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

This commit is contained in:
Alex Corrado 2011-08-16 00:43:43 -04:00
Родитель 961a351592
Коммит 6b01512bee
6 изменённых файлов: 30 добавлений и 18 удалений

Просмотреть файл

@ -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
$(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))

Просмотреть файл

@ -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 ();

Просмотреть файл

@ -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 Normal file
Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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 {
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) {