Refactor emitter and code templates to use defined template variables.
Also switched from "${...}" to $..., which is swig's common notation
of typemap variables.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13787 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cdd450fbe4
commit
8d72616e65
2 changed files with 175 additions and 157 deletions
|
|
@ -6,10 +6,12 @@
|
||||||
|
|
||||||
%fragment ("JS_getproperty", "templates")
|
%fragment ("JS_getproperty", "templates")
|
||||||
%{
|
%{
|
||||||
JSValueRef ${getname}(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
|
JSValueRef $jsgetter(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
|
||||||
{
|
{
|
||||||
${LOCALS}
|
$jslocals
|
||||||
${CODE}
|
JSValueRef jsresult;
|
||||||
|
|
||||||
|
$jscode
|
||||||
return jsresult;
|
return jsresult;
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -26,10 +28,10 @@ JSValueRef ${getname}(JSContextRef context, JSObjectRef thisObject, JSStringRef
|
||||||
|
|
||||||
%fragment ("JS_setproperty", "templates")
|
%fragment ("JS_setproperty", "templates")
|
||||||
%{
|
%{
|
||||||
bool ${setname}(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
|
bool $jssetter(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
|
||||||
{
|
{
|
||||||
${LOCALS}
|
$jslocals
|
||||||
${CODE}
|
$jscode
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -46,10 +48,12 @@ bool ${setname}(JSContextRef context, JSObjectRef thisObject, JSStringRef proper
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
%fragment ("JS_functionwrapper", "templates")
|
%fragment ("JS_functionwrapper", "templates")
|
||||||
%{
|
%{
|
||||||
JSValueRef ${functionname}(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
|
JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
|
||||||
{
|
{
|
||||||
${LOCALS}
|
$jslocals
|
||||||
${CODE}
|
JSValueRef jsresult;
|
||||||
|
|
||||||
|
$jscode
|
||||||
return jsresult;
|
return jsresult;
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -60,10 +64,12 @@ JSValueRef ${functionname}(JSContextRef context, JSObjectRef function, JSObjectR
|
||||||
|
|
||||||
%fragment ("JS_functionwrapper_overload", "templates")
|
%fragment ("JS_functionwrapper_overload", "templates")
|
||||||
%{
|
%{
|
||||||
int ${functionname}(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* result)
|
int $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* result)
|
||||||
{
|
{
|
||||||
${LOCALS}
|
$jslocals
|
||||||
${CODE}
|
JSValueRef jsresult;
|
||||||
|
|
||||||
|
$jscode
|
||||||
*result = jsresult;
|
*result = jsresult;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
||||||
|
|
@ -80,83 +86,81 @@ int ${functionname}(JSContextRef context, JSObjectRef function, JSObjectRef this
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
%fragment ("JS_function_dispatch_case", "templates")
|
%fragment ("JS_function_dispatch_case", "templates")
|
||||||
%{if(argc == ${argcount}) {
|
%{if(argc == $jsargcount) {
|
||||||
res = ${functionwrapper}(context, function, thisObject, argc, argv, exception, &jsresult);
|
res = $jswrapper(context, function, thisObject, argc, argv, exception, &jsresult);
|
||||||
if(res == SWIG_OK) { *exception = 0; return jsresult; }
|
if(res == SWIG_OK) { *exception = 0; return jsresult; }
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%fragment ("JS_function_dispatch_case_default", "templates")
|
%fragment ("JS_function_dispatch_case_default", "templates")
|
||||||
%{
|
%{
|
||||||
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function ${functionname}.");
|
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname.");
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Added template for function declaration */
|
/* Added template for function declaration */
|
||||||
|
|
||||||
%fragment ("JS_variabledecl", "templates")
|
%fragment ("JS_variabledecl", "templates")
|
||||||
%{{"${propertyname}",${getname}, ${setname},kJSPropertyAttributeNone},%}
|
%{{"$jsname", $jsgetter, $jssetter, kJSPropertyAttributeNone},%}
|
||||||
|
|
||||||
|
|
||||||
/* Added template for function declaration */
|
/* Added template for function declaration */
|
||||||
|
|
||||||
%fragment ("JS_functiondecl", "templates")
|
%fragment ("JS_functiondecl", "templates")
|
||||||
%{{"${functionname}",${functionwrapper}, kJSPropertyAttributeNone},%}
|
%{{"$jsname",$jswrapper, kJSPropertyAttributeNone},%}
|
||||||
|
|
||||||
%fragment ("JS_globaldefn", "templates")
|
%fragment ("JS_globaldefn", "templates")
|
||||||
%{
|
%{
|
||||||
JSStaticValue ${namespace}_values[] = {
|
JSStaticValue $jsnspace_values[] = {
|
||||||
${jsglobalvariables}
|
$jsglobalvariables
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
JSStaticFunction ${namespace}_functions[] = {
|
JSStaticFunction $jsnspace_functions[] = {
|
||||||
${jsglobalfunctions}
|
$jsglobalfunctions
|
||||||
{ 0, 0, 0 }
|
{ 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
JSClassDefinition ${namespace}_classDefinition;
|
JSClassDefinition $jsnspace_classDefinition;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/******************************************************************************************
|
/***********************************************************************
|
||||||
* class_definition:
|
* class_definition:
|
||||||
* This code template is used for wrapper of classes definition.
|
* declarations of javascript class definition objects.
|
||||||
* ${classname_mangled}:the mangled name of the qualified class name, e.g., foo::A -> foo_A
|
***********************************************************************/
|
||||||
*****************************************************************************************/
|
|
||||||
|
|
||||||
%fragment ("JS_class_definition", "templates")
|
%fragment ("JS_class_definition", "templates")
|
||||||
%{
|
%{
|
||||||
JSClassDefinition ${classname_mangled}_classDefinition;
|
JSClassDefinition $jsmangledname_classDefinition;
|
||||||
|
|
||||||
JSClassDefinition ${classname_mangled}_objectDefinition;
|
JSClassDefinition $jsmangledname_objectDefinition;
|
||||||
|
|
||||||
JSClassRef ${classname_mangled}_classRef;
|
JSClassRef $jsmangledname_classRef;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/*********************************************************************
|
/***********************************************************************
|
||||||
* class_table:
|
* class_table:
|
||||||
* This code template is used to add the wrapper for class declaration
|
* function and variable tables for class and object creation.
|
||||||
* ${classname_mangled}: The mangled name of the qualified class name, e.g., foo::A -> foo_A
|
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
%fragment ("JS_class_tables", "templates")
|
%fragment ("JS_class_tables", "templates")
|
||||||
%{
|
%{
|
||||||
JSStaticValue ${classname_mangled}_staticValues[] = {
|
JSStaticValue $jsmangledname_staticValues[] = {
|
||||||
${jsstaticclassvariables}
|
$jsstaticclassvariables
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
JSStaticFunction ${classname_mangled}_staticFunctions[] = {
|
JSStaticFunction $jsmangledname_staticFunctions[] = {
|
||||||
${jsstaticclassfunctions}
|
$jsstaticclassfunctions
|
||||||
{ 0, 0, 0 }
|
{ 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
JSStaticValue ${classname_mangled}_values[] = {
|
JSStaticValue $jsmangledname_values[] = {
|
||||||
${jsclassvariables}
|
$jsclassvariables
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
JSStaticFunction ${classname_mangled}_functions[] = {
|
JSStaticFunction $jsmangledname_functions[] = {
|
||||||
${jsclassfunctions}
|
$jsclassfunctions
|
||||||
{ 0, 0, 0 }
|
{ 0, 0, 0 }
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
@ -164,15 +168,14 @@ JSStaticFunction ${classname_mangled}_functions[] = {
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* destructordefn:
|
* destructordefn:
|
||||||
* This code template is used to adds the destructor wrapper function
|
* This code template is used to adds the destructor wrapper function
|
||||||
* ${classname_mangled}: The mangled name of the qualified class name, e.g., foo::A -> foo_A
|
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
%fragment ("JS_destructordefn", "templates")
|
%fragment ("JS_destructordefn", "templates")
|
||||||
%{
|
%{
|
||||||
void _wrap_${classname_mangled}_finalize(JSObjectRef thisObject)
|
void _wrap_$jsmangledname_finalize(JSObjectRef thisObject)
|
||||||
{
|
{
|
||||||
SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject);
|
SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject);
|
||||||
if(t && t->swigCMemOwn) free ((${type}*)t->swigCObject);
|
if(t && t->swigCMemOwn) free (($jstype*)t->swigCObject);
|
||||||
if(t) free(t);
|
if(t) free(t);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
@ -180,22 +183,21 @@ void _wrap_${classname_mangled}_finalize(JSObjectRef thisObject)
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* constructor_definition:
|
* constructor_definition:
|
||||||
* This code template is used to adds the main constructor wrapper function
|
* This code template is used to adds the main constructor wrapper function
|
||||||
* ${classname_mangled}: The mangled name of the qualified class name, e.g., foo::A -> foo_A
|
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
%fragment ("JS_mainctordefn", "templates")
|
%fragment ("JS_mainctordefn", "templates")
|
||||||
%{
|
%{
|
||||||
JSObjectRef _wrap_create_${classname_mangled}(JSContextRef context, JSObjectRef ctorObject,
|
JSObjectRef _wrap_create_$jsmangledname(JSContextRef context, JSObjectRef ctorObject,
|
||||||
size_t argc, const JSValueRef argv[], JSValueRef* exception)
|
size_t argc, const JSValueRef argv[], JSValueRef* exception)
|
||||||
{
|
{
|
||||||
JSObjectRef thisObject = NULL;
|
JSObjectRef thisObject = NULL;
|
||||||
|
|
||||||
// switch all cases by means of series of if-returns.
|
// switch all cases by means of series of if-returns.
|
||||||
${DISPATCH_CASES}
|
$jsdispatchcases
|
||||||
|
|
||||||
// default:
|
// default:
|
||||||
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for contruction of ${classname_mangled}");
|
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for contruction of $jsmangledname");
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return thisObject;
|
return thisObject;
|
||||||
|
|
@ -207,8 +209,8 @@ ctor_dispatch_case: This template is used for the constructor which is overloade
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
|
|
||||||
%fragment ("JS_ctor_dispatch_case", "templates")
|
%fragment ("JS_ctor_dispatch_case", "templates")
|
||||||
%{if(argc == ${argcount}) {
|
%{if(argc == $jsargcount) {
|
||||||
thisObject = _wrap_create_${classname_mangled}${overloadext}(context, NULL, argc, argv, exception);
|
thisObject = _wrap_create_$jsmangledname$jsoverloadext(context, NULL, argc, argv, exception);
|
||||||
if(thisObject != NULL) { *exception=0; return thisObject; } /* reset exception and return */
|
if(thisObject != NULL) { *exception=0; return thisObject; } /* reset exception and return */
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
@ -216,12 +218,12 @@ ctor_dispatch_case: This template is used for the constructor which is overloade
|
||||||
|
|
||||||
%fragment ("JS_ctordefn", "templates")
|
%fragment ("JS_ctordefn", "templates")
|
||||||
%{
|
%{
|
||||||
JSObjectRef _wrap_create_${classname_mangled}${overloadext}(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
|
JSObjectRef _wrap_create_$jsmangledname$jsoverloadext(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
|
||||||
{
|
{
|
||||||
${LOCALS}
|
$jslocals
|
||||||
${CODE}
|
$jscode
|
||||||
|
|
||||||
return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_${type_mangled}, SWIG_POINTER_OWN);
|
return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
|
|
@ -237,7 +239,7 @@ initializer:This template is dynamic growing and aggregates everything
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool ${modulename}_initialize(JSGlobalContextRef context) {
|
bool $jsname_initialize(JSGlobalContextRef context) {
|
||||||
SWIG_InitializeModule(0);
|
SWIG_InitializeModule(0);
|
||||||
|
|
||||||
JSObjectRef global_object = JSContextGetGlobalObject(context);
|
JSObjectRef global_object = JSContextGetGlobalObject(context);
|
||||||
|
|
@ -248,13 +250,13 @@ bool ${modulename}_initialize(JSGlobalContextRef context) {
|
||||||
_SwigObject_classRef = JSClassCreate(&_SwigObject_objectDefinition);
|
_SwigObject_classRef = JSClassCreate(&_SwigObject_objectDefinition);
|
||||||
|
|
||||||
/* Create objects for namespaces */
|
/* Create objects for namespaces */
|
||||||
${create_namespaces}
|
$jscreatenamespaces
|
||||||
|
|
||||||
/* Create classes */
|
/* Create classes */
|
||||||
${initializercode}
|
$jsinitializercode
|
||||||
|
|
||||||
/* Register namespaces */
|
/* Register namespaces */
|
||||||
${register_namespaces}
|
$jsregisternamespaces
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -268,41 +270,35 @@ bool ${modulename}_initialize(JSGlobalContextRef context) {
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
*create_class_template:
|
*create_class_template:
|
||||||
*This template is used to add a Static references to class templates.
|
*This template is used to add a Static references to class templates.
|
||||||
*${classname_mangled}: The mangled name of the qualified class name, e.g., foo::A -> foo_A
|
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
|
|
||||||
%fragment ("JS_create_class_template", "templates")
|
%fragment ("JS_create_class_template", "templates")
|
||||||
%{ ${classname_mangled}_classDefinition.staticFunctions = ${classname_mangled}_staticFunctions;
|
%{ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_staticFunctions;
|
||||||
${classname_mangled}_classDefinition.staticValues = ${classname_mangled}_staticValues;
|
$jsmangledname_classDefinition.staticValues = $jsmangledname_staticValues;
|
||||||
${classname_mangled}_classDefinition.callAsConstructor = _wrap_create_${classname_mangled};
|
$jsmangledname_classDefinition.callAsConstructor = _wrap_create_$jsmangledname;
|
||||||
${classname_mangled}_objectDefinition.staticValues = ${classname_mangled}_values;
|
$jsmangledname_objectDefinition.staticValues = $jsmangledname_values;
|
||||||
${classname_mangled}_objectDefinition.staticFunctions = ${classname_mangled}_functions;
|
$jsmangledname_objectDefinition.staticFunctions = $jsmangledname_functions;
|
||||||
${classname_mangled}_objectDefinition.parentClass = ${base_classname}_classRef;
|
$jsmangledname_objectDefinition.parentClass = $jsbaseclass_classRef;
|
||||||
JSClassRef ${classname_mangled}_classRef = JSClassCreate(&${classname_mangled}_objectDefinition);
|
JSClassRef $jsmangledname_classRef = JSClassCreate(&$jsmangledname_objectDefinition);
|
||||||
SWIGTYPE_${classtype_mangled}->clientdata = ${classname_mangled}_classRef;%}
|
SWIGTYPE_$jsmangledtype->clientdata = $jsmangledname_classRef;%}
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
*register_class:
|
*register_class:
|
||||||
*This template is used to adds a class registration statement to initializer function
|
* This template is used to adds a class registration statement to initializer function
|
||||||
*${classname_mangled}: The mangled name of the qualified class name, e.g., foo::A -> foo_A
|
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
|
|
||||||
%fragment ("JS_register_class", "templates")
|
%fragment ("JS_register_class", "templates")
|
||||||
%{JS_registerClass(context, ${namespace_mangled}_object, "${classname}", &${classname_mangled}_classDefinition);%}
|
%{JS_registerClass(context, $jsnspace_object, "$jsname", &$jsmangledname_classDefinition);%}
|
||||||
|
|
||||||
/* register global function */
|
|
||||||
%fragment ("JS_register_global_function", "templates")
|
|
||||||
%{JS_registerFunction(${context}, ${context_object}, "${functionname}", ${functionwrapper});%}
|
|
||||||
|
|
||||||
|
|
||||||
/* create and register namespaces */
|
/* create and register namespaces */
|
||||||
|
|
||||||
%fragment ("JS_create_namespace", "templates")
|
%fragment ("JS_create_namespace", "templates")
|
||||||
%{ ${namespace}_classDefinition.staticFunctions = ${namespace}_functions;
|
%{ $jsmangledname_classDefinition.staticFunctions = $jsmangledname_functions;
|
||||||
${namespace}_classDefinition.staticValues = ${namespace}_values;
|
$jsmangledname_classDefinition.staticValues = $jsmangledname_values;
|
||||||
JSObjectRef ${namespace}_object = JSObjectMake(context, JSClassCreate(&${namespace}_classDefinition), NULL);
|
JSObjectRef $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%fragment ("JS_register_namespace", "templates")
|
%fragment ("JS_register_namespace", "templates")
|
||||||
%{
|
%{
|
||||||
JS_registerNamespace(context, ${namespace_mangled}_object, ${parent_namespace}_object, "${namespace}"); %}
|
JS_registerNamespace(context, $jsmangledname_object, $jsparent_object, "$jsname"); %}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,27 @@ bool js_template_enable_debug = false;
|
||||||
#define WRAPPER_NAME "wrapper"
|
#define WRAPPER_NAME "wrapper"
|
||||||
#define IS_IMMUTABLE "is_immutable"
|
#define IS_IMMUTABLE "is_immutable"
|
||||||
#define IS_STATIC "is_static"
|
#define IS_STATIC "is_static"
|
||||||
|
#define GETTER "getter"
|
||||||
|
#define SETTER "setter"
|
||||||
|
#define PARENT "parent"
|
||||||
|
|
||||||
|
// variables used in code templates
|
||||||
|
// ATTENTION: be aware of prefix collisions when defining those variables
|
||||||
|
#define T_NAME "$jsname"
|
||||||
|
#define T_NAME_MANGLED "$jsmangledname"
|
||||||
|
#define T_TYPE "$jstype"
|
||||||
|
#define T_TYPE_MANGLED "$jsmangledtype"
|
||||||
|
#define T_WRAPPER "$jswrapper"
|
||||||
|
#define T_GETTER "$jsgetter"
|
||||||
|
#define T_SETTER "$jssetter"
|
||||||
|
#define T_DISPATCH_CASES "$jsdispatchcases"
|
||||||
|
#define T_BASECLASS "$jsbaseclass"
|
||||||
|
#define T_NAMESPACE "$jsnspace"
|
||||||
|
#define T_PARENT "$jsparent"
|
||||||
|
#define T_OVERLOAD "$jsoverloadext"
|
||||||
|
#define T_ARGCOUNT "$jsargcount"
|
||||||
|
#define T_LOCALS "$jslocals"
|
||||||
|
#define T_CODE "$jscode"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience class to manage state variables for emitters.
|
* A convenience class to manage state variables for emitters.
|
||||||
|
|
@ -569,6 +590,8 @@ JSEmitter::~JSEmitter() {
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* JSEmitter::RegisterTemplate() : Registers a code template
|
* JSEmitter::RegisterTemplate() : Registers a code template
|
||||||
|
*
|
||||||
|
* Note: this is used only by JAVASCRIPT::fragmentDirective().
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int JSEmitter::registerTemplate(const String *name, const String *code) {
|
int JSEmitter::registerTemplate(const String *name, const String *code) {
|
||||||
|
|
@ -576,7 +599,7 @@ int JSEmitter::registerTemplate(const String *name, const String *code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* JSEmitter::getTemplate() : Retrieves a registered a code template
|
* JSEmitter::getTemplate() : Provides a registered code template
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
Template JSEmitter::getTemplate(const String *name) {
|
Template JSEmitter::getTemplate(const String *name) {
|
||||||
|
|
@ -624,6 +647,9 @@ Parm *JSEmitter::skipIgnoredArgs(Parm *p) {
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* JSEmitter::getBaseClass() : the node of the base class or NULL
|
* JSEmitter::getBaseClass() : the node of the base class or NULL
|
||||||
|
*
|
||||||
|
* Note: the first base class is provided. Multiple inheritance is not
|
||||||
|
* supported.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
Node *JSEmitter::getBaseClass(Node *n) {
|
Node *JSEmitter::getBaseClass(Node *n) {
|
||||||
|
|
@ -640,7 +666,10 @@ Node *JSEmitter::getBaseClass(Node *n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* JSEmitter::emitWrapperFunction() : dispatches emitter functions
|
* JSEmitter::emitWrapperFunction() : dispatches emitter functions.
|
||||||
|
*
|
||||||
|
* This allows to have small sized, dedicated emitting functions.
|
||||||
|
* All state dependent branching is done here.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int JSEmitter::emitWrapperFunction(Node *n) {
|
int JSEmitter::emitWrapperFunction(Node *n) {
|
||||||
|
|
@ -737,7 +766,7 @@ int JSEmitter::switchNamespace(Node *n) {
|
||||||
String *scope = Swig_scopename_prefix(Getattr(n, "name"));
|
String *scope = Swig_scopename_prefix(Getattr(n, "name"));
|
||||||
if (scope) {
|
if (scope) {
|
||||||
// if the scope is not yet registered
|
// if the scope is not yet registered
|
||||||
// create all scopes/namespaces recursively
|
// create (parent) namespaces recursively
|
||||||
if (!Getattr(namespaces, scope)) {
|
if (!Getattr(namespaces, scope)) {
|
||||||
createNamespace(scope);
|
createNamespace(scope);
|
||||||
}
|
}
|
||||||
|
|
@ -774,9 +803,9 @@ int JSEmitter::createNamespace(String *scope) {
|
||||||
Hash *JSEmitter::createNamespaceEntry(const char *_name, const char *parent) {
|
Hash *JSEmitter::createNamespaceEntry(const char *_name, const char *parent) {
|
||||||
Hash *entry = NewHash();
|
Hash *entry = NewHash();
|
||||||
String *name = NewString(_name);
|
String *name = NewString(_name);
|
||||||
Setattr(entry, "name", Swig_scopename_last(name));
|
Setattr(entry, NAME, Swig_scopename_last(name));
|
||||||
Setattr(entry, "name_mangled", Swig_name_mangle(name));
|
Setattr(entry, NAME_MANGLED, Swig_name_mangle(name));
|
||||||
Setattr(entry, "parent", NewString(parent));
|
Setattr(entry, PARENT, NewString(parent));
|
||||||
|
|
||||||
Delete(name);
|
Delete(name);
|
||||||
return entry;
|
return entry;
|
||||||
|
|
@ -851,8 +880,6 @@ private:
|
||||||
|
|
||||||
// keys for function scoped state variables
|
// keys for function scoped state variables
|
||||||
#define FUNCTION_DISPATCHERS "function_dispatchers"
|
#define FUNCTION_DISPATCHERS "function_dispatchers"
|
||||||
#define GETTER "getter"
|
|
||||||
#define SETTER "setter"
|
|
||||||
|
|
||||||
JSCEmitter::JSCEmitter()
|
JSCEmitter::JSCEmitter()
|
||||||
: JSEmitter(),
|
: JSEmitter(),
|
||||||
|
|
@ -988,10 +1015,10 @@ int JSCEmitter::dump(Node *n) {
|
||||||
|
|
||||||
// compose the initializer function using a template
|
// compose the initializer function using a template
|
||||||
Template initializer(getTemplate("JS_initializer"));
|
Template initializer(getTemplate("JS_initializer"));
|
||||||
initializer.replace("${modulename}", module)
|
initializer.replace(T_NAME, module)
|
||||||
.replace("${initializercode}", state.global(INITIALIZER))
|
.replace("$jsinitializercode", state.global(INITIALIZER))
|
||||||
.replace("${create_namespaces}", state.global(CREATE_NAMESPACES))
|
.replace("$jscreatenamespaces", state.global(CREATE_NAMESPACES))
|
||||||
.replace("${register_namespaces}", state.global(REGISTER_NAMESPACES))
|
.replace("$jsregisternamespaces", state.global(REGISTER_NAMESPACES))
|
||||||
.pretty_print(f_init);
|
.pretty_print(f_init);
|
||||||
|
|
||||||
Printv(f_wrap_cpp, f_init, 0);
|
Printv(f_wrap_cpp, f_init, 0);
|
||||||
|
|
@ -1046,8 +1073,8 @@ int JSCEmitter::exitFunction(Node *n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t_function.replace("${functionname}", state.function(NAME))
|
t_function.replace(T_NAME, state.function(NAME))
|
||||||
.replace("${functionwrapper}", state.function(WRAPPER_NAME));
|
.replace(T_WRAPPER, state.function(WRAPPER_NAME));
|
||||||
|
|
||||||
if (is_member) {
|
if (is_member) {
|
||||||
if (GetFlag(state.function(), IS_STATIC)) {
|
if (GetFlag(state.function(), IS_STATIC)) {
|
||||||
|
|
@ -1074,9 +1101,9 @@ int JSCEmitter::enterVariable(Node *n) {
|
||||||
|
|
||||||
int JSCEmitter::exitVariable(Node *n) {
|
int JSCEmitter::exitVariable(Node *n) {
|
||||||
Template t_variable(getTemplate("JS_variabledecl"));
|
Template t_variable(getTemplate("JS_variabledecl"));
|
||||||
t_variable.replace("${setname}", state.variable(SETTER))
|
t_variable.replace(T_NAME, state.variable(NAME))
|
||||||
.replace("${getname}", state.variable(GETTER))
|
.replace(T_GETTER, state.variable(GETTER))
|
||||||
.replace("${propertyname}", state.variable(NAME));
|
.replace(T_SETTER, state.variable(SETTER));
|
||||||
|
|
||||||
if (GetFlag(n, "ismember")) {
|
if (GetFlag(n, "ismember")) {
|
||||||
if (GetFlag(state.function(), IS_STATIC)
|
if (GetFlag(state.function(), IS_STATIC)
|
||||||
|
|
@ -1103,7 +1130,7 @@ int JSCEmitter::enterClass(Node *n) {
|
||||||
state.clazz(CTOR_DISPATCHERS, NewString(""));
|
state.clazz(CTOR_DISPATCHERS, NewString(""));
|
||||||
|
|
||||||
Template t_class_defn = getTemplate("JS_class_definition");
|
Template t_class_defn = getTemplate("JS_class_definition");
|
||||||
t_class_defn.replace("${classname_mangled}", state.clazz(NAME_MANGLED))
|
t_class_defn.replace(T_NAME_MANGLED, state.clazz(NAME_MANGLED))
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
@ -1112,11 +1139,11 @@ int JSCEmitter::enterClass(Node *n) {
|
||||||
int JSCEmitter::exitClass(Node *n) {
|
int JSCEmitter::exitClass(Node *n) {
|
||||||
|
|
||||||
Template t_class_tables(getTemplate("JS_class_tables"));
|
Template t_class_tables(getTemplate("JS_class_tables"));
|
||||||
t_class_tables.replace("${classname_mangled}", state.clazz(NAME_MANGLED))
|
t_class_tables.replace(T_NAME_MANGLED, state.clazz(NAME_MANGLED))
|
||||||
.replace("${jsclassvariables}", state.clazz(MEMBER_VARIABLES))
|
.replace("$jsclassvariables", state.clazz(MEMBER_VARIABLES))
|
||||||
.replace("${jsclassfunctions}", state.clazz(MEMBER_FUNCTIONS))
|
.replace("$jsclassfunctions", state.clazz(MEMBER_FUNCTIONS))
|
||||||
.replace("${jsstaticclassfunctions}", state.clazz(STATIC_FUNCTIONS))
|
.replace("$jsstaticclassfunctions", state.clazz(STATIC_FUNCTIONS))
|
||||||
.replace("${jsstaticclassvariables}", state.clazz(STATIC_VARIABLES))
|
.replace("$jsstaticclassvariables", state.clazz(STATIC_VARIABLES))
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
/* adds the ctor wrappers at this position */
|
/* adds the ctor wrappers at this position */
|
||||||
|
|
@ -1125,8 +1152,8 @@ int JSCEmitter::exitClass(Node *n) {
|
||||||
|
|
||||||
/* adds the main constructor wrapper function */
|
/* adds the main constructor wrapper function */
|
||||||
Template t_mainctor(getTemplate("JS_mainctordefn"));
|
Template t_mainctor(getTemplate("JS_mainctordefn"));
|
||||||
t_mainctor.replace("${classname_mangled}", state.clazz(NAME_MANGLED))
|
t_mainctor.replace(T_NAME_MANGLED, state.clazz(NAME_MANGLED))
|
||||||
.replace("${DISPATCH_CASES}", state.clazz(CTOR_DISPATCHERS))
|
.replace(T_DISPATCH_CASES, state.clazz(CTOR_DISPATCHERS))
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
/* adds a class template statement to initializer function */
|
/* adds a class template statement to initializer function */
|
||||||
|
|
@ -1139,9 +1166,9 @@ int JSCEmitter::exitClass(Node *n) {
|
||||||
Delete(base_name_mangled);
|
Delete(base_name_mangled);
|
||||||
base_name_mangled = SwigType_manglestr(Getattr(base_class, "name"));
|
base_name_mangled = SwigType_manglestr(Getattr(base_class, "name"));
|
||||||
}
|
}
|
||||||
t_classtemplate.replace("${classname_mangled}", state.clazz(NAME_MANGLED))
|
t_classtemplate.replace(T_NAME_MANGLED, state.clazz(NAME_MANGLED))
|
||||||
.replace("${classtype_mangled}", state.clazz(TYPE_MANGLED))
|
.replace(T_TYPE_MANGLED, state.clazz(TYPE_MANGLED))
|
||||||
.replace("${base_classname}", base_name_mangled)
|
.replace(T_BASECLASS, base_name_mangled)
|
||||||
.pretty_print(state.global(INITIALIZER));
|
.pretty_print(state.global(INITIALIZER));
|
||||||
Delete(base_name_mangled);
|
Delete(base_name_mangled);
|
||||||
|
|
||||||
|
|
@ -1150,9 +1177,9 @@ int JSCEmitter::exitClass(Node *n) {
|
||||||
|
|
||||||
/* adds a class registration statement to initializer function */
|
/* adds a class registration statement to initializer function */
|
||||||
Template t_registerclass(getTemplate("JS_register_class"));
|
Template t_registerclass(getTemplate("JS_register_class"));
|
||||||
t_registerclass.replace("${classname}", state.clazz(NAME))
|
t_registerclass.replace(T_NAME, state.clazz(NAME))
|
||||||
.replace("${classname_mangled}", state.clazz(NAME_MANGLED))
|
.replace(T_NAME_MANGLED, state.clazz(NAME_MANGLED))
|
||||||
.replace("${namespace_mangled}", Getattr(current_namespace, "name_mangled"))
|
.replace(T_NAMESPACE, Getattr(current_namespace, NAME_MANGLED))
|
||||||
.pretty_print(state.global(INITIALIZER));
|
.pretty_print(state.global(INITIALIZER));
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
@ -1180,19 +1207,19 @@ int JSEmitter::emitCtor(Node *n) {
|
||||||
marshalInputArgs(n, params, wrapper, Ctor, true, false);
|
marshalInputArgs(n, params, wrapper, Ctor, true, false);
|
||||||
|
|
||||||
Printv(wrapper->code, action, "\n", 0);
|
Printv(wrapper->code, action, "\n", 0);
|
||||||
t_ctor.replace("${classname_mangled}", mangled_name)
|
t_ctor.replace(T_NAME_MANGLED, mangled_name)
|
||||||
.replace("${overloadext}", overname)
|
.replace(T_OVERLOAD, overname)
|
||||||
.replace("${LOCALS}", wrapper->locals)
|
.replace(T_LOCALS, wrapper->locals)
|
||||||
.replace("${CODE}", wrapper->code)
|
.replace(T_CODE, wrapper->code)
|
||||||
.replace("${type_mangled}", state.clazz(TYPE_MANGLED))
|
.replace(T_TYPE_MANGLED, state.clazz(TYPE_MANGLED))
|
||||||
.pretty_print(state.clazz(CTORS));
|
.pretty_print(state.clazz(CTORS));
|
||||||
|
|
||||||
String *argcount = NewString("");
|
String *argcount = NewString("");
|
||||||
Printf(argcount, "%d", num_args);
|
Printf(argcount, "%d", num_args);
|
||||||
Template t_ctor_case(getTemplate("JS_ctor_dispatch_case"));
|
Template t_ctor_case(getTemplate("JS_ctor_dispatch_case"));
|
||||||
t_ctor_case.replace("${classname_mangled}", mangled_name)
|
t_ctor_case.replace(T_NAME_MANGLED, mangled_name)
|
||||||
.replace("${overloadext}", overname)
|
.replace(T_OVERLOAD, overname)
|
||||||
.replace("${argcount}", argcount);
|
.replace(T_ARGCOUNT, argcount);
|
||||||
Append(state.clazz(CTOR_DISPATCHERS), t_ctor_case.str());
|
Append(state.clazz(CTOR_DISPATCHERS), t_ctor_case.str());
|
||||||
Delete(argcount);
|
Delete(argcount);
|
||||||
|
|
||||||
|
|
@ -1204,8 +1231,8 @@ int JSEmitter::emitCtor(Node *n) {
|
||||||
int JSEmitter::emitDtor(Node *) {
|
int JSEmitter::emitDtor(Node *) {
|
||||||
|
|
||||||
Template t_dtor = getTemplate("JS_destructordefn");
|
Template t_dtor = getTemplate("JS_destructordefn");
|
||||||
t_dtor.replace("${classname_mangled}", state.clazz(NAME_MANGLED))
|
t_dtor.replace(T_NAME_MANGLED, state.clazz(NAME_MANGLED))
|
||||||
.replace("${type}", state.clazz(TYPE))
|
.replace(T_TYPE, state.clazz(TYPE))
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
@ -1224,16 +1251,15 @@ int JSEmitter::emitGetter(Node *n, bool is_member, bool is_static) {
|
||||||
ParmList *params = Getattr(n, "parms");
|
ParmList *params = Getattr(n, "parms");
|
||||||
emit_parameter_variables(params, wrapper);
|
emit_parameter_variables(params, wrapper);
|
||||||
emit_attach_parmmaps(params, wrapper);
|
emit_attach_parmmaps(params, wrapper);
|
||||||
Wrapper_add_local(wrapper, "jsresult", "JSValueRef jsresult");
|
|
||||||
|
|
||||||
// prepare code part
|
// prepare code part
|
||||||
String *action = emit_action(n);
|
String *action = emit_action(n);
|
||||||
marshalInputArgs(n, params, wrapper, Getter, is_member, is_static);
|
marshalInputArgs(n, params, wrapper, Getter, is_member, is_static);
|
||||||
marshalOutput(n, action, wrapper);
|
marshalOutput(n, action, wrapper);
|
||||||
|
|
||||||
t_getter.replace("${getname}", wrap_name)
|
t_getter.replace(T_GETTER, wrap_name)
|
||||||
.replace("${LOCALS}", wrapper->locals)
|
.replace(T_LOCALS, wrapper->locals)
|
||||||
.replace("${CODE}", wrapper->code)
|
.replace(T_CODE, wrapper->code)
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
DelWrapper(wrapper);
|
DelWrapper(wrapper);
|
||||||
|
|
@ -1267,9 +1293,9 @@ int JSEmitter::emitSetter(Node *n, bool is_member, bool is_static) {
|
||||||
marshalInputArgs(n, params, wrapper, Setter, is_member, is_static);
|
marshalInputArgs(n, params, wrapper, Setter, is_member, is_static);
|
||||||
Append(wrapper->code, action);
|
Append(wrapper->code, action);
|
||||||
|
|
||||||
t_setter.replace("${setname}", wrap_name)
|
t_setter.replace(T_SETTER, wrap_name)
|
||||||
.replace("${LOCALS}", wrapper->locals)
|
.replace(T_LOCALS, wrapper->locals)
|
||||||
.replace("${CODE}", wrapper->code)
|
.replace(T_CODE, wrapper->code)
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
DelWrapper(wrapper);
|
DelWrapper(wrapper);
|
||||||
|
|
@ -1296,9 +1322,6 @@ int JSEmitter::emitConstant(Node *n) {
|
||||||
state.variable(GETTER, wrap_name);
|
state.variable(GETTER, wrap_name);
|
||||||
Setattr(n, "wrap:name", wrap_name);
|
Setattr(n, "wrap:name", wrap_name);
|
||||||
|
|
||||||
// prepare local variables
|
|
||||||
Wrapper_add_local(wrapper, "jsresult", "JSValueRef jsresult");
|
|
||||||
|
|
||||||
// prepare code part
|
// prepare code part
|
||||||
String *action = NewString("");
|
String *action = NewString("");
|
||||||
String *value = Getattr(n, "rawval");
|
String *value = Getattr(n, "rawval");
|
||||||
|
|
@ -1312,9 +1335,9 @@ int JSEmitter::emitConstant(Node *n) {
|
||||||
Setattr(n, "wrap:action", action);
|
Setattr(n, "wrap:action", action);
|
||||||
marshalOutput(n, action, wrapper);
|
marshalOutput(n, action, wrapper);
|
||||||
|
|
||||||
t_getter.replace("${getname}", wrap_name)
|
t_getter.replace(T_GETTER, wrap_name)
|
||||||
.replace("${LOCALS}", wrapper->locals)
|
.replace(T_LOCALS, wrapper->locals)
|
||||||
.replace("${CODE}", wrapper->code)
|
.replace(T_CODE, wrapper->code)
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
exitVariable(n);
|
exitVariable(n);
|
||||||
|
|
@ -1334,8 +1357,8 @@ int JSEmitter::emitFunction(Node *n, bool is_member, bool is_static) {
|
||||||
// prepare the function wrapper name
|
// prepare the function wrapper name
|
||||||
String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name"));
|
String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name"));
|
||||||
if (is_overloaded) {
|
if (is_overloaded) {
|
||||||
Append(wrap_name, Getattr(n, "sym:overname"));
|
|
||||||
t_function = getTemplate("JS_functionwrapper_overload");
|
t_function = getTemplate("JS_functionwrapper_overload");
|
||||||
|
Append(wrap_name, Getattr(n, "sym:overname"));
|
||||||
}
|
}
|
||||||
Setattr(n, "wrap:name", wrap_name);
|
Setattr(n, "wrap:name", wrap_name);
|
||||||
state.function(WRAPPER_NAME, wrap_name);
|
state.function(WRAPPER_NAME, wrap_name);
|
||||||
|
|
@ -1344,16 +1367,15 @@ int JSEmitter::emitFunction(Node *n, bool is_member, bool is_static) {
|
||||||
ParmList *params = Getattr(n, "parms");
|
ParmList *params = Getattr(n, "parms");
|
||||||
emit_parameter_variables(params, wrapper);
|
emit_parameter_variables(params, wrapper);
|
||||||
emit_attach_parmmaps(params, wrapper);
|
emit_attach_parmmaps(params, wrapper);
|
||||||
Wrapper_add_local(wrapper, "jsresult", "JSValueRef jsresult");
|
|
||||||
|
|
||||||
// prepare code part
|
// prepare code part
|
||||||
String *action = emit_action(n);
|
String *action = emit_action(n);
|
||||||
marshalInputArgs(n, params, wrapper, Function, is_member, is_static);
|
marshalInputArgs(n, params, wrapper, Function, is_member, is_static);
|
||||||
marshalOutput(n, action, wrapper);
|
marshalOutput(n, action, wrapper);
|
||||||
|
|
||||||
t_function.replace("${functionname}", wrap_name)
|
t_function.replace(T_WRAPPER, wrap_name)
|
||||||
.replace("${LOCALS}", wrapper->locals)
|
.replace(T_LOCALS, wrapper->locals)
|
||||||
.replace("${CODE}", wrapper->code)
|
.replace(T_CODE, wrapper->code)
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
// handle function overloading
|
// handle function overloading
|
||||||
|
|
@ -1364,8 +1386,8 @@ int JSEmitter::emitFunction(Node *n, bool is_member, bool is_static) {
|
||||||
String *argcount = NewString("");
|
String *argcount = NewString("");
|
||||||
Printf(argcount, "%d", argc);
|
Printf(argcount, "%d", argc);
|
||||||
|
|
||||||
t_dispatch_case.replace("${functionwrapper}", wrap_name)
|
t_dispatch_case.replace(T_WRAPPER, wrap_name)
|
||||||
.replace("${argcount}", argcount);
|
.replace(T_ARGCOUNT, argcount);
|
||||||
|
|
||||||
Append(state.global(FUNCTION_DISPATCHERS), t_dispatch_case.str());
|
Append(state.global(FUNCTION_DISPATCHERS), t_dispatch_case.str());
|
||||||
|
|
||||||
|
|
@ -1386,16 +1408,16 @@ int JSEmitter::emitFunctionDispatcher(Node *n, bool /*is_member */ ) {
|
||||||
Setattr(n, "wrap:name", wrap_name);
|
Setattr(n, "wrap:name", wrap_name);
|
||||||
|
|
||||||
Wrapper_add_local(wrapper, "res", "int res");
|
Wrapper_add_local(wrapper, "res", "int res");
|
||||||
Wrapper_add_local(wrapper, "jsresult", "JSValueRef jsresult");
|
|
||||||
|
|
||||||
Append(wrapper->code, state.global(FUNCTION_DISPATCHERS));
|
Append(wrapper->code, state.global(FUNCTION_DISPATCHERS));
|
||||||
Append(wrapper->code, getTemplate("JS_function_dispatch_case_default").str());
|
Append(wrapper->code, getTemplate("JS_function_dispatch_case_default").str());
|
||||||
|
|
||||||
t_function.replace("${LOCALS}", wrapper->locals)
|
t_function.replace(T_LOCALS, wrapper->locals)
|
||||||
.replace("${CODE}", wrapper->code);
|
.replace(T_CODE, wrapper->code);
|
||||||
|
|
||||||
// call this here, to replace all variables
|
// call this here, to replace all variables
|
||||||
t_function.replace("${functionname}", wrap_name)
|
t_function.replace(T_WRAPPER, wrap_name)
|
||||||
|
.replace(T_NAME, state.function(NAME))
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
|
|
||||||
// Delete the state variable
|
// Delete the state variable
|
||||||
|
|
@ -1446,27 +1468,27 @@ int JSCEmitter::emitNamespaces() {
|
||||||
Iterator it;
|
Iterator it;
|
||||||
for (it = First(namespaces); it.item; it = Next(it)) {
|
for (it = First(namespaces); it.item; it = Next(it)) {
|
||||||
Hash *entry = it.item;
|
Hash *entry = it.item;
|
||||||
String *name = Getattr(entry, "name");
|
String *name = Getattr(entry, NAME);
|
||||||
String *parent = Getattr(entry, "parent");
|
String *name_mangled = Getattr(entry, NAME_MANGLED);
|
||||||
|
String *parent = Getattr(entry, PARENT);
|
||||||
|
String *parent_mangled = Swig_name_mangle(parent);
|
||||||
String *functions = Getattr(entry, "functions");
|
String *functions = Getattr(entry, "functions");
|
||||||
String *variables = Getattr(entry, "values");
|
String *variables = Getattr(entry, "values");
|
||||||
String *name_mangled = Getattr(entry, "name_mangled");
|
|
||||||
String *parent_mangled = Swig_name_mangle(parent);
|
|
||||||
|
|
||||||
Template namespace_definition(getTemplate("JS_globaldefn"));
|
Template namespace_definition(getTemplate("JS_globaldefn"));
|
||||||
namespace_definition.replace("${jsglobalvariables}", variables)
|
namespace_definition.replace("$jsglobalvariables", variables)
|
||||||
.replace("${jsglobalfunctions}", functions)
|
.replace("$jsglobalfunctions", functions)
|
||||||
.replace("${namespace}", name_mangled)
|
.replace(T_NAMESPACE, name_mangled)
|
||||||
.pretty_print(f_wrap_cpp);
|
.pretty_print(f_wrap_cpp);
|
||||||
|
|
||||||
Template t_createNamespace(getTemplate("JS_create_namespace"));
|
Template t_createNamespace(getTemplate("JS_create_namespace"));
|
||||||
t_createNamespace.replace("${namespace}", name_mangled);
|
t_createNamespace.replace(T_NAME_MANGLED, name_mangled);
|
||||||
Append(state.global(CREATE_NAMESPACES), t_createNamespace.str());
|
Append(state.global(CREATE_NAMESPACES), t_createNamespace.str());
|
||||||
|
|
||||||
Template t_registerNamespace(getTemplate("JS_register_namespace"));
|
Template t_registerNamespace(getTemplate("JS_register_namespace"));
|
||||||
t_registerNamespace.replace("${namespace_mangled}", name_mangled)
|
t_registerNamespace.replace(T_NAME_MANGLED, name_mangled)
|
||||||
.replace("${namespace}", name)
|
.replace(T_NAME, name)
|
||||||
.replace("${parent_namespace}", parent_mangled);
|
.replace(T_PARENT, parent_mangled);
|
||||||
Append(state.global(REGISTER_NAMESPACES), t_registerNamespace.str());
|
Append(state.global(REGISTER_NAMESPACES), t_registerNamespace.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1575,8 +1597,8 @@ private:
|
||||||
#define KW_REGISTER_CLASSES "${PART_REGISTER_CLASSES}"
|
#define KW_REGISTER_CLASSES "${PART_REGISTER_CLASSES}"
|
||||||
#define KW_REGISTER_NS "${PART_REGISTER_NS}"
|
#define KW_REGISTER_NS "${PART_REGISTER_NS}"
|
||||||
|
|
||||||
#define KW_LOCALS "${LOCALS}"
|
#define KW_LOCALS T_LOCALS
|
||||||
#define KW_CODE "${CODE}"
|
#define KW_CODE T_CODE
|
||||||
|
|
||||||
V8Emitter::V8Emitter()
|
V8Emitter::V8Emitter()
|
||||||
: JSEmitter(),
|
: JSEmitter(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue