From 2baabcdf382e0f7759bf8b012c909dd118fbbf01 Mon Sep 17 00:00:00 2001 From: Stefan Salewski Date: Sun, 11 Mar 2018 15:22:02 +0100 Subject: [PATCH] added libvte --- README.adoc | 4 ++-- tests/gen.nim | 59 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/README.adoc b/README.adoc index 0c5532e..48b8b1b 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,6 @@ = High level GTK3 bindings for the Nim programming language (c) Stefan Salewski -//Version 0.3 2018 +//Version 0.4 2018 :experimental: :imagesdir: http://ssalewski.de/tmp :source-highlighter: pygments @@ -116,7 +116,7 @@ But maybe more is missing, we have to investigate that. Until now these bindings These basic libraries are already partly tested: -Gtk, Gdk, GLib, GObject, Gio, GdkPixbuf, GtkSource, Pango, PangoCairo, PangoFT2, GModule, Rsvg, fontconfig, freetype2, xlib, Atk and *cairo* +Gtk, Gdk, GLib, GObject, Gio, GdkPixbuf, GtkSource, Pango, PangoCairo, PangoFT2, GModule, Rsvg, fontconfig, freetype2, xlib, Atk, Vte, cairo In best case it should be possible to add more GObject based libraries to this list without larger modifications of the generator source code. Unfortunately the bindings for the _cairo_ drawing library provided by {GIR} was only a minimal stub -- we have extend it manually. diff --git a/tests/gen.nim b/tests/gen.nim index 96cb085..c2cd72e 100644 --- a/tests/gen.nim +++ b/tests/gen.nim @@ -1,6 +1,6 @@ # High level gobject-introspection based GTK3 bindings for the Nim programming language -# v 0.2 2017-NOV-20 -# (c) S. Salewski 2017 +# v 0.4 2018-MAR-10 +# (c) S. Salewski 2018 # https://wiki.gnome.org/Projects/GObjectIntrospection # https://developer.gnome.org/gi/1.50/index.html @@ -253,7 +253,7 @@ proc genRec(t: GITypeInfo; genProxy = false; fullQualified: bool = false): strin let tag = gTypeInfoGetTag(t) if tag == GITypeTag.ARRAY: let toa = gTypeInfoGetArrayType(t) # type of array - if toa == GIArrayType.ARRAY: result = "Array" + if toa == GIArrayType.ARRAY: result = "GArray00" elif toa == GIArrayType.PTR_ARRAY: result = "PtrArray" elif toa == GIArrayType.BYTE_ARRAY: result = "ByteArray00" elif toa == GIArrayType.C: @@ -293,6 +293,12 @@ proc genRec(t: GITypeInfo; genProxy = false; fullQualified: bool = false): strin proc isProxyCandidate(t: GITypeInfo): bool = let tag = gTypeInfoGetTag(t) + + #let tag = gTypeInfoGetTag(t) + #if tag == GITypeTag.ARRAY: + # let toa = gTypeInfoGetArrayType(t) # type of array + # if toa == GIArrayType.ARRAY: return true#result = "Array00" + if tag == GITypeTag.INTERFACE: let iface = gTypeInfoGetInterface(t) var ns = ($gBaseInfoGetNamespace(iface)).toLowerAscii @@ -503,6 +509,10 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) = methodBuffer.write("\nproc " & sym & EM & plist) methodBuffer.writeLine(" {.\n importc: \"", sym, "\", ", libprag, ".}") processedFunctions.incl(sym) + if sym.contains("vte_regex_unref"): # this function is special, as it returns the object + methodBuffer.writeLine("\nproc unref*(self: Regex) =") + methodBuffer.writeLine(" discard vte_regex_unref(cast[ptr Regex00](self.impl))") + return if sym.contains("g_param_spec_") or sym.contains("g_type_interface_") or sym.contains("g_object_interface_"): return # or sym.contains("g_value_"): return if sym.contains("gtk_widget_class_find_style_property") or sym.contains("gtk_container_class_find_child_property"): return if sym.contains("gtk_cell_area_class_find_cell_property"): return @@ -554,7 +564,6 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) = hhh = hhh.replace("new", "init") hhh = hhh.replace("*(", "*[T](result: var T" & semi) methodBuffer.writeLine(hhh & " =") - if true:#needProxyProc(mInfo): for j in 0.cint ..< gCallableInfoGetNArgs(minfo): let arg = gCallableInfoGetArg(minfo, j) @@ -563,7 +572,6 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) = assert(false) let h2 = mangleName(gBaseInfoGetName(arg)) methodBuffer.writeLine(" if " & h2 & ".isNil: " & h2 & " = new type(" & h2 & ")") - if gCallableInfoCanThrowGerror(minfo): methodBuffer.writeLine(" var gerror: ptr Error00") if i == 0: arglist.insert(", addr gerror", arglist.high) @@ -622,7 +630,7 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) = elif gCallableInfoGetCallerOwns(minfo) == GITransfer.EVERYTHING: if sym == "g_closure_new_simple": let nMethods = gStructInfoGetNMethods(info) - for j in 0 .. 0: signalbuffer.writeLine("") - for j in 0 .. 0: @@ -1173,7 +1182,7 @@ proc writeObj(info: GIObjectInfo) = let numsig = info.gObjectInfoGetNSignals if numsig > 0: signalbuffer.writeLine("") - for j in 0 ..