Page 1 of 1

FIXED: Ptr Function nearly working

PostPosted: Fri May 21, 2010 5:48 pm
by udo.killermann
Hi Bernd,

thanks for the new beta. I gave it a test drive with a call to AppleScript:
Code: Select all
Declare Class "NSAppleEventDescriptor"

Declare Class "NSAppleScript"
Declare Function "NSAppleScript" + (id)alloc
Declare Function "NSAppleScript" - (id)initWithSource:(NSString *)source

Declare Function "NSAppleScript" - (id) executeAndReturnError: (NSDictionary **) errorInfo

'Declare Class "NSError"


Event AwakeFromNib()
  Dim myScriptString As String
  Dim myASScript As NSAppleScript
  Dim myAEDescriptor As NSAppleEventDescriptor = Nil
 
  Dim err As id = Nil
   
  myScriptString = "choose URL"
 
  myASScript=myASScript.initWithSource(myScriptString) 
  myAEDescriptor=myASScript.executeAndReturnError( errinfo:=err )
 
End Event


This code when compiled results in an exception:
invalid argument exception.tiff
invalid argument exception.tiff (159.74 KiB) Viewed 526 times


errorInfo (name of argument) becomes part of the method name!

If I look into the resulting Objective-C++ code, I see:
Code: Select all
- (id) NSAppleScript_executeAndReturnError:(id)objb_self:(id) errorInfo
{   
[objb_self executeAndReturnError: errorInfo];
}


It should have read:
Code: Select all
- (id) NSAppleScript_executeAndReturnError:(id)objb_self:(id) errorInfo
{      
[objb_self executeAndReturnError: &errorInfo]; // Ampersand missing!
}


When I compile the resulting Objective-C++ files within XCode the program runs as expected!

If you fix this, it will be fun to use.

Kind regards,
Udo

Re: Ptr Function nearly working

PostPosted: Tue May 25, 2010 10:03 am
by berndnoetscher
Hi Udo,

it was a typo and is fixed now. Will upload a new version soon. Thanks for the information.
When you try the new objb version, don't forget to change to make a change in the source file or it won't recompile it and the error will be shown again.

CU
Bernd