un official properties

dust's picture

so i was asked to make my apple script plugin unsafe. so i decided to delve into the un official sdk.

there are a lot of goodies in there. all kinds of things that i have been thinking of trying to do but do not know how officially.

so my question is directed here as there is no documentation. no worries this is something very simple.. i'm sure.

my plugin has one input a string. it is literally 2 lines of code.

they are.....

NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:(NSString*)inputScript];
   [scriptObject executeAndReturnError:nil];

where inputString is my QCStringPort variable.

i get no compilation errors but QC does spit out this.

-[QCStringPort copyWithZone:]: unrecognized selector sent to instance 0x119f7e0e0

im a bit unclear as to whats going on i'm assuming QCStringPort implements NSCopy. QCPort has a method...

+(id)allocWithZone(NSZone*)fp8 

so usually when i get this type of error i have forgot to to set my properties correctly. in this case i have tried the official way.

@property(assign)NSString* inputFoo;

in addition i have tried...

@property(copy)NSString* inputFoo;
@property(nonatomic, retain)NSString* inputFoo;
etc....

also i have tried to allocate memory directly to the QCStringPort class.

inputScript = [[QCStringPort alloc]init];
[inputSript allocWithZone(NSZone*)QCStringPort];

i am able to print the input to the log which makes no since.

does anybody have any experience with using the un official sdk ?

PreviewAttachmentSize
appleScript.zip2.28 MB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

smokris's picture
Re: un official properties

QCStringPort isn't transparently compatible with NSString — you have to call [inputFoo stringValue] to get an NSString out of it.

Don't use @property, and don't manually alloc/init.

And welcome to the dark side!

dust's picture
Re: un official properties

so far the darkside is exciting. poking around is giving me ideas of what i can make once i can finally get to execution.

just a bit confusing as the QCStringPort setValue is NSString and seeing that one i didn't explicitly set the value i thought maybe there was some transparency going on.

so thats wonderful i just call booVal or stringVal etc... instead of setting property.

ok next question ?

how to set to consumer patch ? i'm able to get the right combo of ints for provider and producer etc... just not consumer.

and second question how to i get the patch to execute? as per my log the init, setup, and cleanup all get called but no execution ?

im supposing i have to do something like [self enableRender:context]...that was totally arbitrary by the way.

i don't see the enabler in the patch either.

i got the nib and UI stuff down. very exciting just like normal.

thanks smorkis.

smokris's picture
Re: un official properties

For a Consumer, do this:

+ (int)executionModeWithIdentifier:(id)fp8
{
   return 2;
}

Once it's set to Consumer, the "Enable" port will automatically appear.

(The executionMode and similar class methods lacking the "WithIdentifier:" part are no longer used as of Leopard, and are only needed for Tiger compatibility. I suggest just deleting them.)

Execute is only called for Consumer patches and for non-Consumer patches when they're connected to Consumer patches. If you're a non-Consumer patch and you have no outputs, you will never execute.

Don't forget to [scriptObject release]!

dust's picture
Re: un official properties

sweet. i noticed that once i hooked up an outlet i was able to get some execution. i read somewhere i think on the download page that only, number, bool, string, struct, and image ports are cool but after checking out some headers there seems to be QCVirtualPort data type. Can I use this ?

im thinking of adding a text view. to the nib like the javascript patch. any suggestions on how i would get the data to persist in the nib easily? meaning when i open the patch again i want the code i wrote last to be in the nib settings.

in theory i grab the text.value pass it to the plugin from the UI and then write it back to the UI text window in the nib ? that seems like it will work while in runtime. the string port persists automatically so that is good for now.

sorry to ask so many questions. you guys seem to be some of the only people doing the un-official magic.

great im excited. now i can try the render info class out.. ;)

thanks smorkis.

dust's picture
Re: un official properties

cool so all is good. once i took out the old identifiers i was able to switch execution modes. so my last question and the most important how do i build for sl ?

everything is running smooth. maybe its just me but a skanky patch seems to execute faster.

so my issue now is the build. i added qc as an executable and when i run from x-code the plugin shows up in qc but when i shut down x-code and re-open qc my plugin doesn't show up.

kineme core recognizes it.

i ran into this problem with a few leopard plugins before.

everything compiles native 10.6 but qc doesn't recognize. the only error i get is with ppc64 so nuked him. i tried building 10.5 as well same thing.

here is screen shot.

1 while x-code is running. 2 while x-code is closed.

do you have an un official sdk laying around you use with SL ?