1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-28 06:07:43 +00:00

Update janet_getmethod to better match new get api.

This commit is contained in:
Calvin Rose
2019-12-09 18:45:05 -06:00
parent 8ecf359bbe
commit 8700a407ce
7 changed files with 13 additions and 17 deletions

View File

@@ -103,13 +103,15 @@ type janet_opt##name(const Janet *argv, int32_t argc, int32_t n, int32_t dflt_le
return janet_get##name(argv, n); \
}
Janet janet_getmethod(const uint8_t *method, const JanetMethod *methods) {
int janet_getmethod(const uint8_t *method, const JanetMethod *methods, Janet *out) {
while (methods->name) {
if (!janet_cstrcmp(method, methods->name))
return janet_wrap_cfunction(methods->cfun);
if (!janet_cstrcmp(method, methods->name)) {
*out = janet_wrap_cfunction(methods->cfun);
return 1;
}
methods++;
}
return janet_wrap_nil();
return 0;
}
DEFINE_GETTER(number, NUMBER, double)