Add JS Native Wrapper API

This commit is contained in:
TekuConcept 2019-05-08 15:36:46 -06:00
parent f06330e720
commit ff19363abf
1 changed files with 29 additions and 0 deletions

View File

@ -197,6 +197,11 @@ public:
*/
virtual int emitWrapperFunction(Node *n);
/**
* Invoked by nativeWrapper callback
*/
virtual int emitNativeFunction(Node *n);
/**
* Invoked from constantWrapper after call to Language::constantWrapper.
**/
@ -311,6 +316,7 @@ public:
virtual int classHandler(Node *n);
virtual int functionWrapper(Node *n);
virtual int constantWrapper(Node *n);
virtual int nativeWrapper(Node *n);
virtual void main(int argc, char *argv[]);
virtual int top(Node *n);
@ -441,6 +447,18 @@ int JAVASCRIPT::constantWrapper(Node *n) {
return SWIG_OK;
}
/* ---------------------------------------------------------------------
* nativeWrapper()
*
* Function wrapper for generating placeholders for native functions
* --------------------------------------------------------------------- */
int JAVASCRIPT::nativeWrapper(Node *n) {
emitter->emitNativeFunction(n);
return SWIG_OK;
}
/* ---------------------------------------------------------------------
* classHandler()
*
@ -768,6 +786,17 @@ int JSEmitter::emitWrapperFunction(Node *n) {
return ret;
}
int JSEmitter::emitNativeFunction(Node *n) {
String *wrap_name = Getattr(n, "wrap:name");
Setattr(n, "feature:extend", "last");
enterFunction(n);
state.function(WRAPPER_NAME, wrap_name);
exitFunction(n);
return SWIG_OK;
}
int JSEmitter::enterClass(Node *n) {
state.clazz(RESET);
state.clazz(NAME, Getattr(n, "sym:name"));