Merge latest master into doxygen branch.

This commit is contained in:
Vadim Zeitlin 2014-12-15 02:54:57 +01:00
commit 9b857e6cf1
275 changed files with 6821 additions and 2094 deletions

View file

@ -627,9 +627,11 @@ public:
* ----------------------------------------------------------------------------- */
void emitBanner(File *f) {
Printf(f, "/* ----------------------------------------------------------------------------\n");
Swig_banner_target_lang(f, " *");
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
Printf(f, "//------------------------------------------------------------------------------\n");
Printf(f, "// <auto-generated />\n");
Printf(f, "//\n");
Swig_banner_target_lang(f, "//");
Printf(f, "//------------------------------------------------------------------------------\n\n");
}
/*-----------------------------------------------------------------------
@ -717,7 +719,7 @@ public:
String *overloaded_name = getOverloadedName(n);
if (!Getattr(n, "sym:overloaded")) {
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
if (!addSymbol(symname, n, imclass_name))
return SWIG_ERROR;
}
@ -1088,15 +1090,13 @@ public:
return ret;
}
String *getCurrentScopeName(String *nspace)
{
String *getCurrentScopeName(String *nspace) {
String *scope = 0;
if (nspace || getCurrentClass()) {
scope = NewString("");
if (nspace)
Printf(scope, "%s", nspace);
if (Node* cls = getCurrentClass())
{
if (Node* cls = getCurrentClass()) {
if (Node *outer = Getattr(cls, "nested:outer")) {
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
@ -1266,6 +1266,7 @@ public:
int unnamedinstance = GetFlag(parent, "unnamedinstance");
String *parent_name = Getattr(parent, "name");
String *nspace = getNSpace();
String *newsymname = 0;
String *tmpValue;
// Strange hack from parent method
@ -1290,14 +1291,20 @@ public:
{
EnumFeature enum_feature = decodeEnumFeature(parent);
if ((enum_feature == SimpleEnum) && GetFlag(parent, "scopedenum")) {
newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
symname = newsymname;
}
// Add to language symbol table
String *scope = 0;
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
if (proxy_class_name) {
String *enumClassPrefix = getEnumClassPrefix();
if (enumClassPrefix) {
scope = NewString("");
if (nspace)
Printf(scope, "%s.", nspace);
Printf(scope, "%s", proxy_class_name);
Printf(scope, "%s", enumClassPrefix);
} else {
scope = Copy(module_class_name);
}
@ -1308,7 +1315,7 @@ public:
else
Printf(scope, ".%s", Getattr(parent, "sym:name"));
}
if (!addSymbol(name, n, scope))
if (!addSymbol(symname, n, scope))
return SWIG_ERROR;
const String *csattributes = Getattr(n, "feature:cs:attributes");
@ -1380,6 +1387,7 @@ public:
Delete(scope);
}
Delete(newsymname);
Delete(tmpValue);
Swig_restore(n);
return SWIG_OK;
@ -3053,6 +3061,16 @@ public:
// Use the C syntax to make a true C# constant and hope that it compiles as C# code
value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex"));
} else {
String *newsymname = 0;
if (!getCurrentClass() || !proxy_flag) {
String *enumClassPrefix = getEnumClassPrefix();
if (enumClassPrefix) {
// A global scoped enum
newsymname = Swig_name_member(0, enumClassPrefix, symname);
symname = newsymname;
}
}
// Get the enumvalue from a PINVOKE call
if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) {
// Strange hack to change the name
@ -3061,7 +3079,7 @@ public:
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
} else {
memberconstantHandler(n);
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, getEnumClassPrefix(), symname)));
}
}
}
@ -4246,6 +4264,10 @@ public:
Delete(dirclassname);
}
/*----------------------------------------------------------------------
* nestedClassesSupport()
*--------------------------------------------------------------------*/
NestedClassSupport nestedClassesSupport() const {
return NCS_Full;
}

View file

@ -803,24 +803,24 @@ public:
// Emit each enum item.
Language::enumDeclaration(n);
if (!GetFlag(n, "nonempty")) {
// Do not wrap empty enums; the resulting D code would be illegal.
Delete(proxy_enum_code);
return SWIG_NOWRAP;
}
// Finish the enum.
if (typemap_lookup_type) {
Printv(proxy_enum_code,
lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code
"\n}\n", NIL);
if (GetFlag(n, "nonempty")) {
// Finish the enum.
if (typemap_lookup_type) {
Printv(proxy_enum_code,
lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code
"\n}\n", NIL);
} else {
// Handle anonymous enums.
Printv(proxy_enum_code, "\n}\n", NIL);
}
Replaceall(proxy_enum_code, "$dclassname", symname);
} else {
// Handle anonymous enums.
Printv(proxy_enum_code, "\n}\n", NIL);
// D enum declarations must have at least one member to be legal, so emit
// an alias to int instead (their ctype/imtype is always int).
Delete(proxy_enum_code);
proxy_enum_code = NewStringf("\nalias int %s;\n", symname);
}
Replaceall(proxy_enum_code, "$dclassname", symname);
const String* imports =
lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE);
String* imports_trimmed;
@ -2594,7 +2594,7 @@ private:
const_String_or_char_ptr wrapper_function_name) {
// TODO: Add support for static linking here.
Printf(im_dmodule_code, "extern(C) %s function%s %s;\n", return_type,
Printf(im_dmodule_code, "SwigExternC!(%s function%s) %s;\n", return_type,
parameters, d_name);
Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL);
Replaceall(wrapper_loader_bind_code, "$function", d_name);
@ -2850,7 +2850,7 @@ private:
// polymorphic call or an explicit method call. Needed to prevent infinite
// recursion when calling director methods.
Node *explicit_n = Getattr(n, "explicitcallnode");
if (explicit_n) {
if (explicit_n && Swig_directorclass(getCurrentClass())) {
String *ex_overloaded_name = getOverloadedName(explicit_n);
String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name);

File diff suppressed because it is too large Load diff

View file

@ -1350,7 +1350,7 @@ public:
Printv(f_header, tm, "\n", NIL);
} else {
// Create variable and assign it a value
Printf(f_header, "static %s = %s;\n", SwigType_str(type, var_name), rvalue);
Printf(f_header, "static %s = (%s)(%s);\n", SwigType_str(type, var_name), SwigType_str(type, 0), rvalue);
}
{
/* Hack alert: will cleanup later -- Dave */

View file

@ -220,7 +220,7 @@ public:
String *symname = Copy(Getattr(n, "sym:name"));
if (symname && !GetFlag(n, "feature:flatnested")) {
for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) {
Push(symname, ".");
Push(symname, jnidescriptor ? "$" : ".");
Push(symname, Getattr(outer_class, "sym:name"));
}
}
@ -877,7 +877,7 @@ public:
bool is_destructor = (Cmp(Getattr(n, "nodeType"), "destructor") == 0);
if (!Getattr(n, "sym:overloaded")) {
if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
if (!addSymbol(symname, n, imclass_name))
return SWIG_ERROR;
}
@ -1233,15 +1233,13 @@ public:
return ret;
}
String *getCurrentScopeName(String *nspace)
{
String *getCurrentScopeName(String *nspace) {
String *scope = 0;
if (nspace || getCurrentClass()) {
scope = NewString("");
if (nspace)
Printf(scope, "%s", nspace);
if (Node* cls = getCurrentClass())
{
if (Node* cls = getCurrentClass()) {
if (Node *outer = Getattr(cls, "nested:outer")) {
String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
@ -1440,6 +1438,7 @@ public:
int unnamedinstance = GetFlag(parent, "unnamedinstance");
String *parent_name = Getattr(parent, "name");
String *nspace = getNSpace();
String *newsymname = 0;
String *tmpValue;
// Strange hack from parent method
@ -1464,14 +1463,20 @@ public:
{
EnumFeature enum_feature = decodeEnumFeature(parent);
if ((enum_feature == SimpleEnum) && GetFlag(parent, "scopedenum")) {
newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
symname = newsymname;
}
// Add to language symbol table
String *scope = 0;
if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
if (proxy_class_name) {
String *enumClassPrefix = getEnumClassPrefix();
if (enumClassPrefix) {
scope = NewString("");
if (nspace)
Printf(scope, "%s.", nspace);
Printf(scope, "%s", proxy_class_name);
Printf(scope, "%s", enumClassPrefix);
} else {
scope = Copy(constants_interface_name);
}
@ -1482,7 +1487,7 @@ public:
else
Printf(scope, ".%s", Getattr(parent, "sym:name"));
}
if (!addSymbol(name, n, scope))
if (!addSymbol(symname, n, scope))
return SWIG_ERROR;
//translate and write javadoc comment if flagged
@ -1545,6 +1550,7 @@ public:
Delete(scope);
}
Delete(newsymname);
Delete(tmpValue);
Swig_restore(n);
return SWIG_OK;
@ -2391,7 +2397,7 @@ public:
Printf(imcall, "swigCPtr");
String *this_type = Copy(getClassType());
String *name = NewString("self");
String *name = NewString("jself");
String *qualifier = Getattr(n, "qualifier");
if (qualifier)
SwigType_push(this_type, qualifier);
@ -3100,6 +3106,16 @@ public:
// Use the C syntax to make a true Java constant and hope that it compiles as Java code
value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex"));
} else {
String *newsymname = 0;
if (!getCurrentClass() || !proxy_flag) {
String *enumClassPrefix = getEnumClassPrefix();
if (enumClassPrefix) {
// A global scoped enum
newsymname = Swig_name_member(0, enumClassPrefix, symname);
symname = newsymname;
}
}
// Get the enumvalue from a JNI call
if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) {
// Strange hack to change the name
@ -3108,8 +3124,9 @@ public:
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
} else {
memberconstantHandler(n);
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, getEnumClassPrefix(), symname)));
}
Delete(newsymname);
}
}
return value;
@ -3774,7 +3791,6 @@ public:
* --------------------------------------------------------------- */
int classDirectorMethod(Node *n, Node *parent, String *super) {
String *classname = Getattr(parent, "sym:name");
String *c_classname = Getattr(parent, "name");
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
@ -3808,14 +3824,7 @@ public:
String *imcall_args = NewString("");
int classmeth_off = curr_class_dmethod - first_class_dmethod;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
String *qualified_classname = Copy(classname);
String *nspace = getNSpace();
if (nspace && package)
Insert(qualified_classname, 0, NewStringf("%s.%s.", package, nspace));
else if(nspace)
Insert(qualified_classname, 0, NewStringf("%s.", nspace));
String *qualified_classname = getProxyName(getClassName());
// Kludge Alert: functionWrapper sets sym:overload properly, but it
// isn't at this point, so we have to manufacture it ourselves. At least
@ -3876,7 +3885,7 @@ public:
/* Create the intermediate class wrapper */
tm = Swig_typemap_lookup("jtype", n, "", 0);
if (tm) {
Printf(callback_def, " public static %s %s(%s self", tm, imclass_dmethod, qualified_classname);
Printf(callback_def, " public static %s %s(%s jself", tm, imclass_dmethod, qualified_classname);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(returntype, 0));
}
@ -3938,7 +3947,6 @@ public:
}
Delete(adjustedreturntypeparm);
Delete(qualified_classname);
Swig_director_parms_fixup(l);
@ -3993,7 +4001,7 @@ public:
Printf(w->code, "if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {\n");
}
/* Start the Java field descriptor for the intermediate class's upcall (insert self object) */
/* Start the Java field descriptor for the intermediate class's upcall (insert jself object) */
Parm *tp = NewParmNode(c_classname, n);
String *jdesc;
@ -4204,7 +4212,7 @@ public:
/* Emit the intermediate class's upcall to the actual class */
String *upcall = NewStringf("self.%s(%s)", symname, imcall_args);
String *upcall = NewStringf("jself.%s(%s)", symname, imcall_args);
// Handle exception classes specified in the "except" feature's "throws" attribute
addThrows(n, "feature:except", n);
@ -4579,18 +4587,15 @@ public:
* ------------------------------------------------------------ */
int classDirectorEnd(Node *n) {
String *classname = Getattr(n, "sym:name");
String *full_classname = Getattr(n, "name");
String *classname = getProxyName(full_classname, true);
String *director_classname = directorClassName(n);
String *internal_classname;
Wrapper *w = NewWrapper();
if (Len(package_path) > 0 && Len(getNSpace()) > 0)
internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname);
else if (Len(package_path) > 0)
if (Len(package_path) > 0)
internal_classname = NewStringf("%s/%s", package_path, classname);
else if (Len(getNSpace()) > 0)
internal_classname = NewStringf("%s/%s", getNSpace(), classname);
else
internal_classname = NewStringf("%s", classname);
@ -4702,6 +4707,7 @@ public:
/*----------------------------------------------------------------------
* extraDirectorProtectedCPPMethodsRequired()
*--------------------------------------------------------------------*/
bool extraDirectorProtectedCPPMethodsRequired() const {
return false;
}
@ -4727,6 +4733,10 @@ public:
Setattr(n, "director:ctor", class_ctor);
}
/*----------------------------------------------------------------------
* nestedClassesSupport()
*--------------------------------------------------------------------*/
NestedClassSupport nestedClassesSupport() const {
return NCS_Full;
}

