Skip to content

Instantly share code, notes, and snippets.

@morgant
Created July 25, 2012 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morgant/3173823 to your computer and use it in GitHub Desktop.
Save morgant/3173823 to your computer and use it in GitHub Desktop.
NewtonScript Perform() for NEWT/0
/** Send a message to a method in a frame by name with an array of parameters
*
* @param rcvr [in] レシーバ
* @param frame [in] Frame
* @param message [in] Message
* @param params [in] Parameters
*
* @return Return value
*/
newtRef NsPerform(newtRefArg rcvr, newtRefArg frame, newtRefArg message, newtRefArg params)
{
newtRef ary = NewtRefIsNIL(params) ? NewtMakeArray(kNewtRefUnbind, 0) : params;
return NcSendWithArgArray(frame, message, false, ary);
}
#!newt
someFrame := { SomeMethod: func() begin
Print("SomeMethod!");
end,
SomeOtherMethod: func(number) begin
Print("SomeOtherMethod(" & number & ")!");
end
};
// test Perform() with no arguments to be passed with the message
Perform(someFrame, 'SomeMethod, nil);
// test Perform() with an argument passed with the message
Perform(someFrame, 'SomeOtherMethod, [42]);
true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment