summaryrefslogtreecommitdiff
path: root/Source/Modules/csharp.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Modules/csharp.cxx')
-rw-r--r--Source/Modules/csharp.cxx94
1 files changed, 34 insertions, 60 deletions
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index d30bd18c5..3b1e03560 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -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;
}
@@ -912,21 +914,10 @@ public:
String *null_attribute = 0;
// Now write code to make the function call
if (!native_function_flag) {
- if (Cmp(nodeType(n), "constant") == 0) {
- // Wrapping a constant hack
- Swig_save("functionWrapper", n, "wrap:action", NIL);
-
- // below based on Swig_VargetToFunction()
- SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
- Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
- }
Swig_director_emit_dynamic_cast(n, f);
String *actioncode = emit_action(n);
- if (Cmp(nodeType(n), "constant") == 0)
- Swig_restore(n);
-
/* Return value if necessary */
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
canThrow(n, "out", n);
@@ -1088,15 +1079,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 +1255,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 +1280,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 +1304,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 +1376,7 @@ public:
Delete(scope);
}
+ Delete(newsymname);
Delete(tmpValue);
Swig_restore(n);
return SWIG_OK;
@@ -3053,6 +3050,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 +3068,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)));
}
}
}
@@ -3199,43 +3206,6 @@ public:
}
/* -----------------------------------------------------------------------------
- * makeParameterName()
- *
- * Inputs:
- * n - Node
- * p - parameter node
- * arg_num - parameter argument number
- * setter - set this flag when wrapping variables
- * Return:
- * arg - a unique parameter name
- * ----------------------------------------------------------------------------- */
-
- String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) {
-
- String *arg = 0;
- String *pn = Getattr(p, "name");
-
- // Use C parameter name unless it is a duplicate or an empty parameter name
- int count = 0;
- ParmList *plist = Getattr(n, "parms");
- while (plist) {
- if ((Cmp(pn, Getattr(plist, "name")) == 0))
- count++;
- plist = nextSibling(plist);
- }
- String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
- arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
-
- if (setter && Cmp(arg, "self") != 0) {
- // Note that in C# properties, the input variable name is always called 'value'
- Delete(arg);
- arg = NewString("value");
- }
-
- return arg;
- }
-
- /* -----------------------------------------------------------------------------
* emitTypeWrapperClass()
* ----------------------------------------------------------------------------- */
@@ -4283,6 +4253,10 @@ public:
Delete(dirclassname);
}
+ /*----------------------------------------------------------------------
+ * nestedClassesSupport()
+ *--------------------------------------------------------------------*/
+
NestedClassSupport nestedClassesSupport() const {
return NCS_Full;
}