added cairo_anim.nim example
This commit is contained in:
parent
765ecaf9cc
commit
b0c8857651
5 changed files with 1567 additions and 26 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# High level gobject-introspection based GTK3 bindings for the Nim programming language
|
||||
# v 0.2 2017-AUG-29
|
||||
# v 0.2 2017-SEP-08
|
||||
# (c) S. Salewski 2017
|
||||
|
||||
# https://wiki.gnome.org/Projects/GObjectIntrospection
|
||||
|
|
@ -108,7 +108,6 @@ var fixedProcNames = newTable[string, string]()
|
|||
var mangledNames = newTable[string, string]()
|
||||
var gdkKeys = newTable[string, seq[string]]()
|
||||
var allSyms: HashSet[string]
|
||||
#var scfilter: HashSet[string]
|
||||
var provInt = newTable[string, seq[string]]()
|
||||
var interfaceProvider = newTable[string, seq[string]]()
|
||||
var priList: seq[string]
|
||||
|
|
@ -116,8 +115,8 @@ var knownSyms: HashSet[string]
|
|||
var suppressType = false
|
||||
var suppressRaise = false
|
||||
var droppedSyms = initSet[string]()
|
||||
var callerAlloc = initSet[string]()
|
||||
var callerAllocCollector = initSet[string]()
|
||||
var callerAlloc = initSet[string]()
|
||||
var callerAllocCollector = initSet[string]()
|
||||
var privStr = initSet[string]()
|
||||
var processedFunctions = initSet[string]()
|
||||
var delayedMethods: seq[(GIBaseInfo, GIFunctionInfo)]
|
||||
|
|
@ -142,6 +141,12 @@ mangledNames.add("2buttonPress", "twoButtonPress")
|
|||
mangledNames.add("3buttonPress", "threeButtonPress")
|
||||
mangledNames.add("result", "resu")
|
||||
|
||||
proc gBaseInfoGetName(info: GIBaseInfo): string =
|
||||
result = $(gir.gBaseInfoGetName(info))
|
||||
let h = $(gir.gBaseInfoGetNamespace(info))
|
||||
if h == "Gio" and result == "Application":
|
||||
result = "GApplication"
|
||||
|
||||
proc mangleName(s: cstring): string =
|
||||
result = mysnakeToCamel(s)
|
||||
if mangledNames.contains(result):
|
||||
|
|
@ -348,7 +353,10 @@ proc genP(info: GICallableInfo; genProxy = false; binfo: GIBaseInfo = nil): (str
|
|||
else:
|
||||
arglist = "(cast[ptr " & manglename(gBaseInfoGetName(binfo)) & "00](" & "self.impl)"
|
||||
if genProxy:
|
||||
resul = "(self: " & manglename(gBaseInfoGetName(binfo))
|
||||
var h = manglename(gBaseInfoGetName(binfo))
|
||||
if (sym.startsWith("gdk_events_get_") or sym.startsWith("gdk_event_get_")) and h == "Event":
|
||||
h = "SomeEvent"
|
||||
resul = "(self: " & h
|
||||
else:
|
||||
resul = "(self: ptr " & manglename(gBaseInfoGetName(binfo)) & "00"
|
||||
if m >= 0:
|
||||
|
|
@ -399,6 +407,10 @@ proc genP(info: GICallableInfo; genProxy = false; binfo: GIBaseInfo = nil): (str
|
|||
(h1, h2, h3) = defaultParameters[sym].split
|
||||
if name == h1 and str == h2:
|
||||
str.add(" = " & h3)
|
||||
|
||||
if (sym.startsWith("gdk_events_get_") or sym.startsWith("gdk_event_get_")) and str == "Event":
|
||||
str = "SomeEvent"
|
||||
|
||||
resul.add(name & ": " & str)
|
||||
if j < m:
|
||||
resul.add("; ")
|
||||
|
|
@ -658,6 +670,11 @@ proc writeUnion(info: GIUnionInfo) =
|
|||
output.writeLine(" ", name, ": ", genRec(t))
|
||||
output.writeLine(" ", mangleName(gBaseInfoGetName(info)) & EM & " = ref object")
|
||||
output.writeLine(" impl*: ptr " & mangleName(gBaseInfoGetName(info)) & "00")
|
||||
|
||||
if mangleName(gBaseInfoGetName(info)) == "Event" and moduleNamespace == "gdk":
|
||||
output.writeLine("type")
|
||||
output.writeLine(" SomeEvent* = Event | EventButton | EventMotion | EventTouch | EventScroll | EventCrossing | EventTouchpadSwipe | EventTouchpadPinch")
|
||||
|
||||
let nMethods = gUnionInfoGetNMethods(info)
|
||||
for j in 0 .. <nMethods:
|
||||
let mInfo = gUnionInfoGetMethod(info, j)
|
||||
|
|
@ -887,10 +904,10 @@ proc writeObj(info: GIObjectInfo) =
|
|||
var xxx = mangleName(gBaseInfoGetName(info))
|
||||
output.write("proc " & mangleName("sc_" & $gBaseInfoGetName(signalInfo)) & EM & "(self: " & xxx & "; ")
|
||||
if gCallableInfoGetNArgs(signalInfo) > 0 or gTypeInfoGetTag(zzzu) != GITypeTag.VOID:
|
||||
output.writeLine(" p: proc (self: ptr " & xxx & "00; " & h & " {.cdecl.}, xdata: pointer = nil) =")
|
||||
output.writeLine(" p: proc (self: ptr " & xxx & "00; " & h & " {.cdecl.}, xdata: pointer = nil): culong =")
|
||||
else:
|
||||
output.writeLine(" p: proc (self: ptr gobject.Object00; " & h & " {.cdecl.}, xdata: pointer = nil) =")
|
||||
output.write(" discard g_signal_connect_data(self.impl, \"")
|
||||
output.writeLine(" p: proc (self: ptr gobject.Object00; " & h & " {.cdecl.}, xdata: pointer = nil): culong =")
|
||||
output.write(" g_signal_connect_data(self.impl, \"")
|
||||
output.write($gBaseInfoGetName(signalInfo))
|
||||
output.writeLine("\", cast[GCallback](p), xdata, nil, cast[ConnectFlags](0))")
|
||||
let nMethods = gObjectInfoGetNMethods(info)
|
||||
|
|
@ -1017,8 +1034,8 @@ proc fixednewCursorFromName*(display: Display; name: string): Cursor =
|
|||
|
||||
const GIO_EPI = """
|
||||
|
||||
proc run*(self: Application): int =
|
||||
int(g_application_run(cast[ptr Application00](self.impl), 0, nil))
|
||||
proc run*(self: GApplication): int =
|
||||
int(g_application_run(cast[ptr GApplication00](self.impl), 0, nil))
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
|||
1369
tests/gen.nim.oldv0.2
Normal file
1369
tests/gen.nim.oldv0.2
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue