Hello
I am playing with Nim and IUP and this is pleasant
IUP is very simple ti install with pre-compiled multi os shared lib and it can use GTK2/3/Cairo on Linux
The IUP wrapper seem very limited for the moment and I would like to try to add some bind
so my question Is the current binding hand made or using a tool ?
thank's
The IUP wrapper has been created by c2nim and then modified by hand like so many other wrappers for Nim. A few days ago c2nim learned the --nep1 switch which transforms identifiers to adhere to our style guide so much of this hand editing shouldn't be necessary anymore. To install c2nim you need the devel version of Nim unfortunately and have a directory layout like this:
~/projects/c2nim ~/projects/nim
PRs are welcome which fix c2nim's nimble setup.
Sorry but what I have to do is not clear for me
I have the dev branch of Nim Are the dirs the location for the git clone ? or juste they must exist for the tool ?
~/projects/c2nim
~/projects/nim
What is the exact usage of C2nim? doest is read SYMBOL on the shared Lib or doest it must user .h header
I have try that, but I am probably wrong here
c2nim --cdecl --nep1 --dynlib:SYMBOL libiup.so
answer:
~/projects/c2nim/libiup.so(1, 0) Error: invalid token: (\127)
not really important because I am only trying to understand how it work but thank's for your help
OK understand
I must use the .h
c2nim --cdecl --nep1 --dynlib:libiup --out:iup.nim ../iup/include/iup.h
home/ygo/devygo/nim/iup/include/iup.h(24, 92) Warning: comment '# bug fixes are reported only by IupVersion functions ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(26, 78) Warning: comment '# does not include bug fix releases ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(340, 45) Warning: comment '# 65535 ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(341, 45) Warning: comment '# 65534 ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(342, 45) Warning: comment '# 65533 ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(343, 45) Warning: comment '# 65532 ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(344, 45) Warning: comment '# 65531 ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(345, 45) Warning: comment '# 65530 ' ignored [CommentXIgnored]
home/ygo/devygo/nim/iup/include/iup.h(436, 70) Warning: comment '# this is the trick for Watcom and MetroWerks ' ignored [CommentXIgnored]
Hint: operation successful (463 lines compiled; 0 sec total; 1.102MB) [SuccessX]
but this not add this part
when defined(windows):
const dllname = "iup(30|27|26|25|24).dll"
elif defined(macosx):
const dllname = "libiup(3.0|2.7|2.6|2.5|2.4).dylib"
else:
const dllname = "libiup(3.0|2.7|2.6|2.5|2.4).so.1"
Cool, my personnal generated niup.nim finally work after few manual change
in this block
const
IUP_CENTER* = 0x0000FFFF
IUP_LEFT* = 0x0000FFFE
IUP_RIGHT* = 0x0000FFFD
IUP_MOUSEPOS* = 0x0000FFFC
IUP_CURRENT* = 0x0000FFFB
IUP_CENTERPARENT* = 0x0000FFFA
from
IUP_TOP* = iup_left
IUP_BOTTOM* = iup_right
...
to
IUP_TOP* =IUP_LEFT
IUP_BOTTOM* = IUP_RIGHT
and remove some marked old const defined both as template and as constant like this extract
template iupIsshift*(s: expr): expr =
(s[0] == 'S')
template iupIscontrol*(s: expr): expr =
(s[1] == 'C')
template iupIsbutton1*(s: expr): expr =
(s[2] == '1')
....
# Old definitions for backward compatibility
const
isshift* = iupIsshift
iscontrol* = iupIscontrol
isbutton1* = iupIsbutton1
.....
Finally I have also manually add and comment these lines
when defined(windows):
const iuplib* = "iup.dll"
elif defined(macosx):
const iuplib* = "libiup.dylib"
else:
const iuplib* = "libiup.so"
#~ when not defined(__IUP_H):
#~ const
#~ __IUP_H* = true
#~ import
#~ iupkey, iupdef
the --dynlib:libiup should do that auto magically if not present in directive ;-)