Dev Checkpoint 201906252210

This commit is contained in:
Chris Walker 2019-06-25 22:10:46 -06:00
parent e7993dca97
commit 2c2e638d89
4 changed files with 21 additions and 9 deletions

View File

@ -1,7 +1,13 @@
/* File : example.i */
%module example
// placeholder() used to help SWIG generate "SWIG_From_int" call
%{
int placeholder();
%}
int placeholder() { return 0; }
// actual demo code
%wrapper
%{
#ifdef SWIG_V8_VERSION /* Engine: Node || V8 */
@ -38,4 +44,4 @@
%}
%native(num_to_string) void JavaScript_exampleV8_callback_function();
%native(magicNumber) void JavaScript_do_work();

View File

@ -1,5 +1,3 @@
var example = require("example");
function callback(msg) { console.log(msg); }
example.num_to_string(callback);
console.info("My magic number is: ", example.magicNumber());

View File

@ -42,6 +42,9 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co
#endif
// TODO: C#
// TODO: Python
#ifdef SWIGJAVASCRIPT
%native(CountAlphaCharacters) void JavaScript_alpha_count();

View File

@ -787,13 +787,18 @@ int JSEmitter::emitWrapperFunction(Node *n) {
}
int JSEmitter::emitNativeFunction(Node *n) {
String *wrap_name = Getattr(n, "wrap:name");
Setattr(n, "feature:extend", "last");
String *wrapname = Getattr(n, "wrap:name");
// ismember never seems to be the case;
// it is technically possible to add native member functions,
// just not at the moment? leaving this as an option for later;
// the code will automatically defaulting to static space
if (GetFlag(n, "ismember") != 0)
Setattr(n, "feature:extend", "1"); // member space
else
Setattr(n, "feature:extend", "0"); // static space
enterFunction(n);
state.function(WRAPPER_NAME, wrap_name);
state.function(WRAPPER_NAME, wrapname);
exitFunction(n);
return SWIG_OK;
}