Interface name handling improvements and special variable changes

Support expansion of name attribute in: %feature("interface", name="%s")
%s expands to the proxy class name and all the usual %rename functions
can be used (regex, strip, camelcase etc) to derive the interface name
from the proxy class name.
Rename $interfacename family of special variables to $javainterfacename for Java
Rename $interfacename family of special variables to $csinterfacename for C#
This is to free up $interfacename for simple interface name expansion in forthcoming commit
This commit is contained in:
William S Fulton 2016-02-29 20:18:01 +00:00
commit c71dba5021
5 changed files with 83 additions and 66 deletions

View file

@ -1655,7 +1655,7 @@ public:
String *ret = Getattr(n, "interface:qname");
if (!ret) {
String *nspace = Getattr(n, "sym:nspace");
String *interface_name = Getattr(n, "feature:interface:name");
String *interface_name = Getattr(n, "interface:name");
if (nspace) {
if (namespce)
ret = NewStringf("%s.%s.%s", namespce, nspace, interface_name);
@ -1677,7 +1677,7 @@ public:
String *interface_name = NULL;
if (proxy_flag) {
Node *n = classLookup(t);
if (n && Getattr(n, "feature:interface:name"))
if (n && Getattr(n, "interface:name"))
interface_name = getQualifiedInterfaceName(n);
}
return interface_name;
@ -2003,7 +2003,7 @@ public:
for (Iterator base = First(baselist); base.item; base = Next(base)) {
if (GetFlag(base.item, "feature:ignore") || !Getattr(base.item, "feature:interface"))
continue; // TODO: warn about skipped non-interface bases
String *base_iname = Getattr(base.item, "feature:interface:name");
String *base_iname = Getattr(base.item, "interface:name");
if (!bases)
bases = NewStringf(" : %s", base_iname);
else {
@ -2133,8 +2133,7 @@ public:
if (Getattr(n, "feature:interface")) {
interface_class_code = NewString("");
String *interface_name = Getattr(n, "feature:interface:name");
// TODO check feature:interface:name is not missing
String *interface_name = Getattr(n, "interface:name");
String *output_directory = outputDirectory(nspace);
f_interface = getOutputFile(output_directory, interface_name);
addOpenNamespace(nspace, f_interface);
@ -3400,25 +3399,25 @@ public:
substitution_performed = true;
Delete(classnametype);
}
if (Strstr(tm, "$interfacename")) {
if (Strstr(tm, "$csinterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$interfacename");
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$csinterfacename");
substitution_performed = true;
Delete(interfacenametype);
}
if (Strstr(tm, "$*interfacename")) {
if (Strstr(tm, "$*csinterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
Delete(SwigType_pop(interfacenametype));
if (Len(interfacenametype) > 0) {
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*interfacename");
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$*csinterfacename");
substitution_performed = true;
}
Delete(interfacenametype);
}
if (Strstr(tm, "$&interfacename")) {
if (Strstr(tm, "$&csinterfacename")) {
SwigType *interfacenametype = Copy(strippedtype);
SwigType_add_pointer(interfacenametype);
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&interfacename");
substituteInterfacenameSpecialVariable(interfacenametype, tm, "$&csinterfacename");
substitution_performed = true;
Delete(interfacenametype);
}