Open creationix opened 9 years ago
What problem would Duktape.loadlib
solve in the core distributable? Note that some systems don't even have a file system so concepts like paths and filenames may be completely alien.
For these reasons I've been trying to push all such functionality into the module loading parts provided by the application.
Right, this is why I said to maybe only specify it's behavior. It's entirely possible to do in the embedding app like I've done.
How would this relate to #60?
So the custom logic that uses loadlib
is in the user-configurable part in Duktape.modLoad. Everything can be done in JavaScript to support loading binary addons except for the loadlib
primitive. But since this is highly unportable I can see why core doesn't want it.
My idea was for the built-in modLoad
to check if loadlib
existed and use it for .so
and .dll
files. But now I see even that assumes a lot about platform capabilities.
Module loading is now in extras; adding a DLL capable module loader as an extra is a backlog item so I'll leave this open for now.
Consider adding Duktape.loadlib or at least specifying how it should work since the implementation is not very portable. Here is how I wrote it for dukluv:
It takes a file path and a function name and assumes pushes the function on the stack (assuming it's
duk_c_function
).I integrated this into my prototype require system as the loader for
.so
and.dll
files.Note that is assumes the symbol is
dukopen_
followed by the basename of the file without the extension.