View file

@ -57,7 +57,9 @@ extern "C" {
/* Some status variables used during parsing */
static int InClass = 0; /* Parsing C++ or not */
static String *ClassName = 0; /* This is the real name of the current class */
static String *EnumClassName = 0; /* Enum class name */
static String *ClassPrefix = 0; /* Class prefix */
static String *EnumClassPrefix = 0; /* Prefix for strongly typed enums (including ClassPrefix) */
static String *NSpace = 0; /* Namespace for the nspace feature */
static String *ClassType = 0; /* Fully qualified type name to use */
static String *DirectorClassName = 0; /* Director name of the current class */
@ -1653,10 +1655,24 @@ int Language::enumDeclaration(Node *n) {
String *oldNSpace = NSpace;
NSpace = Getattr(n, "sym:nspace");
String *oldEnumClassPrefix = EnumClassPrefix;
if (GetFlag(n, "scopedenum")) {
assert(Getattr(n, "sym:name"));
assert(Getattr(n, "name"));
EnumClassPrefix = ClassPrefix ? NewStringf("%s_", ClassPrefix) : NewString("");
Printv(EnumClassPrefix, Getattr(n, "sym:name"), NIL);
EnumClassName = Copy(Getattr(n, "name"));
}
if (!ImportMode) {
emit_children(n);
}
if (GetFlag(n, "scopedenum")) {
Delete(EnumClassName);
EnumClassName = 0;
Delete(EnumClassPrefix);
EnumClassPrefix = oldEnumClassPrefix;
}
NSpace = oldNSpace;
return SWIG_OK;
@ -1670,7 +1686,7 @@ int Language::enumvalueDeclaration(Node *n) {
if (CurrentClass && (cplus_mode != PUBLIC))
return SWIG_NOWRAP;
Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL);
Swig_require("enumvalueDeclaration", n, "*name", "*sym:name", "?value", NIL);
String *value = Getattr(n, "value");
String *name = Getattr(n, "name");
String *tmpValue;
@ -1681,6 +1697,13 @@ int Language::enumvalueDeclaration(Node *n) {
tmpValue = NewString(name);
Setattr(n, "value", tmpValue);
Node *parent = parentNode(n);
if (GetFlag(parent, "scopedenum")) {
String *symname = Swig_name_member(0, Getattr(parent, "sym:name"), Getattr(n, "sym:name"));
Setattr(n, "sym:name", symname);
Delete(symname);
}
if (!CurrentClass || !cparse_cplusplus) {
Setattr(n, "name", tmpValue); /* for wrapping of enums in a namespace when emit_action is used */
constantWrapper(n);
@ -1719,16 +1742,19 @@ int Language::memberconstantHandler(Node *n) {
Setattr(n, "feature:except", Getattr(n, "feature:exceptvar"));
}
String *enumvalue_symname = Getattr(n, "enumvalueDeclaration:sym:name"); // Only set if a strongly typed enum
String *name = Getattr(n, "name");
String *symname = Getattr(n, "sym:name");
String *value = Getattr(n, "value");
String *mrename = Swig_name_member(0, ClassPrefix, symname);
String *mrename = Swig_name_member(0, EnumClassPrefix, enumvalue_symname ? enumvalue_symname : symname);
Setattr(n, "sym:name", mrename);
String *new_name = 0;
if (Extend)
new_name = Copy(value);
else if (EnumClassName)
new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : EnumClassName, name);
else
new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName, name);
Setattr(n, "name", new_name);
@ -2046,7 +2072,7 @@ int Language::classDirectorConstructors(Node *n) {
needed, since there is a public constructor already defined.
(scottm) This code is needed here to make the director_abstract +
test generate compileable code (Example2 in director_abastract.i).
test generate compilable code (Example2 in director_abastract.i).
(mmatus) This is very strange, since swig compiled with gcc3.2.3
doesn't need it here....
@ -2372,6 +2398,7 @@ int Language::classDeclaration(Node *n) {
int oldInClass = InClass;
String *oldClassType = ClassType;
String *oldClassPrefix = ClassPrefix;
String *oldEnumClassPrefix = EnumClassPrefix;
String *oldClassName = ClassName;
String *oldDirectorClassName = DirectorClassName;
String *oldNSpace = NSpace;
@ -2413,6 +2440,7 @@ int Language::classDeclaration(Node *n) {
Push(ClassPrefix, "_");
Push(ClassPrefix, Getattr(outerClass, "sym:name"));
}
EnumClassPrefix = Copy(ClassPrefix);
if (strip) {
ClassType = Copy(name);
} else {
@ -2480,6 +2508,8 @@ int Language::classDeclaration(Node *n) {
CurrentClass = oldCurrentClass;
Delete(ClassType);
ClassType = oldClassType;
Delete(EnumClassPrefix);
EnumClassPrefix = oldEnumClassPrefix;
Delete(ClassPrefix);
ClassPrefix = oldClassPrefix;
Delete(ClassName);
@ -2667,7 +2697,8 @@ int Language::constructorDeclaration(Node *n) {
String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0;
String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name);
Delete(scope);
if (!Equal(actual_name, expected_name) && !SwigType_istemplate(expected_name)) {
if (!Equal(actual_name, expected_name) && !SwigType_istemplate(expected_name) && !SwigType_istemplate(actual_name)) {
// Checking templates is skipped but they ought to be checked... they are just somewhat more tricky to check correctly
bool illegal_name = true;
if (Extend) {
// Check for typedef names used as a constructor name in %extend. This is deprecated except for anonymous
@ -2977,6 +3008,12 @@ int Language::variableWrapper(Node *n) {
Delattr(n,"varset");
Delattr(n,"varget");
String *newsymname = 0;
if (!CurrentClass && EnumClassPrefix) {
newsymname = Swig_name_member(0, EnumClassPrefix, symname);
symname = newsymname;
}
/* If no way to set variables. We simply create functions */
int assignable = is_assignable(n);
int flags = use_naturalvar_mode(n);
@ -3034,6 +3071,7 @@ int Language::variableWrapper(Node *n) {
functionWrapper(n);
Delattr(n, "varget");
Swig_restore(n);
Delete(newsymname);
return SWIG_OK;
}
@ -3553,6 +3591,7 @@ String *Language::makeParameterName(Node *n, Parm *p, int arg_num, bool setter)
// Some languages (C#) insist on calling the input variable "value" while
// others (D, Java) could, in principle, use something different but this
// would require more work, and so we just use "value" for them too.
// For setters the parameter name sometimes includes C++ scope resolution which needs removing.
Delete(arg);
arg = NewString("value");
}
@ -3578,9 +3617,22 @@ bool Language::extraDirectorProtectedCPPMethodsRequired() const {
return true;
}
/* -----------------------------------------------------------------------------
* Language::nestedClassesSupport()
* ----------------------------------------------------------------------------- */
Language::NestedClassSupport Language::nestedClassesSupport() const {
return NCS_Unknown;
}
/* -----------------------------------------------------------------------------
* Language::kwargsSupport()
* ----------------------------------------------------------------------------- */
bool Language::kwargsSupport() const {
return false;
}
/* -----------------------------------------------------------------------------
* Language::is_wrapping_class()
* ----------------------------------------------------------------------------- */
@ -3621,6 +3673,14 @@ String *Language::getClassPrefix() const {
return ClassPrefix;
}
/* -----------------------------------------------------------------------------
* Language::getEnumClassPrefix()
* ----------------------------------------------------------------------------- */
String *Language::getEnumClassPrefix() const {
return EnumClassPrefix;
}
/* -----------------------------------------------------------------------------
* Language::getClassType()
* ----------------------------------------------------------------------------- */

View file

@ -1184,10 +1184,12 @@ public:
if (getCurrentClass() && (cplus_mode != PUBLIC))
return SWIG_NOWRAP;
Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL);
Swig_require("enumvalueDeclaration", n, "*name", "?value", "*sym:name", NIL);
String *symname = Getattr(n, "sym:name");
String *value = Getattr(n, "value");
String *name = Getattr(n, "name");
String *tmpValue;
Node *parent = parentNode(n);
if (value)
tmpValue = NewString(value);
@ -1196,6 +1198,13 @@ public:
Setattr(n, "value", tmpValue);
Setattr(n, "name", tmpValue); /* for wrapping of enums in a namespace when emit_action is used */
if (GetFlag(parent, "scopedenum")) {
symname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
Setattr(n, "sym:name", symname);
Delete(symname);
}
int result = constantWrapper(n);
Delete(tmpValue);

View file

@ -50,6 +50,7 @@ int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime
extern "C" {
extern String *ModuleName;
extern int ignore_nested_classes;
extern int kwargs_supported;
}
/* usage string split into multiple parts otherwise string is too big for some compilers */
@ -904,6 +905,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested
ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0;
kwargs_supported = l->kwargsSupport() ? 1 : 0;
// Create Library search directories
// Check for SWIG_LIB environment variable

View file

@ -1350,9 +1350,6 @@ public:
/*
* Modified polymorphism code for Ocaml language module.
* Original:
* C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose
* <mrose@stm.lbl.gov>
*
* TODO
*

View file

@ -342,11 +342,18 @@ public:
Node *options = Getattr(mod, "options");
module = Copy(Getattr(n,"name"));
String *underscore_module = Copy(module);
Replaceall(underscore_module,":","_");
if (verbose > 0) {
fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module));
}
if (directorsEnabled()) {
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", underscore_module);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", underscore_module);
if (dirprot_mode()) {
Printf(f_directors_h, "#include <map>\n");
Printf(f_directors_h, "#include <string>\n\n");
@ -379,13 +386,6 @@ public:
fprintf(stdout, "top: No package found\n");
}
}
String *underscore_module = Copy(module);
Replaceall(underscore_module,":","_");
if (verbose > 0) {
fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module));
}
/* If we're in blessed mode, change the package name to "packagec" */
if (blessed) {
@ -2178,12 +2178,12 @@ public:
SwigType_add_pointer(ptype);
String *mangle = SwigType_manglestr(ptype);
Wrapper_add_local(w, "self", "SV *self");
Printf(w->code, "self = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle);
Printf(w->code, "sv_bless(self, gv_stashpv(swig_get_class(), 0));\n");
Wrapper_add_local(w, "swigself", "SV *swigself");
Printf(w->code, "swigself = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle);
Printf(w->code, "sv_bless(swigself, gv_stashpv(swig_get_class(), 0));\n");
Delete(mangle);
Delete(ptype);
Append(pstack, "XPUSHs(self);\n");
Append(pstack, "XPUSHs(swigself);\n");
}
Parm *p;

View file

@ -2045,6 +2045,17 @@ done:
} else if (GetFlag(n, "feature:exceptionclass")) {
Append(s_phpclasses, "extends Exception ");
}
{
Node *node = NewHash();
Setattr(node, "type", Getattr(n, "name"));
Setfile(node, Getfile(n));
Setline(node, Getline(n));
String * interfaces = Swig_typemap_lookup("phpinterfaces", node, "", 0);
if (interfaces) {
Printf(s_phpclasses, "implements %s ", interfaces);
}
Delete(node);
}
Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR);
if (!baseclass) {
// Only store this in the base class (NB !baseclass means we *are*
@ -2622,12 +2633,12 @@ done:
Printf(w->code, "zval *args[%d];\n", idx);
}
Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
const char * funcname = GetChar(n, "sym:name");
Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
Append(w->code, "if (!swig_self) {\n");
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
Append(w->code, "}\n\n");
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
const char * funcname = GetChar(n, "sym:name");
Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
/* wrap complex arguments to zvals */
Printv(w->code, wrap_args, NIL);

View file

@ -898,16 +898,21 @@ public:
#else
tab4, "if (not static):\n",
#endif
tab4, tab4, "self.__dict__[name] = value\n",
tab4, tab4, "object.__setattr__(self, name, value)\n",
tab4, "else:\n",
tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n",
"\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
Printv(f_shadow,
"\n", "def _swig_getattr(self, class_type, name):\n",
"\n", "def _swig_getattr_nondynamic(self, class_type, name, static=1):\n",
tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own()\n",
tab4, "method = class_type.__swig_getmethods__.get(name, None)\n",
tab4, "if method:\n", tab8, "return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL);
tab4, "if method:\n", tab8, "return method(self)\n",
tab4, "if (not static):\n",
tab4, tab4, "return object.__getattr__(self, name)\n",
tab4, "else:\n",
tab4, tab4, "raise AttributeError(name)\n\n",
"def _swig_getattr(self, class_type, name):\n", tab4, "return _swig_getattr_nondynamic(self, class_type, name, 0)\n\n", NIL);
Printv(f_shadow,
"\n", "def _swig_repr(self):\n",
@ -1602,7 +1607,7 @@ public:
// so we only minimally rename them in Swig_name_make(), e.g. replacing "keyword"
// with "_keyword" if they have any name at all.
if (check_kwargs(n)) {
String* name = Getattr(p, "name");
String *name = Getattr(p, "name");
if (name)
return Swig_name_make(p, 0, name, 0, 0);
}
@ -1623,7 +1628,7 @@ public:
* The "lname" attribute in each parameter in plist will be contain a parameter name
* ----------------------------------------------------------------------------- */
void addMissingParameterNames(Node* n, ParmList *plist, int arg_offset) {
void addMissingParameterNames(Node *n, ParmList *plist, int arg_offset) {
Parm *p = plist;
int i = arg_offset;
while (p) {
@ -2688,7 +2693,6 @@ public:
/* Insert cleanup code */
for (p = l; p;) {
// if (!checkAttribute(p,"tmap:in:numinputs","0") && !Getattr(p,"tmap:in:parse")) {
if (!Getattr(p, "tmap:in:parse") && (tm = Getattr(p, "tmap:freearg"))) {
if (Getattr(p, "tmap:freearg:implicitconv")) {
const char *convflag = "0";
@ -3301,7 +3305,7 @@ public:
* BEGIN C++ Director Class modifications
* ------------------------------------------------------------------------- */
/* C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose <mrose@stm.lbl.gov>
/* C++/Python polymorphism demo code
*
* TODO
*
@ -4425,7 +4429,9 @@ public:
} else {
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
}
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = staticmethod(", symname, ")\n", NIL);
if (!modern)
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
Printv(f_shadow, tab4, symname, " = staticmethod(", symname, ")\n", NIL);
if (!modern) {
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", symname, "\n", NIL);
@ -4437,7 +4443,9 @@ public:
NIL);
}
if (!classic) {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
if (!modern)
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
")\n", NIL);
}
}
@ -4672,11 +4680,12 @@ public:
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
}
if (!classic) {
if (!assignable) {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
} else {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
}
if (!modern)
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL);
if (assignable)
Printv(f_shadow, ", ", module, ".", setname, NIL);
Printv(f_shadow, ")\n", NIL);
}
Delete(mname);
Delete(setname);
@ -4745,11 +4754,12 @@ public:
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
}
if (!classic && !builtin) {
if (!assignable) {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
} else {
Printv(f_shadow, tab4, modern ? "" : "if _newclass:\n", tab8, symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
}
if (!modern)
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL);
if (assignable)
Printv(f_shadow, ", ", module, ".", setname, NIL);
Printv(f_shadow, ")\n", NIL);
}
String *getter = Getattr(n, "pybuiltin:getter");
String *setter = Getattr(n, "pybuiltin:setter");
@ -4877,6 +4887,13 @@ public:
return NewString("swigpyrun.h");
}
/*----------------------------------------------------------------------
* kwargsSupport()
*--------------------------------------------------------------------*/
bool kwargsSupport() const {
return true;
}
};
/* ---------------------------------------------------------------
@ -4914,6 +4931,16 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
int idx;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
if (builtin) {
// Rename any wrapped parameters called 'self' as the generated code contains a variable with same name
Parm *p;
for (p = l; p; p = nextSibling(p)) {
String *arg = Getattr(p, "name");
if (arg && Cmp(arg, "self") == 0)
Delattr(p, "name");
}
}
if (Cmp(storage, "virtual") == 0) {
if (Cmp(value, "0") == 0) {
pure_virtual = true;

View file

@ -3426,6 +3426,14 @@ public:
String *defaultExternalRuntimeFilename() {
return NewString("swigrubyrun.h");
}
/*----------------------------------------------------------------------
* kwargsSupport()
*--------------------------------------------------------------------*/
bool kwargsSupport() const {
return true;
}
}; /* class RUBY */
/* -----------------------------------------------------------------------------

View file

@ -297,6 +297,9 @@ protected:
/* Return the current class prefix */
String *getClassPrefix() const;
/* Return the current enum class prefix */
String *getEnumClassPrefix() const;
/* Fully qualified type name to use */
String *getClassType() const;
@ -324,6 +327,9 @@ public:
*/
virtual NestedClassSupport nestedClassesSupport() const;
/* Returns true if the target language supports key word arguments (kwargs) */
virtual bool kwargsSupport() const;
protected:
/* Identifies if a protected members that are generated when the allprotected option is used.
This does not include protected virtual methods as they are turned on with the dirprot option. */