Slightly efficiency improvements for packages/namespaces/
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11933 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ebe21075f9
commit
8d227bce62
2 changed files with 45 additions and 43 deletions
|
|
@ -181,7 +181,7 @@ public:
|
|||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (nspace) {
|
||||
if (Len(namespce) > 0)
|
||||
if (namespce)
|
||||
proxyname = NewStringf("%s.%s.%s", namespce, nspace, symname);
|
||||
else
|
||||
proxyname = NewStringf("%s.%s", nspace, symname);
|
||||
|
|
@ -239,6 +239,10 @@ public:
|
|||
if (argv[i + 1]) {
|
||||
namespce = NewString("");
|
||||
Printf(namespce, argv[i + 1]);
|
||||
if (Len(namespce) == 0) {
|
||||
Delete(namespce);
|
||||
namespce = 0;
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -378,8 +382,6 @@ public:
|
|||
dmethods_table = NewHash();
|
||||
n_dmethods = 0;
|
||||
n_directors = 0;
|
||||
if (!namespce)
|
||||
namespce = NewString("");
|
||||
if (!dllimport)
|
||||
dllimport = Copy(module_class_name);
|
||||
|
||||
|
|
@ -439,7 +441,7 @@ public:
|
|||
// Start writing out the intermediary class file
|
||||
emitBanner(f_im);
|
||||
|
||||
addOpenNamespace(namespce, 0, f_im);
|
||||
addOpenNamespace(0, f_im);
|
||||
|
||||
if (imclass_imports)
|
||||
Printf(f_im, "%s\n", imclass_imports);
|
||||
|
|
@ -463,7 +465,7 @@ public:
|
|||
|
||||
// Finish off the class
|
||||
Printf(f_im, "}\n");
|
||||
addCloseNamespace(namespce, 0, f_im);
|
||||
addCloseNamespace(0, f_im);
|
||||
|
||||
Close(f_im);
|
||||
}
|
||||
|
|
@ -483,7 +485,7 @@ public:
|
|||
// Start writing out the module class file
|
||||
emitBanner(f_module);
|
||||
|
||||
addOpenNamespace(namespce, 0, f_module);
|
||||
addOpenNamespace(0, f_module);
|
||||
|
||||
if (module_imports)
|
||||
Printf(f_module, "%s\n", module_imports);
|
||||
|
|
@ -515,7 +517,7 @@ public:
|
|||
|
||||
// Finish off the class
|
||||
Printf(f_module, "}\n");
|
||||
addCloseNamespace(namespce, 0, f_module);
|
||||
addCloseNamespace(0, f_module);
|
||||
|
||||
Close(f_module);
|
||||
}
|
||||
|
|
@ -1134,7 +1136,7 @@ public:
|
|||
if (!nspace) {
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
} else {
|
||||
if (Len(namespce) > 0) {
|
||||
if (namespce) {
|
||||
full_imclass_name = NewStringf("%s.%s", namespce, imclass_name);
|
||||
} else {
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
|
|
@ -1214,12 +1216,12 @@ public:
|
|||
// Start writing out the enum file
|
||||
emitBanner(f_enum);
|
||||
|
||||
addOpenNamespace(namespce, nspace, f_enum);
|
||||
addOpenNamespace(nspace, f_enum);
|
||||
|
||||
Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
|
||||
"\n", enum_code, "\n", NIL);
|
||||
|
||||
addCloseNamespace(namespce, nspace, f_enum);
|
||||
addCloseNamespace(nspace, f_enum);
|
||||
Close(f_enum);
|
||||
Delete(output_directory);
|
||||
}
|
||||
|
|
@ -1820,7 +1822,7 @@ public:
|
|||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
if (Len(namespce) > 0) {
|
||||
if (namespce) {
|
||||
full_proxy_class_name = NewStringf("%s.%s.%s", namespce, nspace, proxy_class_name);
|
||||
full_imclass_name = NewStringf("%s.%s", namespce, imclass_name);
|
||||
} else {
|
||||
|
|
@ -1846,7 +1848,7 @@ public:
|
|||
// Start writing out the proxy class file
|
||||
emitBanner(f_proxy);
|
||||
|
||||
addOpenNamespace(namespce, nspace, f_proxy);
|
||||
addOpenNamespace(nspace, f_proxy);
|
||||
|
||||
Clear(proxy_class_def);
|
||||
Clear(proxy_class_code);
|
||||
|
|
@ -1878,7 +1880,7 @@ public:
|
|||
Printv(f_proxy, proxy_class_constants_code, NIL);
|
||||
|
||||
Printf(f_proxy, "}\n");
|
||||
addCloseNamespace(namespce, nspace, f_proxy);
|
||||
addCloseNamespace(nspace, f_proxy);
|
||||
Close(f_proxy);
|
||||
f_proxy = NULL;
|
||||
|
||||
|
|
@ -2959,7 +2961,7 @@ public:
|
|||
// global enum or enum in a namespace
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
if (nspace) {
|
||||
if (Len(namespce) > 0)
|
||||
if (namespce)
|
||||
enumname = NewStringf("%s.%s.%s", namespce, nspace, symname);
|
||||
else
|
||||
enumname = NewStringf("%s.%s", nspace, symname);
|
||||
|
|
@ -3111,7 +3113,7 @@ public:
|
|||
// Start writing out the type wrapper class file
|
||||
emitBanner(f_swigtype);
|
||||
|
||||
addOpenNamespace(namespce, 0, f_swigtype);
|
||||
addOpenNamespace(0, f_swigtype);
|
||||
|
||||
// Pure C# baseclass and interfaces
|
||||
const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE);
|
||||
|
|
@ -3140,7 +3142,7 @@ public:
|
|||
|
||||
Printv(f_swigtype, swigtype, NIL);
|
||||
|
||||
addCloseNamespace(namespce, 0, f_swigtype);
|
||||
addCloseNamespace(0, f_swigtype);
|
||||
|
||||
Close(f_swigtype);
|
||||
Delete(swigtype);
|
||||
|
|
@ -3215,12 +3217,12 @@ public:
|
|||
* addOpenNamespace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addOpenNamespace(const String *namspace, const String *nspace, File *file) {
|
||||
if (namspace) {
|
||||
if (Len(namspace) > 0 || nspace) {
|
||||
void addOpenNamespace(const String *nspace, File *file) {
|
||||
if (namespce) {
|
||||
if (namespce || nspace) {
|
||||
Printf(file, "namespace ");
|
||||
if (Len(namspace) > 0)
|
||||
Printv(file, namspace, nspace ? "." : "", NIL);
|
||||
if (namespce)
|
||||
Printv(file, namespce, nspace ? "." : "", NIL);
|
||||
if (nspace)
|
||||
Printv(file, nspace, NIL);
|
||||
Printf(file, " {\n");
|
||||
|
|
@ -3232,9 +3234,9 @@ public:
|
|||
* addCloseNamespace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addCloseNamespace(const String *namspace, const String *nspace, File *file) {
|
||||
if (namspace)
|
||||
if (Len(namspace) > 0 || nspace)
|
||||
void addCloseNamespace(const String *nspace, File *file) {
|
||||
if (namespce)
|
||||
if (namespce || nspace)
|
||||
Printf(file, "\n}\n");
|
||||
}
|
||||
|
||||
|
|
@ -3303,8 +3305,7 @@ public:
|
|||
/*----------------------------------------------------------------------
|
||||
* emitDirectorExtraMethods()
|
||||
*
|
||||
* This is where the director connect method is
|
||||
* generated.
|
||||
* This is where the director connect method is generated.
|
||||
*--------------------------------------------------------------------*/
|
||||
void emitDirectorExtraMethods(Node *n) {
|
||||
if (!Swig_directorclass(n))
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public:
|
|||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (nspace) {
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
proxyname = NewStringf("%s.%s.%s", package, nspace, symname);
|
||||
else
|
||||
proxyname = NewStringf("%s.%s", nspace, symname);
|
||||
|
|
@ -234,6 +234,10 @@ public:
|
|||
if (argv[i + 1]) {
|
||||
package = NewString("");
|
||||
Printf(package, argv[i + 1]);
|
||||
if (Len(package) == 0) {
|
||||
Delete(package);
|
||||
package = 0;
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -390,8 +394,6 @@ public:
|
|||
dmethods_table = NewHash();
|
||||
n_dmethods = 0;
|
||||
n_directors = 0;
|
||||
if (!package)
|
||||
package = NewString("");
|
||||
jnipackage = NewString("");
|
||||
package_path = NewString("");
|
||||
|
||||
|
|
@ -420,7 +422,7 @@ public:
|
|||
|
||||
String *wrapper_name = NewString("");
|
||||
|
||||
if (Len(package)) {
|
||||
if (package) {
|
||||
String *jniname = makeValidJniName(package);
|
||||
Printv(jnipackage, jniname, NIL);
|
||||
Delete(jniname);
|
||||
|
|
@ -467,7 +469,7 @@ public:
|
|||
// Start writing out the intermediary class file
|
||||
emitBanner(f_im);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_im, "package %s;\n", package);
|
||||
|
||||
if (imclass_imports)
|
||||
|
|
@ -518,7 +520,7 @@ public:
|
|||
// Start writing out the module class file
|
||||
emitBanner(f_module);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_module, "package %s;\n", package);
|
||||
|
||||
if (module_imports)
|
||||
|
|
@ -570,7 +572,7 @@ public:
|
|||
// Start writing out the Java constants interface file
|
||||
emitBanner(f_module);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_module, "package %s;\n", package);
|
||||
|
||||
if (module_imports)
|
||||
|
|
@ -1195,7 +1197,7 @@ public:
|
|||
if (!nspace) {
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
} else {
|
||||
if (Len(package) > 0) {
|
||||
if (package) {
|
||||
full_imclass_name = NewStringf("%s.%s", package, imclass_name);
|
||||
} else {
|
||||
full_imclass_name = NewStringf("%s", imclass_name);
|
||||
|
|
@ -1277,9 +1279,9 @@ public:
|
|||
// Start writing out the enum file
|
||||
emitBanner(f_enum);
|
||||
|
||||
if (Len(package) > 0 || nspace) {
|
||||
if (package || nspace) {
|
||||
Printf(f_enum, "package ");
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printv(f_enum, package, nspace ? "." : "", NIL);
|
||||
if (nspace)
|
||||
Printv(f_enum, nspace, NIL);
|
||||
|
|
@ -1828,7 +1830,7 @@ public:
|
|||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
if (Len(package) > 0) {
|
||||
if (package) {
|
||||
full_proxy_class_name = NewStringf("%s.%s.%s", package, nspace, proxy_class_name);
|
||||
full_imclass_name = NewStringf("%s.%s", package, imclass_name);
|
||||
} else {
|
||||
|
|
@ -1856,9 +1858,9 @@ public:
|
|||
// Start writing out the proxy class file
|
||||
emitBanner(f_proxy);
|
||||
|
||||
if (Len(package) > 0 || nspace) {
|
||||
if (package || nspace) {
|
||||
Printf(f_proxy, "package ");
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printv(f_proxy, package, nspace ? "." : "", NIL);
|
||||
if (nspace)
|
||||
Printv(f_proxy, nspace, NIL);
|
||||
|
|
@ -2807,7 +2809,7 @@ public:
|
|||
// global enum or enum in a namespace
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
if (nspace) {
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
enumname = NewStringf("%s.%s.%s", package, nspace, symname);
|
||||
else
|
||||
enumname = NewStringf("%s.%s", nspace, symname);
|
||||
|
|
@ -2963,7 +2965,7 @@ public:
|
|||
// Start writing out the type wrapper class file
|
||||
emitBanner(f_swigtype);
|
||||
|
||||
if (Len(package) > 0)
|
||||
if (package)
|
||||
Printf(f_swigtype, "package %s;\n", package);
|
||||
|
||||
// Pure Java baseclass and interfaces
|
||||
|
|
@ -3274,8 +3276,7 @@ public:
|
|||
/*----------------------------------------------------------------------
|
||||
* emitDirectorExtraMethods()
|
||||
*
|
||||
* This is where the $javaclassname_director_connect is
|
||||
* generated.
|
||||
* This is where the director connect method is generated.
|
||||
*--------------------------------------------------------------------*/
|
||||
void emitDirectorExtraMethods(Node *n) {
|
||||
if (!Swig_directorclass(n))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue