Browse Source

Misc fixes. Always generate all virtual methods in iface

pull/1/head
Alexander Corrado 14 years ago
parent
commit
adfd69958f
  1. 2
      src/Mono.Cxxi/CppType.cs
  2. 22
      src/generator/Generator.cs
  3. 2
      src/qt/Makefile.am

2
src/Mono.Cxxi/CppType.cs

@ -132,7 +132,7 @@ namespace Mono.Cxxi { @@ -132,7 +132,7 @@ namespace Mono.Cxxi {
// pointer types to C++ pointers
// array types to C++ arrays
(t) => {
var cppType = CppType.ForManagedType (t.GetElementType () ?? t.GetGenericTypeDefinition ());
var cppType = CppType.ForManagedType (t.GetElementType () ?? (t.IsGenericType? t.GetGenericTypeDefinition () : t));
if (t.IsByRef) cppType.Modifiers.Add (CppModifiers.Reference);
if (t.IsPointer) cppType.Modifiers.Add (CppModifiers.Pointer);
if (t.IsArray) cppType.Modifiers.Add (CppModifiers.Array);

22
src/generator/Generator.cs

@ -199,6 +199,7 @@ public class Generator { @@ -199,6 +199,7 @@ public class Generator {
foreach (Node n in members) {
bool ctor = false;
bool dtor = false;
bool skip = false;
switch (n.Type) {
case "Field":
@ -226,11 +227,13 @@ public class Generator { @@ -226,11 +227,13 @@ public class Generator {
continue;
}
if (!n.CheckValue ("access", "public") || // exclude non-public methods
(!dtor && n.HasValue ("overrides") && klass.BaseClasses [0].Node.CheckValueList ("members", n.Attributes ["overrides"])) || // excl. virtual methods from primary base (except dtor)
(!n.IsTrue ("extern") && !n.IsTrue ("inline")))
if ((!dtor && n.HasValue ("overrides") && klass.BaseClasses [0].Node.CheckValueList ("members", n.Attributes ["overrides"])) || // excl. virtual methods from primary base (except dtor)
(!n.IsTrue ("extern") && !n.IsTrue ("inline")))
continue;
if (!n.CheckValue ("access", "public")) // exclude non-public methods
skip = true;
string name = dtor ? "Destruct" : n.Name;
var method = new Method (n) {
@ -247,17 +250,18 @@ public class Generator { @@ -247,17 +250,18 @@ public class Generator {
if (dtor || method.IsArtificial)
method.GenWrapperMethod = false;
bool skip = false;
CppType retType;
if (n.HasValue ("returns"))
retType = GetType (n.NodeForAttr ("returns"));
else
retType = CppTypes.Void;
if (retType.ElementType == CppTypes.Unknown)
if (retType.ElementType == CppTypes.Unknown) {
retType = CppTypes.Void;
skip = true;
}
if (CppTypeToManaged (retType) == null) {
//Console.WriteLine ("\t\tS: " + retType);
retType = CppTypes.Void;
skip = true;
}
@ -275,11 +279,13 @@ public class Generator { @@ -275,11 +279,13 @@ public class Generator {
CppType argtype = GetType (GetTypeNode (arg));
if (argtype.ElementType == CppTypes.Unknown) {
//Console.WriteLine ("Skipping method " + klass.Name + "::" + member.Name + " () because it has an argument with unknown type '" + TypeNodeToString (arg) + "'.");
argtype = new CppType (CppTypes.Void, CppModifiers.Pointer);
skip = true;
}
if (CppTypeToManaged (argtype) == null) {
//Console.WriteLine ("\t\tS: " + argtype);
argtype = new CppType (CppTypes.Void, CppModifiers.Pointer);
skip = true;
}
@ -288,8 +294,10 @@ public class Generator { @@ -288,8 +294,10 @@ public class Generator {
c++;
}
if (skip)
if (skip && !method.IsVirtual)
continue;
else if (skip && method.IsVirtual)
method.GenWrapperMethod = false;
// FIXME: More complete type name check
if (ctor && argTypes.Count == 1 && argTypes [0].ElementType == CppTypes.Class && argTypes [0].ElementTypeName == klass.Name && argTypes [0].Modifiers.Count == 2 && argTypes [0].Modifiers.Contains (CppModifiers.Const) && argTypes [0].Modifiers.Contains (CppModifiers.Reference))

2
src/qt/Makefile.am

@ -16,7 +16,7 @@ generated: qt-gui.xml @@ -16,7 +16,7 @@ generated: qt-gui.xml
# $(CXX) `pkg-config --cflags QtCore QtGui` --shared -fPIC -o $@ -fkeep-inline-functions qt-gui.cpp `pkg-config --libs QtCore QtGui`
Qt.Gui-binding.dll: generated QString.cs
rm generated/QString.cs
$(RM) -f generated/QString.cs
$(GMCS) -out:$@ -target:library -unsafe -r:$(INTEROP_DLL) generated/*.cs QString.cs
hello.exe: Qt.Gui-binding.dll hello.cs #libQtGui-inline.so

Loading…
Cancel
Save