feat: replace separate methodName/arity params with unified signature string in foreign method API

The wrenDefineMethod and wrenDefineStaticMethod functions now accept a single `signature` string parameter instead of separate `methodName` and `arity` arguments. This simplifies the API by letting callers specify the full method signature (including arity spaces) directly, removing the internal arity-to-spaces conversion logic in defineMethod. The change updates the header declaration, the internal defineMethod helper, and all call sites in wren_io.c to pass pre-formatted signatures.
This commit is contained in:
Bob Nystrom
2015-02-26 15:44:45 +00:00
parent a12b1695a7
commit a24f51d4af
3 changed files with 22 additions and 33 deletions
+8 -8
View File
@@ -124,22 +124,22 @@ WrenInterpretResult wrenInterpret(WrenVM* vm, const char* sourcePath,
// global class named [className] to bind the method to. If not found, it will
// be created automatically.
//
// Defines a method on that class named [methodName] accepting [arity]
// parameters. If a method already exists with that name and arity, it will be
// replaced. When invoked, the method will call [method].
// Defines a method on that class with [signature]. If a method already exists
// with that signature, it will be replaced. When invoked, the method will call
// [method].
void wrenDefineMethod(WrenVM* vm, const char* className,
const char* methodName, int arity,
const char* signature,
WrenForeignMethodFn method);
// Defines a static foreign method implemented by the host application. Looks
// for a global class named [className] to bind the method to. If not found, it
// will be created automatically.
//
// Defines a static method on that class named [methodName] accepting
// [arity] parameters. If a method already exists with that name and arity,
// it will be replaced. When invoked, the method will call [method].
// Defines a static method on that class with [signature]. If a method already
// exists with that signature, it will be replaced. When invoked, the method
// will call [method].
void wrenDefineStaticMethod(WrenVM* vm, const char* className,
const char* methodName, int arity,
const char* signature,
WrenForeignMethodFn method);
// The following functions read one of the arguments passed to a foreign call.