Changeset 64
- Timestamp:
- 06/04/06 03:39:51 (2 years ago)
- Files:
-
- trunk/bcd.gen/bcd/bind.d (modified) (2 diffs)
- trunk/bcd.gen/bcd/gen/bcdgen.d (modified) (18 diffs)
- trunk/bcd.gen/scripts/libglade2.sh (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bcd.gen/bcd/bind.d
r60 r64 30 30 } 31 31 void *__C_data = null; 32 bool __C_data_owned = false; 32 33 } 33 34 … … 36 37 super("BCDReflectionException: " ~ msg); 37 38 } 39 } 40 41 struct CXXDelegate { 42 void *o; 43 void *f; 38 44 } 39 45 trunk/bcd.gen/bcd/gen/bcdgen.d
r59 r64 326 326 name == "align" || 327 327 name == "body" || 328 name == "debug" || 328 329 name == "final" || 329 330 name == "function" || … … 333 334 name == "out" || 334 335 name == "override" || 336 name == "package" || 335 337 name == "scope" || 336 338 name == "version") { … … 671 673 dtail ~= "super(ignore);\n"; 672 674 dtail ~= "__C_data = x;\n"; 675 dtail ~= "__C_data_owned = false;\n"; 673 676 dtail ~= "}\n"; 674 677 … … 680 683 681 684 dtail ~= "~this() {\n"; 682 dtail ~= "if (__C_data ) _BCD_delete_" ~ mangled ~ "(__C_data);\n";685 dtail ~= "if (__C_data && __C_data_owned) _BCD_delete_" ~ mangled ~ "(__C_data);\n"; 683 686 dtail ~= "__C_data = null;\n"; 684 687 dtail ~= "}\n"; … … 692 695 dtail ~= "super(cast(ifloat) 0);\n"; 693 696 dtail ~= "__C_data = _BCD_new_" ~ mangled ~ "();\n"; 697 dtail ~= "__C_data_owned = true;\n"; 694 698 dtail ~= "}\n"; 695 699 cout ~= demangled ~ " *_BCD_new_" ~ mangled ~ "() {\n"; … … 715 719 716 720 dtail ~= "~this() {\n"; 717 dtail ~= "if (__C_data ) _BCD_delete_" ~ mangled ~ "__" ~ curReflection ~ "(__C_data);\n";721 dtail ~= "if (__C_data && __C_data_owned) _BCD_delete_" ~ mangled ~ "__" ~ curReflection ~ "(__C_data);\n"; 718 722 dtail ~= "__C_data = null;\n"; 719 723 dtail ~= "}\n"; … … 748 752 dtail ~= "super(cast(ifloat) 0);\n"; 749 753 dtail ~= "__C_data = _BCD_new_" ~ mangled ~ "__" ~ curReflection ~ "();\n"; 754 dtail ~= "__C_data_owned = true;\n"; 750 755 dtail ~= "}\n"; 751 756 cout ~= curReflection ~ " *_BCD_new_" ~ mangled ~ "__" ~ curReflection ~ "() {\n"; … … 860 865 861 866 cout ~= type.CType ~ " _BCD_get_" ~ mangled ~ "(" ~ curClass ~ " *This) {\n"; 862 cout ~= "return (" ~ type.CType ~ ")";867 cout ~= "return "; 863 868 if (type.isClass) cout ~= "&"; 864 869 cout ~= "This->" ~ name ~ ";\n"; … … 891 896 892 897 cout ~= type.CType ~ " _BCD_get_" ~ mangled ~ "() {\n"; 893 cout ~= "return (" ~ type.CType ~ ")";898 cout ~= "return "; 894 899 if (type.isClass) cout ~= "&"; 895 900 cout ~= demangled ~ ";\n"; … … 1040 1045 cout ~= type.CType ~ " _BCD_" ~ mangled ~ "(" ~ Cargs ~ ") {\n"; 1041 1046 if (type.DType != "void") { 1042 cout ~= "return (" ~ type.CType ~ ")";1047 cout ~= "return "; 1043 1048 } 1044 1049 cout ~= "(" ~ demangled ~ "(" ~ Ccall ~ "));\n"; … … 1305 1310 1306 1311 if (!reflection) 1307 parse_Function_body(node, dname, mangled, "This-> " ~ name, type,1312 parse_Function_body(node, dname, mangled, "This->operator" ~ name, type, 1308 1313 Dargs, Deargs, Cargs, Dcall, Ccall); 1309 1314 else 1310 parse_Function_reflection(node, dname, name, mangled, type,1315 parse_Function_reflection(node, dname, "operator" ~ name, mangled, type, 1311 1316 Dargs, Deargs, Cargs, Dcall, Ccall); 1312 1317 } … … 1355 1360 char[] Dargs; 1356 1361 char[] Deargs; 1357 if (!reflection) Deargs = "void *";1358 1362 char[] Cargs; 1359 if (!reflection) {1360 if (outputC) {1361 Cargs = "struct " ~ curClass ~ " *This";1362 } else {1363 Cargs = curClass ~ " *This";1364 }1365 }1366 1363 char[] Dcall; 1367 if (!reflection) Dcall = "__C_data";1368 1364 char[] Ccall; 1369 1365 … … 1373 1369 } 1374 1370 1375 parse_Arguments(node, Dargs, Deargs, Cargs, Dcall, Ccall, reflection);1371 parse_Arguments(node, Dargs, Deargs, Cargs, Dcall, Ccall, false); 1376 1372 1377 1373 if (reflection) { … … 1387 1383 dtail ~= "super(cast(ifloat) 0);\n"; 1388 1384 dtail ~= "__C_data = _BCD_new_" ~ mangled ~ "(" ~ Dcall ~ ");\n"; 1385 dtail ~= "__C_data_owned = true;\n"; 1389 1386 if (reflection) { 1390 1387 dtail ~= curReflectionInit ~ "(__C_data, cast(void *) this);\n"; … … 1611 1608 break; 1612 1609 1610 case "wchar_t": 1611 parsedCache[type] = new ParsedType("wchar_t", "wchar"); 1612 break; 1613 1613 1614 1614 case "bool": … … 1804 1804 parsedCache[type] = rpt; 1805 1805 1806 } else if (nname == "FunctionType" ) {1806 } else if (nname == "FunctionType" || nname == "MethodType") { 1807 1807 // make a typedef and an alias 1808 1808 static bool[char[]] handledFunctions; 1809 1810 char[] base = ""; 1811 if (nname == "MethodType") { 1812 base = parseType(toStringFree(xmlGetProp(curNode, "basetype"))).CType; 1813 base[base.length - 2 .. base.length] = "::"; 1814 } 1809 1815 1810 1816 if (!(type in handledFunctions)) { … … 1816 1822 bool first = true; 1817 1823 couta = "typedef " ~ pt.CType ~ 1818 " (* _BCD_func_" ~ type ~ ")(";1824 " (*" ~ base ~ "_BCD_func_" ~ type ~ ")("; 1819 1825 dheada = "alias " ~ pt.DType ~ " function("; 1820 1826 … … 1856 1862 } 1857 1863 1858 ParsedType pt = new ParsedType("_BCD_func_" ~ type, "_BCD_func_" ~ type); 1859 pt.isFunction = true; 1864 ParsedType pt; 1865 if (nname != "MethodType") { 1866 pt = new ParsedType("_BCD_func_" ~ type, "_BCD_func_" ~ type); 1867 pt.isFunction = true; 1868 } else { 1869 writefln("WARNING: method types/delegates are not yet supported"); 1870 pt = new ParsedType("_BCD_func_" ~ type, "bcd.bind.CXXDelegate"); 1871 pt.isFunction = true; 1872 } 1860 1873 1861 1874 parsedCache[type] = pt; 1862 1875 1863 1876 } else if (nname == "Enumeration") { 1864 1877 if (parseThis(curNode, true)) parse_Enumeration(curNode);
