diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bffbd1a..1c441613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented in this file. ## 0.4.0 - ?? +- Add methods to parser values that mirror the api. - Add janet\_getmethod to CAPI for easier use of method like syntax. - Add get/set to abstract types to allow them to behave more like objects with methods. diff --git a/examples/numarray/numarray.c b/examples/numarray/numarray.c index 8f60d680..5a5beb63 100644 --- a/examples/numarray/numarray.c +++ b/examples/numarray/numarray.c @@ -75,26 +75,18 @@ void num_array_put(void *p, Janet key, Janet value) { } } -static const JanetReg methods[] = { - {"scale", num_array_scale,"(:scale numarray factor)"}, - {"sum", num_array_sum,"(:sum numarray)"} +static const JanetMethod methods[] = { + {"scale", num_array_scale}, + {"sum", num_array_sum}, + {NULL, NULL} }; Janet num_array_get(void *p, Janet key) { size_t index; Janet value; num_array * array=(num_array *)p; - if (janet_checktype(key,JANET_KEYWORD)) { - const uint8_t *keyw = janet_unwrap_keyword(key); - const size_t nm = sizeof(methods)/sizeof(JanetReg); - size_t i; - for ( i=0 ; i