[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] writing primitives



I'm writing some primitives for the get file dialogs.

i understand a certain amount, but its pretty thick in there.

the sc method takes two args, the definePrimitive call specifies two args.

those two args appear to be at :

	PyrSlot *defaultPath = g->sp;
	PyrSlot *prompt = g->sp + 1;

g->sp - 1 is the class File


i'm getting an array of files via cocoa, which was easy as hell. took 3 minutes to figure out.
made an sc-array, filled the slots.  that took an hour.


now where do i put the thing to return it ?





NSDocumentController *docctl = [NSDocumentController sharedDocumentController];
        if (!docctl) {
            post("No NSDocumentController\n");
            return errFailed;
        }

        // TODO if default path not nil, locate to there

        // TODO prompt
        NSArray *urls =  [docctl URLsFromRunningOpenPanel];

        // TODO if cancelled, return nil


        NSString *nspath;
        int i;
        int count = [urls count];
        // array to return
PyrObject *scArray = (PyrObject*)instantiateObject(g->gc, class_array, count, false, true);

        for (i = 0; i < count; i++)
        {
            nspath = [[urls objectAtIndex: i ] path];
            NSLog (@"Object at index %d is: %@", i, nspath);
PyrString* pyrPathString = newPyrString(g->gc,[nspath cString],false,true);
            putIndexedSlot(g ,scArray,(PyrSlot*)pyrPathString  ,count);
        }

        // return it


	return errNone;






-felix