Merge branch 'master' into devel

Conflicts:
	.travis.yml
	Examples/test-suite/common.mk
This commit is contained in:
Oliver Buchtala 2014-03-30 23:07:56 +02:00
commit 158c8b6732
114 changed files with 2861 additions and 1708 deletions

View file

@ -421,7 +421,7 @@ class Allocate:public Dispatcher {
while (cc) {
Node *cp = cc;
if (classname) {
Setattr(cp, "classname", classname);
Setattr(cp, "extendsmartclassname", classname);
}
Setattr(cp, "allocate:smartpointeraccess", "1");
/* If constant, we have to be careful */
@ -827,7 +827,7 @@ Allocate():
}
List *methods = smart_pointer_methods(sc, 0, isconst);
Setattr(inclass, "allocate:smartpointer", methods);
Setattr(inclass, "allocate:smartpointerbase", base);
Setattr(inclass, "allocate:smartpointerpointeeclassname", Getattr(sc, "name"));
} else {
/* Hmmm. The return value is not a pointer. If the type is a value
or reference. We're going to chase it to see if another operator->()

View file

@ -203,26 +203,6 @@ public:
return proxyname;
}
/* -----------------------------------------------------------------------------
* directorClassName()
* ----------------------------------------------------------------------------- */
String *directorClassName(Node *n) {
String *dirclassname;
const char *attrib = "director:classname";
if (!(dirclassname = Getattr(n, attrib))) {
String *classname = getClassPrefix();
dirclassname = NewStringf("SwigDirector_%s", classname);
Setattr(n, attrib, dirclassname);
}
else
dirclassname = Copy(dirclassname);
return dirclassname;
}
/* ------------------------------------------------------------
* main()
* ------------------------------------------------------------ */
@ -1898,6 +1878,7 @@ public:
String *old_proxy_class_constants_code = proxy_class_constants_code;
String *old_proxy_class_def = proxy_class_def;
String *old_proxy_class_code = proxy_class_code;
bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested");
if (proxy_flag) {
proxy_class_name = NewString(Getattr(n, "sym:name"));
@ -1938,8 +1919,8 @@ public:
}
}
// inner class doesn't need this prologue
if (!Getattr(n, "nested:outer")) {
// Each outer proxy class goes into a separate file
if (!has_outerclass) {
String *output_directory = outputDirectory(nspace);
String *filen = NewStringf("%s%s.cs", output_directory, proxy_class_name);
f_proxy = NewFile(filen, "w", SWIG_output_files());
@ -1991,7 +1972,6 @@ public:
Replaceall(proxy_class_def, "$dllimport", dllimport);
Replaceall(proxy_class_code, "$dllimport", dllimport);
Replaceall(proxy_class_constants_code, "$dllimport", dllimport);
bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested");
if (!has_outerclass)
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
else {
@ -3185,25 +3165,37 @@ public:
* ----------------------------------------------------------------------------- */
void substituteClassnameSpecialVariable(SwigType *classnametype, String *tm, const char *classnamespecialvariable) {
String *replacementname;
if (SwigType_isenum(classnametype)) {
String *enumname = getEnumName(classnametype);
if (enumname)
Replaceall(tm, classnamespecialvariable, enumname);
else
Replaceall(tm, classnamespecialvariable, NewStringf("int"));
if (enumname) {
replacementname = Copy(enumname);
} else {
bool anonymous_enum = (Cmp(classnametype, "enum ") == 0);
if (anonymous_enum) {
replacementname = NewString("int");
} else {
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition)
replacementname = SwigType_base(classnametype);
Replace(replacementname, "enum ", "", DOH_REPLACE_ANY);
Setattr(swig_types_hash, replacementname, classnametype);
}
}
} else {
String *classname = getProxyName(classnametype);
String *classname = getProxyName(classnametype); // getProxyName() works for pointers to classes too
if (classname) {
Replaceall(tm, classnamespecialvariable, classname); // getProxyName() works for pointers to classes too
} else { // use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved.
String *descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype));
Replaceall(tm, classnamespecialvariable, descriptor);
replacementname = Copy(classname);
} else {
// use $descriptor if SWIG does not know anything about this type. Note that any typedefs are resolved.
replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype));
// Add to hash table so that the type wrapper classes can be created later
Setattr(swig_types_hash, descriptor, classnametype);
Delete(descriptor);
Setattr(swig_types_hash, replacementname, classnametype);
}
}
Replaceall(tm, classnamespecialvariable, replacementname);
Delete(replacementname);
}
/* -----------------------------------------------------------------------------
@ -3293,6 +3285,9 @@ public:
Replaceall(swigtype, "$imclassname", imclass_name);
Replaceall(swigtype, "$dllimport", dllimport);
// For unknown enums
Replaceall(swigtype, "$enumvalues", "");
Printv(f_swigtype, swigtype, NIL);
addCloseNamespace(0, f_swigtype);

View file

@ -568,8 +568,7 @@ public:
writeTypeWrapperClass(swig_type.key, swig_type.item);
}
// Add the proxy functions (and classes, if they are not written to a
// seperate file).
// Add the proxy functions (and classes, if they are not written to a separate file).
replaceModuleVariables(proxy_dmodule_code);
Printv(proxy_d_file, proxy_dmodule_code, NIL);
@ -1399,7 +1398,7 @@ public:
// generates a getter function (which is the same as a read only property
// in D) which retrieves the value via by calling the C wrapper.
// Note that this is only called for global constants, static member
// constants are already handeled in staticmemberfunctionHandler().
// constants are already handled in staticmemberfunctionHandler().
Swig_save("constantWrapper", n, "value", NIL);
Swig_save("constantWrapper", n, "tmap:ctype:out", "tmap:imtype:out", "tmap:dtype:out", "tmap:out:null", "tmap:imtype:outattributes", "tmap:dtype:outattributes", NIL);
@ -3602,7 +3601,7 @@ private:
* package if one is set.
*
* This is only used for dependencies created in generated code, user-
* (i.e. typemap-) specified import statements are handeled seperately.
* (i.e. typemap-) specified import statements are handled separately.
* --------------------------------------------------------------------------- */
void requireDType(const String *nspace, const String *symname) {
String *dmodule = createModuleName(nspace, symname);
@ -4054,10 +4053,10 @@ private:
// TODO: Fix const-correctness of methods called in here and make type const.
// We make use of the fact that this function is called at least once for
// every type encountered which is written to a seperate file, which allows
// every type encountered which is written to a separate file, which allows
// us to handle imports here.
// When working in split proxy module mode, each generated proxy class/enum
// is written to a seperate module. This requires us to add a corresponding
// is written to a separate module. This requires us to add a corresponding
// import when a type is used in another generated module. If we are not
// working in split proxy module mode, this is not relevant and the
// generated module name is discarded.
@ -4066,35 +4065,39 @@ private:
if (SwigType_isenum(type)) {
// RESEARCH: Make sure that we really cannot get here for anonymous enums.
Node *n = enumLookup(type);
String *enum_name = Getattr(n, "sym:name");
if (n) {
String *enum_name = Getattr(n, "sym:name");
Node *p = parentNode(n);
if (p && !Strcmp(nodeType(p), "class")) {
// This is a nested enum.
String *parent_name = Getattr(p, "sym:name");
String *nspace = Getattr(p, "sym:nspace");
Node *p = parentNode(n);
if (p && !Strcmp(nodeType(p), "class")) {
// This is a nested enum.
String *parent_name = Getattr(p, "sym:name");
String *nspace = Getattr(p, "sym:nspace");
// An enum nested in a class is not written to a seperate module (this
// would not even be possible in D), so just import the parent.
requireDType(nspace, parent_name);
// An enum nested in a class is not written to a separate module (this
// would not even be possible in D), so just import the parent.
requireDType(nspace, parent_name);
String *module = createModuleName(nspace, parent_name);
if (inProxyModule(module)) {
type_name = NewStringf("%s.%s", parent_name, enum_name);
String *module = createModuleName(nspace, parent_name);
if (inProxyModule(module)) {
type_name = NewStringf("%s.%s", parent_name, enum_name);
} else {
type_name = NewStringf("%s%s.%s.%s", package, module, parent_name, enum_name);
}
} else {
type_name = NewStringf("%s%s.%s.%s", package, module, parent_name, enum_name);
// A non-nested enum is written to a separate module, import it.
String *nspace = Getattr(n, "sym:nspace");
requireDType(nspace, enum_name);
String *module = createModuleName(nspace, enum_name);
if (inProxyModule(module)) {
type_name = Copy(enum_name);
} else {
type_name = NewStringf("%s%s.%s", package, module, enum_name);
}
}
} else {
// A non-nested enum is written to a seperate module, import it.
String *nspace = Getattr(n, "sym:nspace");
requireDType(nspace, enum_name);
String *module = createModuleName(nspace, enum_name);
if (inProxyModule(module)) {
type_name = Copy(enum_name);
} else {
type_name = NewStringf("%s%s.%s", package, module, enum_name);
}
type_name = NewStringf("int");
}
} else {
Node *n = classLookup(type);

View file

@ -79,6 +79,9 @@ class GO:public Language {
bool making_variable_wrappers;
// True when working with a static member function.
bool is_static_member_function;
// A hash table of enum types that we have seen but which may not have
// been defined. The index is a SwigType.
Hash *undefined_enum_types;
// A hash table of types that we have seen but which may not have
// been defined. The index is a SwigType.
Hash *undefined_types;
@ -124,6 +127,7 @@ public:
class_methods(NULL),
making_variable_wrappers(false),
is_static_member_function(false),
undefined_enum_types(NULL),
undefined_types(NULL),
defined_types(NULL),
go_imports(NULL) {
@ -451,6 +455,7 @@ private:
// Set up the hash table for types not defined by SWIG.
undefined_enum_types = NewHash();
undefined_types = NewHash();
defined_types = NewHash();
go_imports = NewHash();
@ -463,6 +468,13 @@ private:
// Write out definitions for the types not defined by SWIG.
if (Len(undefined_enum_types) > 0)
Printv(f_go_wrappers, "\n", NULL);
for (Iterator p = First(undefined_enum_types); p.key; p = Next(p)) {
String *name = p.item;
Printv(f_go_wrappers, "type ", name, " int\n", NULL);
}
Printv(f_go_wrappers, "\n", NULL);
for (Iterator p = First(undefined_types); p.key; p = Next(p)) {
String *ty = goType(NULL, p.key);
@ -481,6 +493,7 @@ private:
}
Delete(ty);
}
Delete(undefined_enum_types);
Delete(undefined_types);
Delete(defined_types);
@ -4494,11 +4507,18 @@ private:
SwigType *t = SwigType_typedef_resolve_all(type);
Node *e = Language::enumLookup(t);
if (e) {
ret = goEnumName(e);
} else if (Strcmp(t, "enum ") == 0) {
ret = NewString("int");
if (SwigType_isenum(t)) {
Node *e = Language::enumLookup(t);
if (e) {
ret = goEnumName(e);
} else if (Strcmp(t, "enum ") == 0) {
ret = NewString("int");
} else {
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition)
ret = SwigType_base(t);
Replace(ret, "enum ", "", DOH_REPLACE_ANY);
Setattr(undefined_enum_types, t, ret);
}
} else if (SwigType_isfunctionpointer(type) || SwigType_isfunction(type)) {
ret = NewString("_swig_fnptr");
} else if (SwigType_ismemberpointer(type)) {
@ -4767,14 +4787,11 @@ private:
ret = NewString("_Complex double ");
} else if (is_interface) {
SwigType *t = SwigType_typedef_resolve_all(type);
SwigType_strip_qualifiers(t);
if (SwigType_ispointer(t)) {
SwigType_del_pointer(t);
SwigType_strip_qualifiers(t);
}
if (SwigType_isreference(t)) {
SwigType_del_reference(t);
SwigType_strip_qualifiers(t);
}
SwigType_add_pointer(t);
ret = SwigType_lstr(t, name);
@ -4809,8 +4826,13 @@ private:
}
}
if (Language::enumLookup(t) != NULL || Strcmp(t, "enum ") == 0) {
if (Language::enumLookup(t) != NULL) {
is_int = true;
} else {
SwigType *tstripped = SwigType_strip_qualifiers(t);
if (SwigType_isenum(tstripped))
is_int = true;
Delete(tstripped);
}
Delete(t);

View file

@ -1945,6 +1945,8 @@ public:
String *old_proxy_class_constants_code = proxy_class_constants_code;
String *old_proxy_class_def = proxy_class_def;
String *old_proxy_class_code = proxy_class_code;
bool has_outerclass = Getattr(n, "nested:outer") && !GetFlag(n, "feature:flatnested");
if (proxy_flag) {
proxy_class_name = NewString(Getattr(n, "sym:name"));
String *nspace = getNSpace();
@ -1997,7 +1999,8 @@ public:
return SWIG_ERROR;
}
if (!Getattr(n, "nested:outer")) {
// Each outer proxy class goes into a separate file
if (!has_outerclass) {
String *output_directory = outputDirectory(nspace);
String *filen = NewStringf("%s%s.java", output_directory, proxy_class_name);
f_proxy = NewFile(filen, "w", SWIG_output_files());
@ -2054,7 +2057,6 @@ public:
Replaceall(proxy_class_code, "$imclassname", full_imclass_name);
Replaceall(proxy_class_constants_code, "$imclassname", full_imclass_name);
bool has_outerclass = Getattr(n, "nested:outer") != 0 && !GetFlag(n, "feature:flatnested");
if (!has_outerclass)
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
else {
@ -3081,10 +3083,19 @@ public:
if (SwigType_isenum(classnametype)) {
String *enumname = getEnumName(classnametype, jnidescriptor);
if (enumname)
if (enumname) {
replacementname = Copy(enumname);
else
replacementname = NewString("int");
} else {
bool anonymous_enum = (Cmp(classnametype, "enum ") == 0);
if (anonymous_enum) {
replacementname = NewString("int");
} else {
// An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition)
replacementname = SwigType_base(classnametype);
Replace(replacementname, "enum ", "", DOH_REPLACE_ANY);
Setattr(swig_types_hash, replacementname, classnametype);
}
}
} else {
String *classname = getProxyName(classnametype, jnidescriptor); // getProxyName() works for pointers to classes too
if (classname) {
@ -3184,6 +3195,11 @@ public:
Replaceall(swigtype, "$javaclassname", classname);
Replaceall(swigtype, "$module", module_class_name);
Replaceall(swigtype, "$imclassname", imclass_name);
// For unknown enums
Replaceall(swigtype, "$static ", "");
Replaceall(swigtype, "$enumvalues", "");
Printv(f_swigtype, swigtype, NIL);
Delete(f_swigtype);

View file

@ -1242,8 +1242,8 @@ int Language::memberfunctionHandler(Node *n) {
String *fname = Swig_name_member(NSpace, ClassPrefix, symname);
if (Extend && SmartPointer) {
if (!Getattr(n, "classname")) {
Setattr(n, "classname", Getattr(CurrentClass, "allocate:smartpointerbase"));
if (!Getattr(n, "extendsmartclassname")) {
Setattr(n, "extendsmartclassname", Getattr(CurrentClass, "allocate:smartpointerpointeeclassname"));
}
}
// Set up the type for the cast to this class for use when wrapping const director (virtual) methods.
@ -1562,7 +1562,7 @@ int Language::membervariableHandler(Node *n) {
int Language::staticmembervariableHandler(Node *n) {
Swig_require("staticmembervariableHandler", n, "*name", "*sym:name", "*type", "?value", NIL);
String *value = Getattr(n, "value");
String *classname = !SmartPointer ? (isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName) : Getattr(CurrentClass, "allocate:smartpointerbase");
String *classname = !SmartPointer ? (isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName) : Getattr(CurrentClass, "allocate:smartpointerpointeeclassname");
if (!value || !Getattr(n, "hasconsttype")) {
String *name = Getattr(n, "name");
@ -2373,6 +2373,7 @@ int Language::classDeclaration(Node *n) {
String *oldDirectorClassName = DirectorClassName;
String *oldNSpace = NSpace;
Node *oldCurrentClass = CurrentClass;
int dir = 0;
String *kind = Getattr(n, "kind");
String *name = Getattr(n, "name");
@ -2424,7 +2425,6 @@ int Language::classDeclaration(Node *n) {
/* Call classHandler() here */
if (!ImportMode) {
int dir = 0;
if (directorsEnabled()) {
int ndir = GetFlag(n, "feature:director");
int nndir = GetFlag(n, "feature:nodirector");
@ -2481,7 +2481,9 @@ int Language::classDeclaration(Node *n) {
ClassPrefix = oldClassPrefix;
Delete(ClassName);
ClassName = oldClassName;
Delete(DirectorClassName);
if (dir) {
Delete(DirectorClassName);
}
DirectorClassName = oldDirectorClassName;
return SWIG_OK;
}
@ -2749,7 +2751,7 @@ int Language::constructorHandler(Node *n) {
Setattr(n, "handled_as_constructor", "1");
}
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend, DirectorClassName);
Setattr(n, "sym:name", mrename);
functionWrapper(n);
Delete(mrename);
@ -2771,7 +2773,7 @@ int Language::copyconstructorHandler(Node *n) {
String *director_ctor = get_director_ctor_code(n, director_ctor_code,
director_prot_ctor_code,
abstracts);
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend, DirectorClassName);
Setattr(n, "sym:name", mrename);
functionWrapper(n);
Delete(mrename);
@ -3237,6 +3239,7 @@ Node *Language::classLookup(const SwigType *s) const {
(Len(prefix) == 0) || // simple type (pass by value)
(Strcmp(prefix, "p.") == 0) || // pointer
(Strcmp(prefix, "r.") == 0) || // reference
(Strcmp(prefix, "z.") == 0) || // rvalue reference
SwigType_prefix_is_simple_1D_array(prefix); // Simple 1D array (not arrays of pointers/references)
// Also accept pointer by const reference, not non-const pointer reference
if (!acceptable_prefix && (Strcmp(prefix, "r.p.") == 0)) {

View file

@ -73,6 +73,14 @@ void display_mapping(DOH *d) {
}
}
extern "C"
{
static int compareByLen(const DOH *f, const DOH *s) {
return Len(s) - Len(f);
}
}
/* NEW LANGUAGE NOTE:***********************************************
most of the default options are handled by SWIG
you can add new ones here
@ -99,18 +107,14 @@ static int elua_ltr = 0;
static int eluac_ltr = 0;
static int elua_emulate = 0;
static int squash_bases = 0;
/* This variable defines internal(!) module API level and compatibility options.
* This variable is controled by -no-old-metatable-bindings option.
* v2_compatibility -
/* The new metatable bindings were introduced in SWIG 3.0.0.
* old_metatable_bindings in v2:
* 1. static methods will be put into the scope their respective class
* belongs to as well as into the class scope itself.
* belongs to as well as into the class scope itself. (only for classes without %nspace given)
* 2. The layout in elua mode is somewhat different
* 3. C enums defined inside struct will oblige to C Standard and
* will be defined in the scope surrounding the struct, not scope
* associated with it/
*/
static int v2_compatibility = 0;
static const int default_api_level = 2;
static int old_metatable_bindings = 1;
static int old_compatible_names = 1; // This flag can temporarily disable backward compatible names generation if old_metatable_bindings is enabled
/* NEW LANGUAGE NOTE:***********************************************
To add a new language, you need to derive your class from
@ -214,7 +218,6 @@ public:
virtual void main(int argc, char *argv[]) {
int api_level = default_api_level; // Default api level
/* Set location of SWIG library */
SWIG_library_directory("lua");
@ -234,7 +237,7 @@ public:
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-no-old-metatable-bindings") == 0) {
Swig_mark_arg(i);
api_level = 3;
old_metatable_bindings = 0;
} else if (strcmp(argv[i], "-squash-bases") == 0) {
Swig_mark_arg(i);
squash_bases = 1;
@ -250,15 +253,6 @@ public:
Swig_arg_error();
}
// Set API-compatibility options
if (api_level <= 2) // Must be compatible with SWIG 2.*
v2_compatibility = 1;
// template for further API breaks
//if(api_level <= 3)
// v3_compatibility = 1;
//if(api_level <= 4)
// v4_compatibility = 1;
// Set elua_ltr if elua_emulate is requested
if(elua_emulate)
elua_ltr = 1;
@ -1035,7 +1029,7 @@ public:
assert(s_const_tab);
Printf(s_const_tab, " %s,\n", constantRecord);
if ((eluac_ltr || elua_ltr) && v2_compatibility) {
if ((eluac_ltr || elua_ltr) && old_metatable_bindings) {
s_const_tab = Getattr(nspaceHash, "constants");
assert(s_const_tab);
Printf(s_const_tab, " %s,\n", constantRecord);
@ -1096,7 +1090,7 @@ public:
return SWIG_NOWRAP;
}
bool make_v2_compatible = v2_compatibility && getCurrentClass() != 0;
bool make_v2_compatible = old_metatable_bindings && getCurrentClass() && old_compatible_names;
if (make_v2_compatible) {
// Don't do anything for enums in C mode - they are already
@ -1166,9 +1160,19 @@ public:
virtual int enumDeclaration(Node *n) {
current[STATIC_CONST] = true;
current[ENUM_CONST] = true;
// There is some slightly specific behaviour with enums. Basically,
// their NSpace may be tracked separately. The code below tries to work around
// this issue to some degree.
// The idea is the same as in classHandler - to drop old names generation if
// enum is in class in namespace.
const int old_compatible_names_saved = old_compatible_names;
if (getNSpace() || ( Getattr(n, "sym:nspace") != 0 && Len(Getattr(n, "sym:nspace")) > 0 ) ) {
old_compatible_names = 0;
}
int result = Language::enumDeclaration(n);
current[STATIC_CONST] = false;
current[ENUM_CONST] = false;
old_compatible_names = old_compatible_names_saved;
return result;
}
@ -1279,7 +1283,7 @@ public:
// * consider effect on template_specialization_defarg
static Hash *emitted = NewHash();
if (Getattr(emitted, mangled_fr_t)) {
if (GetFlag(emitted, mangled_fr_t)) {
full_proxy_class_name = 0;
proxy_class_name = 0;
return SWIG_NOWRAP;
@ -1316,12 +1320,21 @@ public:
Setattr(instance_cls, "lua:class_instance:static_hash", static_cls);
Setattr(static_cls, "lua:class_static:instance_hash", instance_cls);
const int old_compatible_names_saved = old_compatible_names;
// If class has %nspace enabled, then generation of backward compatible names
// should be disabled
if (getNSpace()) {
old_compatible_names = 0;
}
/* There is no use for "classes" and "namespaces" arrays. Subclasses are not supported
* by SWIG and namespaces couldn't be nested inside classes (C++ Standard)
*/
// Generate normal wrappers
Language::classHandler(n);
old_compatible_names = old_compatible_names_saved;
SwigType_add_pointer(t);
// Catch all: eg. a class with only static functions and/or variables will not have 'remembered'
@ -1601,7 +1614,7 @@ public:
const int result = Language::staticmemberfunctionHandler(n);
registerMethod(n);
if (v2_compatibility && result == SWIG_OK) {
if (old_metatable_bindings && result == SWIG_OK && old_compatible_names) {
Swig_require("lua_staticmemberfunctionHandler", n, "*lua:name", NIL);
String *lua_name = Getattr(n, "lua:name");
// Although this function uses Swig_name_member, it actually generates the Lua name,
@ -1646,7 +1659,7 @@ public:
if (result == SWIG_OK) {
// This will add static member variable to the class namespace with name ClassName_VarName
if (v2_compatibility) {
if (old_metatable_bindings && old_compatible_names) {
Swig_save("lua_staticmembervariableHandler", n, "lua:name", NIL);
String *lua_name = Getattr(n, "lua:name");
// Although this function uses Swig_name_member, it actually generates the Lua name,
@ -1659,7 +1672,7 @@ public:
registerVariable(n, true, getNSpace());
}
// If static member variable was wrapped as a constant, then
// constant wrapper has already performed all actions necessary for v2_compatibility
// constant wrapper has already performed all actions necessary for old_metatable_bindings
Delete(v2_name);
Swig_restore(n);
}
@ -1895,7 +1908,7 @@ public:
Setattr(scope, "lua:cdata", carrays_hash);
assert(rawGetCArraysHash(nspace));
if (reg && nspace != 0 && Len(nspace) != 0 && Getattr(carrays_hash, "lua:no_reg") == 0) {
if (reg && nspace != 0 && Len(nspace) != 0 && GetFlag(carrays_hash, "lua:no_reg") == 0) {
// Split names into components
List *components = Split(nspace, '.', -1);
String *parent_path = NewString("");
@ -1941,7 +1954,7 @@ public:
void closeCArraysHash(String *nspace, File *output) {
Hash *carrays_hash = rawGetCArraysHash(nspace);
assert(carrays_hash);
assert(Getattr(carrays_hash, "lua:closed") == 0);
assert(GetFlag(carrays_hash, "lua:closed") == 0);
SetFlag(carrays_hash, "lua:closed");
@ -1964,7 +1977,7 @@ public:
String *methods_tab = Getattr(carrays_hash, "methods");
String *metatable_tab_name = Getattr(carrays_hash, "metatable:name");
if (elua_ltr || eluac_ltr) {
if (v2_compatibility)
if (old_metatable_bindings)
Printv(methods_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(", const_tab_name, ")},\n", NIL);
if (elua_ltr) {
Printv(methods_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(", metatable_tab_name, ")},\n", NIL);
@ -1976,13 +1989,13 @@ public:
Printf(methods_tab, " {0,0}\n};\n");
Printv(output, methods_tab, NIL);
if (!Getattr(carrays_hash, "lua:no_classes")) {
if (!GetFlag(carrays_hash, "lua:no_classes")) {
String *classes_tab = Getattr(carrays_hash, "classes");
Printf(classes_tab, " 0\n};\n");
Printv(output, classes_tab, NIL);
}
if (!Getattr(carrays_hash, "lua:no_namespaces")) {
if (!GetFlag(carrays_hash, "lua:no_namespaces")) {
String *namespaces_tab = Getattr(carrays_hash, "namespaces");
Printf(namespaces_tab, " 0\n};\n");
Printv(output, namespaces_tab, NIL);
@ -2003,7 +2016,7 @@ public:
String *get_tab_name = Getattr(carrays_hash, "get:name");
String *set_tab_name = Getattr(carrays_hash, "set:name");
if (Getattr(carrays_hash, "lua:class_instance")) {
if (GetFlag(carrays_hash, "lua:class_instance")) {
Printv(metatable_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_class_get)},\n", NIL);
Printv(metatable_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_class_set)},\n", NIL);
} else {
@ -2016,7 +2029,7 @@ public:
Printv(metatable_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(", set_tab_name, ")},\n", NIL);
Printv(metatable_tab, tab4, "{LSTRKEY(\".fn\"), LROVAL(", Getattr(carrays_hash, "methods:name"), ")},\n", NIL);
if (Getattr(carrays_hash, "lua:class_instance")) {
if (GetFlag(carrays_hash, "lua:class_instance")) {
String *static_cls = Getattr(carrays_hash, "lua:class_instance:static_hash");
assert(static_cls);
// static_cls is swig_lua_namespace. This structure can't be use with eLua(LTR)
@ -2026,7 +2039,7 @@ public:
Printv(metatable_tab, tab4, "{LSTRKEY(\".static\"), LROVAL(", static_cls_cname, ")},\n", NIL);
// Put forward declaration of this array
Printv(output, "extern ", Getattr(static_cls, "methods:decl"), "\n", NIL);
} else if (Getattr(carrays_hash, "lua:class_static")) {
} else if (GetFlag(carrays_hash, "lua:class_static")) {
Hash *instance_cls = Getattr(carrays_hash, "lua:class_static:instance_hash");
assert(instance_cls);
String *instance_cls_metatable_name = Getattr(instance_cls, "metatable:name");
@ -2045,10 +2058,6 @@ public:
Printv(output, "\n", NIL);
}
static int compareByLen(const DOH *f, const DOH *s) {
return Len(s) - Len(f);
}
/* -----------------------------------------------------------------------------
* closeNamespaces()
*
@ -2074,7 +2083,7 @@ public:
// We have a pseudo symbol. Lets get actual scope for this pseudo symbol
Hash *carrays_hash = rawGetCArraysHash(ki.key);
assert(carrays_hash);
if (Getattr(carrays_hash, "lua:closed") == 0)
if (GetFlag(carrays_hash, "lua:closed") == 0)
Append(to_close, ki.key);
}
ki = Next(ki);
@ -2119,8 +2128,8 @@ public:
String *const_tab_name = Getattr(carrays_hash, "constants:name");
String *classes_tab_name = Getattr(carrays_hash, "classes:name");
String *namespaces_tab_name = Getattr(carrays_hash, "namespaces:name");
bool has_classes = Getattr(carrays_hash, "lua:no_classes") == 0;
bool has_namespaces = Getattr(carrays_hash, "lua:no_namespaces") == 0;
bool has_classes = GetFlag(carrays_hash, "lua:no_classes") == 0;
bool has_namespaces = GetFlag(carrays_hash, "lua:no_namespaces") == 0;
Printv(output, "{\n",
tab4, "\"", name, "\",\n",