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

Re: [sc-dev] writing primitives



On Wednesday, November 27, 2002, at 12:07 PM, James McCartney wrote:
SetObject takes a pointer to a slot, but variable 'slot' is uninitialized.
You should do this:

				PyrSlot slot;
				SetObject(&slot, pyrPathString);
                putIndexedSlot(g ,scArray, &slot  ,count);

makes sense.

no crashing now, but the returned array is empty.

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

        // if cancelled, return nil
        if(!urls) {
            SetNil(receiver);
            return errNone;
        } else {
            int i;
            int count = [urls count];
            // array to return
PyrObject *scArray = (PyrObject*)instantiateObject(g->gc, class_array, count, false, true);
            SetObject(receiver,scArray);
            //g->gc->GCWrite(scArray,receiver);

            for (i = 0; i < count; i++)
            {
                NSString *nspath = [[urls objectAtIndex: i ] path];
                NSLog (@"Object at index %d is: %@", i, nspath);

PyrString* pyrPathString = newPyrString(g->gc,[nspath cString],0,true);

                PyrSlot slot;
			  SetObject(&slot, pyrPathString);
                putIndexedSlot(g ,scArray, &slot  ,count);

                g->gc->GCWrite(scArray,pyrPathString);
            }

            return errNone;


thanks a lot.

-felix