Fix wrapping D constants using %dmanifestconst
This commit is contained in:
parent
539aca58a5
commit
6840996dba
2 changed files with 20 additions and 10 deletions
|
|
@ -41,6 +41,10 @@ struct CharTestClass {
|
||||||
|
|
||||||
#if defined(SWIGJAVA)
|
#if defined(SWIGJAVA)
|
||||||
%javaconst(1);
|
%javaconst(1);
|
||||||
|
//#elif SWIGCSHARP
|
||||||
|
//%csconst(1);
|
||||||
|
#elif SWIGD
|
||||||
|
%dmanifestconst;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
|
||||||
|
|
@ -910,7 +910,7 @@ public:
|
||||||
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
|
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
|
||||||
Setattr(n, "enumvalue", val);
|
Setattr(n, "enumvalue", val);
|
||||||
} else if (swigtype == T_CHAR) {
|
} else if (swigtype == T_CHAR) {
|
||||||
String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
|
String *val = NewStringf("'%(escape)s'", Getattr(n, "enumvalue"));
|
||||||
Setattr(n, "enumvalue", val);
|
Setattr(n, "enumvalue", val);
|
||||||
Delete(val);
|
Delete(val);
|
||||||
}
|
}
|
||||||
|
|
@ -1423,6 +1423,7 @@ public:
|
||||||
|
|
||||||
String *constants_code = NewString("");
|
String *constants_code = NewString("");
|
||||||
SwigType *t = Getattr(n, "type");
|
SwigType *t = Getattr(n, "type");
|
||||||
|
SwigType *valuetype = Getattr(n, "valuetype");
|
||||||
ParmList *l = Getattr(n, "parms");
|
ParmList *l = Getattr(n, "parms");
|
||||||
|
|
||||||
// Attach the non-standard typemaps to the parameter list.
|
// Attach the non-standard typemaps to the parameter list.
|
||||||
|
|
@ -1470,16 +1471,21 @@ public:
|
||||||
Printf(constants_code, "%s;\n", override_value);
|
Printf(constants_code, "%s;\n", override_value);
|
||||||
} else {
|
} else {
|
||||||
// Just take the value from the C definition and hope it compiles in D.
|
// Just take the value from the C definition and hope it compiles in D.
|
||||||
String* value = Getattr(n, "wrappedasconstant") ?
|
if (Getattr(n, "wrappedasconstant")) {
|
||||||
Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value");
|
if (SwigType_type(valuetype) == T_CHAR)
|
||||||
|
Printf(constants_code, "\'%(escape)s\';\n", Getattr(n, "staticmembervariableHandler:value"));
|
||||||
// Add the stripped quotes back in.
|
else
|
||||||
if (SwigType_type(t) == T_STRING) {
|
Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value"));
|
||||||
Printf(constants_code, "\"%s\";\n", value);
|
|
||||||
} else if (SwigType_type(t) == T_CHAR) {
|
|
||||||
Printf(constants_code, "\'%s\';\n", value);
|
|
||||||
} else {
|
} else {
|
||||||
Printf(constants_code, "%s;\n", value);
|
// Add the stripped quotes back in.
|
||||||
|
String* value = Getattr(n, "value");
|
||||||
|
if (SwigType_type(t) == T_STRING) {
|
||||||
|
Printf(constants_code, "\"%s\";\n", value);
|
||||||
|
} else if (SwigType_type(t) == T_CHAR) {
|
||||||
|
Printf(constants_code, "\'%s\';\n", value);
|
||||||
|
} else {
|
||||||
|
Printf(constants_code, "%s;\n", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue