fix to make it compile for v1.0.x again

This commit is contained in:
Stefan Salewski 2020-02-23 19:54:58 +01:00
commit 67618a6119
4 changed files with 23 additions and 16 deletions

View file

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

View file

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

View file

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

View file

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