Hello,
I am currently documenting and refactoring the code of PuREST JSON to be consistent, but I seem to be unable to rename setup function from setup_json0x2dencode to json_encode_setup, as after renaming, I get the following error:
error: load_object: Symbol "setup_json0x2dencode" not found json-encode error: ... couldn't create
Here is the relevant code:
In purest_json.h:
#ifdef _WIN32 #define APIEXPORT __declspec(dllexport) #define APICALL __cdecl #else #define APIEXPORT #define APICALL #endif
/* [json-encode] */ APIEXPORT void APICALL json_encode_setup(void);
In purest_json.c:
#include "purest_json.h"
void purest_json_setup(void) { post("PuREST JSON version %s: A library for executing HTTP queries and encoding and decoding JSON data from Puredata.", PUREST_JSON_VERSION); post("(c) Thomas Mayer (Residuum) 2013"); post("Get the latest source from https://github.com/residuum/PuRestJson"); post("Website: http://ix.residuum.org/pd/purest_json.html"); post("Report bugs to: purest-json-bugs@ix.residuum.org"); rest_setup(); oauth_setup(); json_encode_setup(); json_decode_setup(); urlparams_setup(); }
And finally in json_encode.c:
void json_encode_setup(void) { json_encode_class = class_new(gensym("json-encode"), (t_newmethod)json_encode_new, (t_method)json_encode_free, sizeof(t_json_encode), 0, A_GIMME, 0); class_addbang(json_encode_class, (t_method)json_encode_bang); class_addmethod(json_encode_class, (t_method)json_encode_add, gensym("add"), A_GIMME, 0); class_addmethod(json_encode_class, (t_method)json_encode_add, gensym("array"), A_GIMME, 0); class_addmethod(json_encode_class, (t_method)json_encode_read, gensym("read"), A_SYMBOL, A_DEFSYM, 0); class_addmethod(json_encode_class, (t_method)json_encode_write, gensym("write"), A_SYMBOL, A_DEFSYM, 0); class_addmethod(json_encode_class, (t_method)json_encode_clear, gensym("clear"), A_GIMME, 0); class_sethelpsymbol(json_encode_class, gensym("json")); }
On 2013-11-14 23:44, Thomas Mayer wrote:
Hello,
I am currently documenting and refactoring the code of PuREST JSON to be consistent, but I seem to be unable to rename setup function from setup_json0x2dencode to json_encode_setup, as after renaming, I get the following error:
error: load_object: Symbol "setup_json0x2dencode" not found json-encode error: ... couldn't create
i'm not sure what you want to acchieve. it seems that you are creating an object [json-encode], which (since it is not loaded yet) will make Pd look for a file named "json-encode.dll" and once it found it, it will look in the dll for an entry function named "setup_json0x2dencode".
Pd will *not* look for the function "json_encode_setup()". Pd uses the library name to calculate the setup function name; a library "foo" must provide a setup-function "foo_setup()". a library with weird characters, like "foo-bar" must provide a setup-function "setup_foo0x2dbar()". there is no way to tell Pd that it should use "foo_setup()" for the library "foo-bar".
so if you do want to use the new setup-function you must: - rename the resulting dll to "json_encode" - use [json_encode] in the patch.
void json_encode_setup(void) { json_encode_class = class_new(gensym("json-encode"),
so which name do you want: "json-encode" (as the class-name suggests) or "json_encode" as the setup-function name suggests?
gfmdsar IOhannes
Hi,
On 15.11.2013 10:43, IOhannes m zmölnig wrote:
i'm not sure what you want to acchieve.
I want to achieve a common naming convention for the setup function of all objects in my library, currently some have the name of <object>_setup, some setup_<object>.
it seems that you are creating an object [json-encode], which (since it is not loaded yet) will make Pd look for a file named "json-encode.dll" and once it found it, it will look in the dll for an entry function named "setup_json0x2dencode".
Pd will *not* look for the function "json_encode_setup()". Pd uses the library name to calculate the setup function name; a library "foo" must provide a setup-function "foo_setup()". a library with weird characters, like "foo-bar" must provide a setup-function "setup_foo0x2dbar()". there is no way to tell Pd that it should use "foo_setup()" for the library "foo-bar".
When I try to rename the function rest_setup() to setup_rest(), Pd tells me
rest error: ... couldn't create error: load_object: Symbol "rest_setup" not found
Does Pd have a cache of setup functions? I am using Pd 0.44.0-extended-20130611
Thanks, Thomas
Hi,
On 15.11.2013 19:28, Thomas Mayer wrote:
On 15.11.2013 10:43, IOhannes m zmölnig wrote:
i'm not sure what you want to acchieve.
I want to achieve a common naming convention for the setup function of all objects in my library, currently some have the name of <object>_setup, some setup_<object>.
it seems that you are creating an object [json-encode], which (since it is not loaded yet) will make Pd look for a file named "json-encode.dll" and once it found it, it will look in the dll for an entry function named "setup_json0x2dencode".
When I try to rename the function rest_setup() to setup_rest(), Pd tells me
rest error: ... couldn't create error: load_object: Symbol "rest_setup" not found
Does Pd have a cache of setup functions? I am using Pd 0.44.0-extended-20130611
I guess, I have found it in s_loader.c lines 129ff:
if (hexmunge) { memmove(symname+6, symname, strlen(symname)+1); strncpy(symname, "setup_", 6); } else strcat(symname, "_setup");
So, for objects that need a special character converted to hex, the setup function must be called setup_<object>, while for other objects the setup function must be called <object>_setup.
This is kind of confusing.
Thanks, Thomas
On 2013-11-16 00:10, Thomas Mayer wrote:
So, for objects that need a special character converted to hex, the setup function must be called setup_<object>, while for other objects the setup function must be called <object>_setup.
This is kind of confusing.
yes, but it's the way it is. the "<object>_setup()" naming scheme, has been introduced in the days of yore and is this practically impossible to change.
the "setup_<hexobject>()" naming scheme is relatively young and only available through the hexloading stuff. "<hexobject>_setup()" does *not* work, as the hexencoded object name might start with a number, and a C-function must start with a character (and not with a digit).
gfsdmr IOhannes