fixes related to gboolean and int32 function results
This commit is contained in:
parent
ac537bbe84
commit
6fe9617603
2 changed files with 18 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "0.4.10"
|
version = "0.4.11"
|
||||||
author = "Stefan Salewski"
|
author = "Stefan Salewski"
|
||||||
description = "High level GObject-Introspection based GTK3 bindings"
|
description = "High level GObject-Introspection based GTK3 bindings"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# High level gobject-introspection based GTK3 bindings for the Nim programming language
|
# High level gobject-introspection based GTK3 bindings for the Nim programming language
|
||||||
# v 0.4.9 2019-FEB-10
|
# v 0.4.11 2019-FEB-16
|
||||||
# (c) S. Salewski 2018
|
# (c) S. Salewski 2018
|
||||||
|
|
||||||
# https://wiki.gnome.org/Projects/GObjectIntrospection
|
# https://wiki.gnome.org/Projects/GObjectIntrospection
|
||||||
|
|
@ -436,15 +436,20 @@ proc genP(info: GICallableInfo; genProxy = false; binfo: GIBaseInfo = nil): (str
|
||||||
if str == "cstring" and mayBeNil:
|
if str == "cstring" and mayBeNil:
|
||||||
arglist.add("safeStringToCString" & '(' & name & ')')################################################
|
arglist.add("safeStringToCString" & '(' & name & ')')################################################
|
||||||
else:
|
else:
|
||||||
arglist.add(str & '(' & name & ')')
|
if str != "string" and str != "cstring": # v0.4.11
|
||||||
|
arglist.add(str & '(' & name & ')')
|
||||||
|
else:
|
||||||
|
arglist.add(name)
|
||||||
else:
|
else:
|
||||||
arglist.add(name)
|
arglist.add(name)
|
||||||
if not genProxy and ct2nt.contains(str) and str != "cstring":
|
#if not genProxy and ct2nt.contains(str) and str != "cstring": # new in 0.4.11: for var pass Nim string, not cstring yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
||||||
|
if not genProxy and ct2nt.contains(str) and (str != "cstring" or (gArgInfoGetDirection(arg) == GIDirection.OUT or gArgInfoGetDirection(arg) == GIDirection.INOUT)):
|
||||||
replist.add($name, $str)
|
replist.add($name, $str)
|
||||||
if genProxy and ct2nt.contains(str):
|
if genProxy and ct2nt.contains(str):
|
||||||
if gArgInfoGetDirection(arg) == GIDirection.OUT or gArgInfoGetDirection(arg) == GIDirection.INOUT:
|
if gArgInfoGetDirection(arg) == GIDirection.OUT or gArgInfoGetDirection(arg) == GIDirection.INOUT:
|
||||||
replist.add($name, $str)
|
replist.add($name, $str)
|
||||||
str = ct2nt[str]
|
if gArgInfoGetDirection(arg) == GIDirection.OUT or gArgInfoGetDirection(arg) == GIDirection.INOUT or str != "cstring": # new in 0.4.11 -- allow passing cstring if not a var
|
||||||
|
str = ct2nt[str]
|
||||||
if gArgInfoGetDirection(arg) == GIDirection.OUT or gArgInfoGetDirection(arg) == GIDirection.INOUT: # caution cstringArray
|
if gArgInfoGetDirection(arg) == GIDirection.OUT or gArgInfoGetDirection(arg) == GIDirection.INOUT: # caution cstringArray
|
||||||
str.insert("var ")
|
str.insert("var ")
|
||||||
if genProxy and defaultParameters.contains(sym):
|
if genProxy and defaultParameters.contains(sym):
|
||||||
|
|
@ -452,7 +457,7 @@ proc genP(info: GICallableInfo; genProxy = false; binfo: GIBaseInfo = nil): (str
|
||||||
(h1, h2, h3) = defaultParameters[sym].split
|
(h1, h2, h3) = defaultParameters[sym].split
|
||||||
if name == h1 and str == h2:
|
if name == h1 and str == h2:
|
||||||
str.add(" = " & h3)
|
str.add(" = " & h3)
|
||||||
if genProxy and str == "string" and mayBeNil:
|
if genProxy and (str == "string" or str == "cstring") and mayBeNil: # v0.4.11
|
||||||
#str.add(" = nil")
|
#str.add(" = nil")
|
||||||
str.add(" = \"\"")
|
str.add(" = \"\"")
|
||||||
if genProxy and isProxyCandidate(t) and mayBeNil:
|
if genProxy and isProxyCandidate(t) and mayBeNil:
|
||||||
|
|
@ -544,7 +549,9 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
||||||
if sym.contains("gtk_widget_class_find_style_property") or sym.contains("gtk_container_class_find_child_property"): 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_fi$manglename(gBaseInfoGetName(info)))nd_cell_property"): return
|
#if sym.contains("gtk_cell_area_class_fi$manglename(gBaseInfoGetName(info)))nd_cell_property"): return
|
||||||
if sym.contains("gtk_cell_area_class_find_cell_property"): return
|
if sym.contains("gtk_cell_area_class_find_cell_property"): return
|
||||||
|
|
||||||
var asym = manglename(gBaseInfoGetName(mInfo))
|
var asym = manglename(gBaseInfoGetName(mInfo))
|
||||||
|
if asym == "errorQuark" or asym == "quark": return
|
||||||
|
|
||||||
#[
|
#[
|
||||||
# this does not work really well, so we do proc renaming manually using fixedProcNames seq.
|
# this does not work really well, so we do proc renaming manually using fixedProcNames seq.
|
||||||
|
|
@ -567,6 +574,9 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
||||||
#var ret22 = gCallableInfoGetReturnType(minfo)
|
#var ret22 = gCallableInfoGetReturnType(minfo)
|
||||||
for run in 0 .. 1:
|
for run in 0 .. 1:
|
||||||
if run == 1:
|
if run == 1:
|
||||||
|
|
||||||
|
#if not (asym != "errorQuark" and asym != "getPlugin" and asym != "quark"): continue
|
||||||
|
|
||||||
if fixedProcNames.contains(sym): continue
|
if fixedProcNames.contains(sym): continue
|
||||||
if not (asym.startsWith("get") or asym.startsWith("set")) or asym == "getPlugin" or asym.len < 4: continue
|
if not (asym.startsWith("get") or asym.startsWith("set")) or asym == "getPlugin" or asym.len < 4: continue
|
||||||
if asym.startsWith("get") and gTypeInfoGetTag(ret2) == GITypeTag.VOID: continue
|
if asym.startsWith("get") and gTypeInfoGetTag(ret2) == GITypeTag.VOID: continue
|
||||||
|
|
@ -583,7 +593,7 @@ proc writeMethod(info: GIBaseInfo; minfo: GIFunctionInfo; genProxy = false) =
|
||||||
asym[0] = asym[0].toLowerAscii
|
asym[0] = asym[0].toLowerAscii
|
||||||
asym = '`' & asym & '=' & '`'
|
asym = '`' & asym & '=' & '`'
|
||||||
if keywords.split.contains(asym) or nims.split.contains(asym): continue
|
if keywords.split.contains(asym) or nims.split.contains(asym): continue
|
||||||
if needProxyProc(mInfo) or isString(ret2) or replist.len > 0:
|
if needProxyProc(mInfo) or isString(ret2) or replist.len > 0 or ct2nt.contains(genRec(ret2)): # new in 0.4.11: return bool/int instead of gboolenan/int32#################################
|
||||||
var isGObject = false
|
var isGObject = false
|
||||||
let tag = gTypeInfoGetTag(ret2)
|
let tag = gTypeInfoGetTag(ret2)
|
||||||
if tag == GITypeTag.INTERFACE:
|
if tag == GITypeTag.INTERFACE:
|
||||||
|
|
@ -1574,7 +1584,7 @@ proc main(namespace: string) =
|
||||||
output.writeLine("const GTrue = gboolean(1)")
|
output.writeLine("const GTrue = gboolean(1)")
|
||||||
output.writeLine("proc cogfree*(mem: pointer) {.importc: \"g_free\", libprag.}")
|
output.writeLine("proc cogfree*(mem: pointer) {.importc: \"g_free\", libprag.}")
|
||||||
output.writeLine("proc toBool*(g: gboolean): bool = g.int != 0")
|
output.writeLine("proc toBool*(g: gboolean): bool = g.int != 0")
|
||||||
output.writeLine("proc safeStringToCString*(s: string): cstring = (if s.len == 0: nil else: cstring(s))")
|
output.writeLine("proc safeStringToCString*(s: cstring): cstring = (if s.len == 0: nil else: s)")
|
||||||
elif namespace == "Gdk":
|
elif namespace == "Gdk":
|
||||||
output.writeLine("type\n AtomArray* = pointer")
|
output.writeLine("type\n AtomArray* = pointer")
|
||||||
output.writeLine("type\n KeymapKey00Array* = pointer")
|
output.writeLine("type\n KeymapKey00Array* = pointer")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue