Skip to content

Instantly share code, notes, and snippets.

@morgant morgant/NewtFns.c
Created Jul 25, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.