Browse Source

If InlinePolicy is "NotPresent," do not add those methods to the generated wrapper (unless they are virtual). Make things prettier :)

pull/1/head
Alex Corrado 14 years ago
parent
commit
6b01512bee
  1. 7
      qt/Makefile.am
  2. 3
      qt/demos/hello.cs
  3. 8
      qt/src/QSize.cs
  4. 16
      qt/src/QWidget.cs
  5. 2
      src/Mono.Cxxi/Abi/CppAbi.cs
  6. 12
      src/generator/Generator.cs

7
qt/Makefile.am

@ -8,7 +8,8 @@ HANDWRITTEN = \ @@ -8,7 +8,8 @@ HANDWRITTEN = \
QApplication.cs \
QCoreApplication.cs \
QSize.cs \
QPushButton.cs
QPushButton.cs \
QWidget.cs
all: hello.exe
@ -25,8 +26,8 @@ generated: qt-gui-filters.xml qt-gui.xml @@ -25,8 +26,8 @@ generated: qt-gui-filters.xml qt-gui.xml
$(RM) -r generated
$(MONO) --debug $(top_srcdir)/bin/Debug/generator.exe -o=generated -ns=Qt.Gui -lib=QtGui --filters=$^
#libQtGui-inline.so: qt-gui.cpp
# $(CXX) -m32 -I. -framework QtGui -framework QtCore -DQ_WS_MAC --shared -fPIC -o $@ -fkeep-inline-functions qt-gui.cpp
libQtGui-inline.so: qt-gui.cpp
$(CXX) -m32 -I. -framework QtGui -framework QtCore --shared -fPIC -o $@ -fkeep-inline-functions -fdump-class-hierarchy qt-gui.cpp
Qt.Gui-binding.dll: generated $(addprefix src/,$(HANDWRITTEN))
$(GMCS) -debug -out:$@ -target:library -unsafe -r:$(INTEROP_DLL) generated/*.cs $(addprefix src/,$(HANDWRITTEN))

3
qt/demos/hello.cs

@ -11,8 +11,7 @@ namespace QtTest { @@ -11,8 +11,7 @@ namespace QtTest {
using (QApplication app = new QApplication ()) {
using (QPushButton hello = new QPushButton ("Hello world!")) {
var sz = new QSize (100, 30);
hello.Resize (ref sz);
hello.Resize (200, 30);
hello.SetVisible (true);
QApplication.Exec ();

8
qt/src/QSize.cs

@ -7,13 +7,13 @@ namespace Qt.Gui { @@ -7,13 +7,13 @@ namespace Qt.Gui {
[StructLayout (LayoutKind.Sequential)]
public struct QSize {
public int wd;
public int ht;
public int Width;
public int Height;
public QSize (int w, int h)
{
wd = w;
ht = h;
this.Width = w;
this.Height = h;
}
}
}

16
qt/src/QWidget.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;
using Mono.Cxxi;
namespace Qt.Gui {
public partial class QWidget {
public void Resize (int width, int height)
{
var size = new QSize (width, height);
impl.resize (Native, ref size);
}
}
}

2
src/Mono.Cxxi/Abi/CppAbi.cs

@ -76,7 +76,7 @@ namespace Mono.Cxxi.Abi { @@ -76,7 +76,7 @@ namespace Mono.Cxxi.Abi {
public virtual MethodType GetMethodType (CppTypeInfo typeInfo, MethodInfo imethod)
{
if (IsInline (imethod) && typeInfo.Library.InlineMethodPolicy == InlineMethods.NotPresent)
if (IsInline (imethod) && !IsVirtual (imethod) && typeInfo.Library.InlineMethodPolicy == InlineMethods.NotPresent)
return MethodType.NotImplemented;
else if (imethod.IsDefined (typeof (ConstructorAttribute), false))
return MethodType.NativeCtor;

12
src/generator/Generator.cs

@ -190,15 +190,8 @@ public class Generator { @@ -190,15 +190,8 @@ public class Generator {
if (!klass.Node.HasValue ("members"))
continue;
List<Node> members = new List<Node> ();
foreach (string id in klass.Node ["members"].Split (' ')) {
if (id == "")
continue;
members.Add (Node.IdToNode [id]);
}
int fieldCount = 0;
foreach (Node n in members) {
foreach (Node n in klass.Node ["members"].Split (new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select (id => Node.IdToNode [id])) {
bool ctor = false;
bool dtor = false;
bool skip = false;
@ -236,6 +229,9 @@ public class Generator { @@ -236,6 +229,9 @@ public class Generator {
if (!n.CheckValue ("access", "public")) // exclude non-public methods
skip = true;
if (n.IsTrue ("inline") && InlinePolicy == InlineMethods.NotPresent)
skip = true;
string name = dtor ? "Destruct" : n.Name;
var method = new Method (n) {

Loading…
Cancel
Save