Dev Checkpoint 201906252210
This commit is contained in:
parent
e7993dca97
commit
2c2e638d89
4 changed files with 21 additions and 9 deletions
|
|
@ -1,7 +1,13 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module example
|
||||||
|
|
||||||
|
// placeholder() used to help SWIG generate "SWIG_From_int" call
|
||||||
|
%{
|
||||||
|
int placeholder();
|
||||||
|
%}
|
||||||
|
int placeholder() { return 0; }
|
||||||
|
|
||||||
|
// actual demo code
|
||||||
%wrapper
|
%wrapper
|
||||||
%{
|
%{
|
||||||
#ifdef SWIG_V8_VERSION /* Engine: Node || V8 */
|
#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();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
var example = require("example");
|
var example = require("example");
|
||||||
|
|
||||||
function callback(msg) { console.log(msg); }
|
console.info("My magic number is: ", example.magicNumber());
|
||||||
|
|
||||||
example.num_to_string(callback);
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: C#
|
||||||
|
// TODO: Python
|
||||||
|
|
||||||
|
|
||||||
#ifdef SWIGJAVASCRIPT
|
#ifdef SWIGJAVASCRIPT
|
||||||
%native(CountAlphaCharacters) void JavaScript_alpha_count();
|
%native(CountAlphaCharacters) void JavaScript_alpha_count();
|
||||||
|
|
|
||||||
|
|
@ -787,13 +787,18 @@ int JSEmitter::emitWrapperFunction(Node *n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int JSEmitter::emitNativeFunction(Node *n) {
|
int JSEmitter::emitNativeFunction(Node *n) {
|
||||||
String *wrap_name = Getattr(n, "wrap:name");
|
String *wrapname = Getattr(n, "wrap:name");
|
||||||
|
// ismember never seems to be the case;
|
||||||
Setattr(n, "feature:extend", "last");
|
// 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);
|
enterFunction(n);
|
||||||
state.function(WRAPPER_NAME, wrap_name);
|
state.function(WRAPPER_NAME, wrapname);
|
||||||
exitFunction(n);
|
exitFunction(n);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue