From 67618a61199feab2ccffded0a2d55d6389352c2e Mon Sep 17 00:00:00 2001 From: Stefan Salewski Date: Sun, 23 Feb 2020 19:54:58 +0100 Subject: [PATCH] fix to make it compile for v1.0.x again --- README.adoc | 2 +- gintro.nimble | 2 +- gintro/cairoimpl.nim | 9 +++++---- tests/gen.nim | 26 ++++++++++++++++---------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/README.adoc b/README.adoc index 3bfaa41..fe550af 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,6 @@ = High level GTK3 (and GTK4) bindings for the Nim programming language (c) Stefan Salewski -//Version 0.7.1 +//Version 0.7.2 :experimental: :imagesdir: http://ssalewski.de/tmp :source-highlighter: pygments diff --git a/gintro.nimble b/gintro.nimble index 3ccc07b..0a5c2cd 100644 --- a/gintro.nimble +++ b/gintro.nimble @@ -1,6 +1,6 @@ # Package -version = "0.7.1" +version = "0.7.2" author = "Stefan Salewski" description = "High level GObject-Introspection based GTK3/GTK4 bindings" license = "MIT" diff --git a/gintro/cairoimpl.nim b/gintro/cairoimpl.nim index 6fcb716..00f2c0c 100644 --- a/gintro/cairoimpl.nim +++ b/gintro/cairoimpl.nim @@ -1,7 +1,7 @@ # This is the high level cairo module for Nim -- based on the low level ngtk3 module, manually tuned. # (c) S. Salewski 2017, cairo 1.15.6 -# v0.7.1 -# 01-FEB-2020 +# v0.7.2 +# 23-FEB-2020 # starting with gintro v.0.6.0 we split cairo into the gobject-introspection generated cairo.nim and this file. @@ -138,7 +138,8 @@ var NUDK: ptr UserDataKey = cast[ptr UserDataKey](alloc(sizeof(UserDataKey))) # copy from glib.nim template fnew(a: untyped; finalizer: untyped) = - when compileOption("gc", "arc"): + # when compileOption("gc", "arc"): + when defined(gcDestructors): new(a) else: new(a, finalizer) @@ -2640,5 +2641,5 @@ when CAIRO_HAS_TEE_SURFACE: discard cairo_tee_surface_index(surface.impl, index.cuint) return surface -# 2636 lines new( +# 2644 lines diff --git a/tests/gen.nim b/tests/gen.nim index 3047e39..cb56ff0 100644 --- a/tests/gen.nim +++ b/tests/gen.nim @@ -1,6 +1,6 @@ # High level gobject-introspection based GTK3/GTK4 bindings for the Nim programming language # nimpretty --maxLineLen:130 gen.nim -# v 0.7.1 2020-FEB-20 +# v 0.7.2 2020-FEB-23 # (c) S. Salewski 2018 # https://wiki.gnome.org/Projects/GObjectIntrospection @@ -1170,7 +1170,8 @@ template genBoxedFree = else: output.writeLine(" if not self.ignoreFinalizer:") output.writeLine(" boxedFree(", getTypeProc, "(), ", "cast[ptr " & mangleName(gBaseInfoGetName(info)) & "00](self.impl))") - output.writeLine("\nwhen compileOption(\"gc\", \"arc\"):") # the when is not really needed, currently default gc ignores destructor + #output.writeLine("\nwhen compileOption(\"gc\", \"arc\"):") # the when is not really needed, currently default gc ignores destructor + output.writeLine("\nwhen defined(gcDestructors):") output.writeLine(" proc `=destroy`*(self: var typeof(" & mangleName(gBaseInfoGetName(info)) & "()[])) =") output.writeLine(" if not self.ignoreFinalizer and self.impl != nil:") output.writeLine(" boxedFree(", getTypeProc, "(), ", "cast[ptr " & mangleName(gBaseInfoGetName(info)) & "00](self.impl))") @@ -1214,7 +1215,8 @@ template genDestroyFreeUnref = if freeMe.isNil: freeMe = gStructInfoFindMethod(info, "unref") if freeMe != nil and gCallableInfoGetNArgs(freeMe) == (if gCallableInfoIsMethod(freeMe): 0 else: 1): - methodBuffer.writeLine("\nwhen compileOption(\"gc\", \"arc\"):") + # methodBuffer.writeLine("\nwhen compileOption(\"gc\", \"arc\"):") + methodBuffer.writeLine("\nwhen defined(gcDestructors):") methodBuffer.writeLine(" proc `=destroy`*(self: var typeof(" & mangleName(gBaseInfoGetName(info)) & "()[])) =") methodBuffer.writeLine(" if not self.ignoreFinalizer and self.impl != nil:") methodBuffer.writeLine(" $1(self.impl)" % [$gFunctionInfoGetSymbol(freeMe)]) @@ -1687,7 +1689,8 @@ proc writeObj(info: GIObjectInfo) = output.writeLine(" impl*: ptr Object00") output.writeLine(" ignoreFinalizer*: bool") if gObjectInfoGetFundamental(info) == GFalse: # guess work, ignore fake GObjects like GParamSpec and such - output.writeLine("\nwhen compileOption(\"gc\", \"arc\"):") + #output.writeLine("\nwhen compileOption(\"gc\", \"arc\"):") + output.writeLine("\nwhen defined(gcDestructors):") output.writeLine(" proc `=destroy`*(self: var typeof(" & mangleName(gBaseInfoGetName(info)) & "()[])) =") output.writeLine(" if not self.ignoreFinalizer and self.impl != nil:") output.writeLine(" g_object_remove_toggle_ref(self.impl, toggleNotify, addr(self))") @@ -2089,7 +2092,7 @@ proc main(namespace: string; version: cstring = nil) = output.writeLine(""" #proc fnew*[T](a: var ref T; finalizer: proc (x: ref T)) = template fnew*(a: untyped; finalizer: untyped) = - when compileOption("gc", "arc"): + when defined(gcDestructors): new(a) else: new(a, finalizer) @@ -2516,10 +2519,13 @@ proc get$1*(builder: Builder; name: string): $1 = echo gBaseInfoGetName(el[1]) proc launch() = - when compileOption("gc", "arc"): - echo "GC is arc" - when compileOption("gc", "refc"): - echo "GC is refc" + when defined(gcDestructors): + echo "defined(gcDestructors)" + echo "maybe GC is arc" + #when compileOption("gc", "arc"): + # echo "GC is arc" + #when compileOption("gc", "refc"): + # echo "GC is refc" ISGTK3 = paramCount() == 0 # we have to launch the generator two times, as typelibs can not be unloaded! supmod3 = newStringStream() @@ -2598,4 +2604,4 @@ proc launch() = supmod4.close launch() -# 2601 lines construct benil +# 2607 lines