more fixes for dy(n)lib typo; fixes #15
This commit is contained in:
parent
fa332b7298
commit
62b4cc6c02
17 changed files with 140 additions and 101 deletions
|
|
@ -119,7 +119,7 @@ from a C function prototype with the ``dynlib`` pragma:
|
||||||
# if defined(windows)
|
# if defined(windows)
|
||||||
# define iupdll "iup.dll"
|
# define iupdll "iup.dll"
|
||||||
# elif defined(macosx)
|
# elif defined(macosx)
|
||||||
# define iupdll "libiup.dynlib"
|
# define iupdll "libiup.dylib"
|
||||||
# else
|
# else
|
||||||
# define iupdll "libiup.so"
|
# define iupdll "libiup.so"
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -133,7 +133,7 @@ Is translated to:
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
const iupdll* = "iup.dll"
|
const iupdll* = "iup.dll"
|
||||||
elif defined(macosx):
|
elif defined(macosx):
|
||||||
const iupdll* = "libiup.dynlib"
|
const iupdll* = "libiup.dylib"
|
||||||
else:
|
else:
|
||||||
const iupdll* = "libiup.so"
|
const iupdll* = "libiup.so"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,7 @@ proc ipart(x: float): float = return x.trunc()
|
||||||
proc fpart(x: float): float = return x - ipart(x)
|
proc fpart(x: float): float = return x - ipart(x)
|
||||||
proc rfpart(x: float): float = return 1.0 - fpart(x)
|
proc rfpart(x: float): float = return 1.0 - fpart(x)
|
||||||
|
|
||||||
proc drawLineAA(sur: PSurface, p1, p2: TPoint, color: TColor) =
|
proc drawLineAA*(sur: PSurface, p1, p2: TPoint, color: TColor) =
|
||||||
## Draws a anti-aliased line from ``p1`` to ``p2``, using Xiaolin Wu's
|
## Draws a anti-aliased line from ``p1`` to ``p2``, using Xiaolin Wu's
|
||||||
## line algorithm
|
## line algorithm
|
||||||
var (x1, x2, y1, y2) = (p1.x.toFloat(), p2.x.toFloat(),
|
var (x1, x2, y1, y2) = (p1.x.toFloat(), p2.x.toFloat(),
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ const
|
||||||
DocumentFragmentNode* = 11
|
DocumentFragmentNode* = 11
|
||||||
|
|
||||||
# Nodes which are childless - Not sure about AttributeNode
|
# Nodes which are childless - Not sure about AttributeNode
|
||||||
childlessObjects = {DocumentNode, AttributeNode, TextNode, CDataSectionNode, ProcessingInstructionNode, CommentNode}
|
childlessObjects = {DocumentNode, AttributeNode, TextNode,
|
||||||
|
CDataSectionNode, ProcessingInstructionNode, CommentNode}
|
||||||
# Illegal characters
|
# Illegal characters
|
||||||
illegalChars = {'>', '<', '&', '"'}
|
illegalChars = {'>', '<', '&', '"'}
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ type
|
||||||
Element = object of Node
|
Element = object of Node
|
||||||
FTagName: string # Read-only
|
FTagName: string # Read-only
|
||||||
|
|
||||||
PCharacterData = ref CharacterData
|
PCharacterData* = ref CharacterData
|
||||||
CharacterData = object of Node
|
CharacterData = object of Node
|
||||||
data*: string
|
data*: string
|
||||||
|
|
||||||
|
|
@ -109,10 +110,10 @@ type
|
||||||
# DOMImplementation
|
# DOMImplementation
|
||||||
proc getDOM*(): PDOMImplementation =
|
proc getDOM*(): PDOMImplementation =
|
||||||
## Returns a DOMImplementation
|
## Returns a DOMImplementation
|
||||||
var DOMImpl: PDOMImplementation
|
new(result)
|
||||||
new(DOMImpl)
|
result.Features = @[(name: "core", version: "2.0"),
|
||||||
DOMImpl.Features = @[(name: "core", version: "2.0"), (name: "core", version: "1.0"), (name: "XML", version: "2.0")]
|
(name: "core", version: "1.0"),
|
||||||
return DOMImpl
|
(name: "XML", version: "2.0")]
|
||||||
|
|
||||||
proc createDocument*(dom: PDOMImplementation, namespaceURI: string, qualifiedName: string): PDocument =
|
proc createDocument*(dom: PDOMImplementation, namespaceURI: string, qualifiedName: string): PDocument =
|
||||||
## Creates an XML Document object of the specified type with its document element.
|
## Creates an XML Document object of the specified type with its document element.
|
||||||
|
|
|
||||||
|
|
@ -22741,144 +22741,144 @@ proc AnsiLowerBuff*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,
|
||||||
|
|
||||||
# WinBase.h
|
# WinBase.h
|
||||||
|
|
||||||
proc FreeModule(h: HINST): WINBOOL =
|
proc FreeModule*(h: HINST): WINBOOL =
|
||||||
result = FreeLibrary(h)
|
result = FreeLibrary(h)
|
||||||
|
|
||||||
proc MakeProcInstance(p, i: pointer): pointer =
|
proc MakeProcInstance*(p, i: pointer): pointer =
|
||||||
result = p
|
result = p
|
||||||
|
|
||||||
proc FreeProcInstance(p: pointer): pointer =
|
proc FreeProcInstance*(p: pointer): pointer =
|
||||||
result = p
|
result = p
|
||||||
|
|
||||||
proc GlobalDiscard(hglbMem: HGLOBAL): HGLOBAL =
|
proc GlobalDiscard*(hglbMem: HGLOBAL): HGLOBAL =
|
||||||
result = GlobalReAlloc(hglbMem, 0, GMEM_MOVEABLE)
|
result = GlobalReAlloc(hglbMem, 0, GMEM_MOVEABLE)
|
||||||
|
|
||||||
proc LocalDiscard(hlocMem: HLOCAL): HLOCAL =
|
proc LocalDiscard*(hlocMem: HLOCAL): HLOCAL =
|
||||||
result = LocalReAlloc(hlocMem, 0, LMEM_MOVEABLE)
|
result = LocalReAlloc(hlocMem, 0, LMEM_MOVEABLE)
|
||||||
|
|
||||||
# WinGDI.h
|
# WinGDI.h
|
||||||
|
|
||||||
proc GetGValue(rgb: int32): int8 =
|
proc GetGValue*(rgb: int32): int8 =
|
||||||
result = toU8(rgb shr 8'i32)
|
result = toU8(rgb shr 8'i32)
|
||||||
proc RGB(r, g, b: int): COLORREF =
|
proc RGB*(r, g, b: int): COLORREF =
|
||||||
result = toU32(r) or (toU32(g) shl 8) or (toU32(b) shl 16)
|
result = toU32(r) or (toU32(g) shl 8) or (toU32(b) shl 16)
|
||||||
proc RGB(r, g, b: range[0 .. 255]): COLORREF =
|
proc RGB*(r, g, b: range[0 .. 255]): COLORREF =
|
||||||
result = r or g shl 8 or b shl 16
|
result = r or g shl 8 or b shl 16
|
||||||
|
|
||||||
proc PALETTERGB(r, g, b: range[0..255]): COLORREF =
|
proc PALETTERGB*(r, g, b: range[0..255]): COLORREF =
|
||||||
result = 0x02000000 or RGB(r, g, b)
|
result = 0x02000000 or RGB(r, g, b)
|
||||||
|
|
||||||
proc PALETTEINDEX(i: DWORD): COLORREF =
|
proc PALETTEINDEX*(i: DWORD): COLORREF =
|
||||||
result = COLORREF(0x01000000'i32 or i and 0xffff'i32)
|
result = COLORREF(0x01000000'i32 or i and 0xffff'i32)
|
||||||
|
|
||||||
|
|
||||||
proc GetRValue(rgb: COLORREF): int8 =
|
proc GetRValue*(rgb: COLORREF): int8 =
|
||||||
result = toU8(rgb)
|
result = toU8(rgb)
|
||||||
|
|
||||||
proc GetGValue(rgb: COLORREF): int8 =
|
proc GetGValue*(rgb: COLORREF): int8 =
|
||||||
result = toU8(rgb shr 8)
|
result = toU8(rgb shr 8)
|
||||||
|
|
||||||
proc GetBValue(rgb: COLORREF): int8 =
|
proc GetBValue*(rgb: COLORREF): int8 =
|
||||||
result = toU8(rgb shr 16)
|
result = toU8(rgb shr 16)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
proc HIBYTE(w: int32): int8 =
|
proc HIBYTE*(w: int32): int8 =
|
||||||
result = toU8(w shr 8'i32 and 0x000000FF'i32)
|
result = toU8(w shr 8'i32 and 0x000000FF'i32)
|
||||||
|
|
||||||
proc HIWORD(L: int32): int16 =
|
proc HIWORD*(L: int32): int16 =
|
||||||
result = toU16(L shr 16'i32 and 0x0000FFFF'i32)
|
result = toU16(L shr 16'i32 and 0x0000FFFF'i32)
|
||||||
|
|
||||||
proc LOBYTE(w: int32): int8 =
|
proc LOBYTE*(w: int32): int8 =
|
||||||
result = toU8(w)
|
result = toU8(w)
|
||||||
|
|
||||||
proc LOWORD(L: int32): int16 =
|
proc LOWORD*(L: int32): int16 =
|
||||||
result = toU16(L)
|
result = toU16(L)
|
||||||
|
|
||||||
proc MAKELONG(a, b: int32): LONG =
|
proc MAKELONG*(a, b: int32): LONG =
|
||||||
result = a and 0x0000ffff'i32 or b shl 16'i32
|
result = a and 0x0000ffff'i32 or b shl 16'i32
|
||||||
|
|
||||||
proc MAKEWORD(a, b: int32): int16 =
|
proc MAKEWORD*(a, b: int32): int16 =
|
||||||
result = toU16(a and 0xff'i32) or toU16(b shl 8'i32)
|
result = toU16(a and 0xff'i32) or toU16(b shl 8'i32)
|
||||||
|
|
||||||
proc SEXT_HIWORD(L: int32): int32 =
|
proc SEXT_HIWORD*(L: int32): int32 =
|
||||||
# return type might be wrong
|
# return type might be wrong
|
||||||
result = HIWORD(L)
|
result = HIWORD(L)
|
||||||
|
|
||||||
proc ZEXT_HIWORD(L: int32): int32 =
|
proc ZEXT_HIWORD*(L: int32): int32 =
|
||||||
# return type might be wrong
|
# return type might be wrong
|
||||||
result = ze(HIWORD(L))
|
result = ze(HIWORD(L))
|
||||||
|
|
||||||
proc SEXT_LOWORD(L: int32): int32 =
|
proc SEXT_LOWORD*(L: int32): int32 =
|
||||||
result = LOWORD(L)
|
result = LOWORD(L)
|
||||||
|
|
||||||
proc INDEXTOOVERLAYMASK(i: int32): int32 =
|
proc INDEXTOOVERLAYMASK*(i: int32): int32 =
|
||||||
# return type might be wrong
|
# return type might be wrong
|
||||||
result = i shl 8'i32
|
result = i shl 8'i32
|
||||||
|
|
||||||
proc INDEXTOSTATEIMAGEMASK(i: int32): int32 =
|
proc INDEXTOSTATEIMAGEMASK*(i: int32): int32 =
|
||||||
# return type might be wrong
|
# return type might be wrong
|
||||||
result = i shl 12'i32
|
result = i shl 12'i32
|
||||||
|
|
||||||
proc MAKEINTATOM(i: int32): LPTSTR =
|
proc MAKEINTATOM*(i: int32): LPTSTR =
|
||||||
result = cast[LPTSTR](cast[ULONG_PTR](ToU16(i)))
|
result = cast[LPTSTR](cast[ULONG_PTR](ToU16(i)))
|
||||||
|
|
||||||
proc MAKELANGID(p, s: int32): int32 =
|
proc MAKELANGID*(p, s: int32): int32 =
|
||||||
# return type might be wrong
|
# return type might be wrong
|
||||||
result = toU16(s) shl 10'i16 or toU16(p)
|
result = toU16(s) shl 10'i16 or toU16(p)
|
||||||
|
|
||||||
proc PRIMARYLANGID(lgid: int32): int16 =
|
proc PRIMARYLANGID*(lgid: int32): int16 =
|
||||||
result = toU16(lgid) and 0x000003FF'i16
|
result = toU16(lgid) and 0x000003FF'i16
|
||||||
|
|
||||||
proc SUBLANGID(lgid: int32): int32 =
|
proc SUBLANGID*(lgid: int32): int32 =
|
||||||
# return type might be wrong
|
# return type might be wrong
|
||||||
result = toU16(lgid) shr 10'i16
|
result = toU16(lgid) shr 10'i16
|
||||||
|
|
||||||
proc LANGIDFROMLCID(lcid: int32): int16 =
|
proc LANGIDFROMLCID*(lcid: int32): int16 =
|
||||||
result = toU16(lcid)
|
result = toU16(lcid)
|
||||||
|
|
||||||
proc SORTIDFROMLCID(lcid: int32): int16 =
|
proc SORTIDFROMLCID*(lcid: int32): int16 =
|
||||||
result = toU16((lcid and 0x000FFFFF'i32) shr 16'i32)
|
result = toU16((lcid and 0x000FFFFF'i32) shr 16'i32)
|
||||||
|
|
||||||
proc MAKELCID(lgid, srtid: int32): DWORD =
|
proc MAKELCID*(lgid, srtid: int32): DWORD =
|
||||||
result = toU32(srtid shl 16'i32 or lgid and 0xffff'i32)
|
result = toU32(srtid shl 16'i32 or lgid and 0xffff'i32)
|
||||||
|
|
||||||
proc MAKELPARAM(L, h: int32): LPARAM =
|
proc MAKELPARAM*(L, h: int32): LPARAM =
|
||||||
result = LPARAM(MAKELONG(L, h))
|
result = LPARAM(MAKELONG(L, h))
|
||||||
|
|
||||||
proc MAKELRESULT(L, h: int32): LRESULT =
|
proc MAKELRESULT*(L, h: int32): LRESULT =
|
||||||
result = LRESULT(MAKELONG(L, h))
|
result = LRESULT(MAKELONG(L, h))
|
||||||
|
|
||||||
proc MAKEROP4(fore, back: int32): DWORD =
|
proc MAKEROP4*(fore, back: int32): DWORD =
|
||||||
result = back shl 8'i32 and 0xFF000000'i32 or fore
|
result = back shl 8'i32 and 0xFF000000'i32 or fore
|
||||||
|
|
||||||
proc MAKEWPARAM(L, h: int32): WPARAM =
|
proc MAKEWPARAM*(L, h: int32): WPARAM =
|
||||||
result = WPARAM(MAKELONG(L, h))
|
result = WPARAM(MAKELONG(L, h))
|
||||||
|
|
||||||
proc GET_X_LPARAM(lp: Windows.LParam): int32 =
|
proc GET_X_LPARAM*(lp: Windows.LParam): int32 =
|
||||||
result = int16(LOWORD(lp))
|
result = int16(LOWORD(lp))
|
||||||
|
|
||||||
proc GET_Y_LPARAM(lp: Windows.LParam): int32 =
|
proc GET_Y_LPARAM*(lp: Windows.LParam): int32 =
|
||||||
result = int16(HIWORD(lp))
|
result = int16(HIWORD(lp))
|
||||||
|
|
||||||
proc UNICODE_NULL(): WCHAR =
|
proc UNICODE_NULL*(): WCHAR =
|
||||||
result = 0'i16
|
result = 0'i16
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc GetFirstChild(h: HWND): HWND =
|
proc GetFirstChild*(h: HWND): HWND =
|
||||||
result = GetTopWindow(h)
|
result = GetTopWindow(h)
|
||||||
|
|
||||||
proc GetNextSibling(h: HWND): HWND =
|
proc GetNextSibling*(h: HWND): HWND =
|
||||||
result = GetWindow(h, GW_HWNDNEXT)
|
result = GetWindow(h, GW_HWNDNEXT)
|
||||||
|
|
||||||
proc GetWindowID(h: HWND): int32 =
|
proc GetWindowID*(h: HWND): int32 =
|
||||||
result = GetDlgCtrlID(h)
|
result = GetDlgCtrlID(h)
|
||||||
|
|
||||||
proc SubclassWindow(h: HWND, p: LONG): LONG =
|
proc SubclassWindow*(h: HWND, p: LONG): LONG =
|
||||||
result = SetWindowLong(h, GWL_WNDPROC, p)
|
result = SetWindowLong(h, GWL_WNDPROC, p)
|
||||||
|
|
||||||
proc GET_WM_COMMAND_CMD(w, L: int32): int32 =
|
proc GET_WM_COMMAND_CMD*(w, L: int32): int32 =
|
||||||
# return type might be wrong
|
# return type might be wrong
|
||||||
result = HIWORD(w)
|
result = HIWORD(w)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,12 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
const
|
const LIB_CAIRO* = "libcairo-2.dll"
|
||||||
LIB_CAIRO* = "libcairo-2.dll"
|
elif defined(macosx):
|
||||||
|
const LIB_CAIRO* = "libcairo.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const LIB_CAIRO* = "libcairo.so"
|
||||||
LIB_CAIRO* = "libcairo.so"
|
|
||||||
type
|
type
|
||||||
PByte = cstring
|
PByte = cstring
|
||||||
TStatus* = enum
|
TStatus* = enum
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ import
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
const
|
const
|
||||||
lib = "libatk-1.0-0.dll"
|
lib = "libatk-1.0-0.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
lib = "libatk-1.0.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
lib = "libatk-1.0.so"
|
lib = "libatk-1.0.so"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import
|
||||||
when defined(win32):
|
when defined(win32):
|
||||||
const
|
const
|
||||||
lib = "libgdk-win32-2.0-0.dll"
|
lib = "libgdk-win32-2.0-0.dll"
|
||||||
elif defined(darwin):
|
elif defined(macosx):
|
||||||
# linklib gtk-x11-2.0
|
# linklib gtk-x11-2.0
|
||||||
# linklib gdk-x11-2.0
|
# linklib gdk-x11-2.0
|
||||||
# linklib pango-1.0.0
|
# linklib pango-1.0.0
|
||||||
|
|
@ -14,7 +14,7 @@ elif defined(darwin):
|
||||||
# linklib gdk_pixbuf-2.0.0
|
# linklib gdk_pixbuf-2.0.0
|
||||||
# linklib atk-1.0.0
|
# linklib atk-1.0.0
|
||||||
const
|
const
|
||||||
lib = "gdk-x11-2.0"
|
lib = "libgdk-x11-2.0.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
lib = "libgdk-x11-2.0.so(|.0)"
|
lib = "libgdk-x11-2.0.so(|.0)"
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import
|
||||||
when defined(win32):
|
when defined(win32):
|
||||||
const
|
const
|
||||||
pixbuflib = "libgdk_pixbuf-2.0-0.dll"
|
pixbuflib = "libgdk_pixbuf-2.0-0.dll"
|
||||||
elif defined(darwin):
|
elif defined(macosx):
|
||||||
const
|
const
|
||||||
pixbuflib = "gdk_pixbuf-2.0.0"
|
pixbuflib = "libgdk_pixbuf-2.0.0.dylib"
|
||||||
# linklib gtk-x11-2.0
|
# linklib gtk-x11-2.0
|
||||||
# linklib gdk-x11-2.0
|
# linklib gdk-x11-2.0
|
||||||
# linklib pango-1.0.0
|
# linklib pango-1.0.0
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ import
|
||||||
when defined(WIN32):
|
when defined(WIN32):
|
||||||
const
|
const
|
||||||
GLExtLib = "libgdkglext-win32-1.0-0.dll"
|
GLExtLib = "libgdkglext-win32-1.0-0.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
GLExtLib = "libgdkglext-x11-1.0.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
GLExtLib = "libgdkglext-x11-1.0.so"
|
GLExtLib = "libgdkglext-x11-1.0.so"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@ when defined(windows):
|
||||||
gliblib = "libglib-2.0-0.dll"
|
gliblib = "libglib-2.0-0.dll"
|
||||||
gmodulelib = "libgmodule-2.0-0.dll"
|
gmodulelib = "libgmodule-2.0-0.dll"
|
||||||
gobjectlib = "libgobject-2.0-0.dll"
|
gobjectlib = "libgobject-2.0-0.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
gliblib = "libglib-2.0.dylib"
|
||||||
|
gmodulelib = "libgmodule-2.0.dylib"
|
||||||
|
gobjectlib = "libgobject-2.0.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
gliblib = "libglib-2.0.so(|.0)"
|
gliblib = "libglib-2.0.so(|.0)"
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import
|
||||||
when defined(win32):
|
when defined(win32):
|
||||||
const
|
const
|
||||||
lib = "libgtk-win32-2.0-0.dll"
|
lib = "libgtk-win32-2.0-0.dll"
|
||||||
elif defined(darwin):
|
elif defined(macosx):
|
||||||
const
|
const
|
||||||
lib = "gtk-x11-2.0"
|
lib = "libgtk-x11-2.0.dylib"
|
||||||
# linklib gtk-x11-2.0
|
# linklib gtk-x11-2.0
|
||||||
# linklib gdk-x11-2.0
|
# linklib gdk-x11-2.0
|
||||||
# linklib pango-1.0.0
|
# linklib pango-1.0.0
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,15 @@
|
||||||
import
|
import
|
||||||
Glib2, Gdk2, gtk2, GdkGLExt
|
Glib2, Gdk2, gtk2, GdkGLExt
|
||||||
|
|
||||||
const
|
when defined(windows):
|
||||||
GLExtLib* = if defined(WIN32): "libgtkglext-win32-1.0-0.dll" else: "libgtkglext-x11-1.0.so"
|
const
|
||||||
|
GLExtLib* = "libgtkglext-win32-1.0-0.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
GLExtLib* = "libgtkglext-x11-1.0.dylib"
|
||||||
|
else:
|
||||||
|
const
|
||||||
|
GLExtLib* = "libgtkglext-x11-1.0.so"
|
||||||
|
|
||||||
const
|
const
|
||||||
HEADER_GTKGLEXT_MAJOR_VERSION* = 1
|
HEADER_GTKGLEXT_MAJOR_VERSION* = 1
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ import
|
||||||
gtk2, glib2, atk, pango, gdk2pixbuf, gdk2
|
gtk2, glib2, atk, pango, gdk2pixbuf, gdk2
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
{.define: WINDOWING_WIN32.}
|
|
||||||
const
|
const
|
||||||
htmllib = "libgtkhtml-win32-2.0-0.dll"
|
htmllib = "libgtkhtml-win32-2.0-0.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
htmllib = "libgtkhtml-2.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
htmllib = "libgtkhtml-2.so"
|
htmllib = "libgtkhtml-2.so"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ import
|
||||||
when defined(win32):
|
when defined(win32):
|
||||||
const
|
const
|
||||||
LibGladeLib = "libglade-2.0-0.dll"
|
LibGladeLib = "libglade-2.0-0.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
LibGladeLib = "libglade-2.0.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
LibGladeLib = "libglade-2.0.so"
|
LibGladeLib = "libglade-2.0.so"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ import
|
||||||
when defined(win32):
|
when defined(win32):
|
||||||
const
|
const
|
||||||
lib* = "libpango-1.0-0.dll"
|
lib* = "libpango-1.0-0.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
lib* = "libpango-1.0.dylib"
|
||||||
else:
|
else:
|
||||||
const
|
const
|
||||||
lib* = "libpango-1.0.so.0"
|
lib* = "libpango-1.0.so.0"
|
||||||
|
|
|
||||||
37
rod/ast.nim
37
rod/ast.nim
|
|
@ -61,7 +61,8 @@ type
|
||||||
# (used for macros)
|
# (used for macros)
|
||||||
nkNilLit, # the nil literal
|
nkNilLit, # the nil literal
|
||||||
# end of atoms
|
# end of atoms
|
||||||
nkDotCall, # used to temporarily flag a nkCall node; this is used
|
nkDotCall, # used to temporarily flag a nkCall node;
|
||||||
|
# this is used
|
||||||
# for transforming ``s.len`` to ``len(s)``
|
# for transforming ``s.len`` to ``len(s)``
|
||||||
nkCommand, # a call like ``p 2, 4`` without parenthesis
|
nkCommand, # a call like ``p 2, 4`` without parenthesis
|
||||||
nkCall, # a call like p(x, y) or an operation like +(a, b)
|
nkCall, # a call like p(x, y) or an operation like +(a, b)
|
||||||
|
|
@ -115,7 +116,8 @@ type
|
||||||
# end of expressions
|
# end of expressions
|
||||||
|
|
||||||
nkAsgn, # a = b
|
nkAsgn, # a = b
|
||||||
nkFastAsgn, # internal node for a fast ``a = b`` (no string copy)
|
nkFastAsgn, # internal node for a fast ``a = b``
|
||||||
|
# (no string copy)
|
||||||
nkGenericParams, # generic parameters
|
nkGenericParams, # generic parameters
|
||||||
nkFormalParams, # formal parameters
|
nkFormalParams, # formal parameters
|
||||||
nkOfInherit, # inherited from symbol
|
nkOfInherit, # inherited from symbol
|
||||||
|
|
@ -128,7 +130,8 @@ type
|
||||||
nkTemplateDef, # a template
|
nkTemplateDef, # a template
|
||||||
nkIteratorDef, # an iterator
|
nkIteratorDef, # an iterator
|
||||||
|
|
||||||
nkOfBranch, # used inside case statements for (cond, action)-pairs
|
nkOfBranch, # used inside case statements
|
||||||
|
# for (cond, action)-pairs
|
||||||
nkElifBranch, # used in if statements
|
nkElifBranch, # used in if statements
|
||||||
nkExceptBranch, # an except section
|
nkExceptBranch, # an except section
|
||||||
nkElse, # an else part
|
nkElse, # an else part
|
||||||
|
|
@ -296,7 +299,8 @@ type
|
||||||
skForVar, # a for loop variable
|
skForVar, # a for loop variable
|
||||||
skLabel, # a label (for block statement)
|
skLabel, # a label (for block statement)
|
||||||
skStub # symbol is a stub and not yet loaded from the ROD
|
skStub # symbol is a stub and not yet loaded from the ROD
|
||||||
# file (it is loaded on demand, which may mean: never)
|
# file (it is loaded on demand, which may
|
||||||
|
# mean: never)
|
||||||
TSymKinds* = set[TSymKind]
|
TSymKinds* = set[TSymKind]
|
||||||
|
|
||||||
TMagic* = enum # symbols that require compiler magic:
|
TMagic* = enum # symbols that require compiler magic:
|
||||||
|
|
@ -312,10 +316,12 @@ type
|
||||||
mMinF64, mMaxF64, mAddU, mSubU, mMulU,
|
mMinF64, mMaxF64, mAddU, mSubU, mMulU,
|
||||||
mDivU, mModU, mAddU64, mSubU64, mMulU64, mDivU64, mModU64, mEqI, mLeI,
|
mDivU, mModU, mAddU64, mSubU64, mMulU64, mDivU64, mModU64, mEqI, mLeI,
|
||||||
mLtI,
|
mLtI,
|
||||||
mEqI64, mLeI64, mLtI64, mEqF64, mLeF64, mLtF64, mLeU, mLtU, mLeU64, mLtU64,
|
mEqI64, mLeI64, mLtI64, mEqF64, mLeF64, mLtF64,
|
||||||
|
mLeU, mLtU, mLeU64, mLtU64,
|
||||||
mEqEnum, mLeEnum, mLtEnum, mEqCh, mLeCh, mLtCh, mEqB, mLeB, mLtB, mEqRef,
|
mEqEnum, mLeEnum, mLtEnum, mEqCh, mLeCh, mLtCh, mEqB, mLeB, mLtB, mEqRef,
|
||||||
mEqProc, mEqUntracedRef, mLePtr, mLtPtr, mEqCString, mXor, mUnaryMinusI,
|
mEqProc, mEqUntracedRef, mLePtr, mLtPtr, mEqCString, mXor, mUnaryMinusI,
|
||||||
mUnaryMinusI64, mAbsI, mAbsI64, mNot, mUnaryPlusI, mBitnotI, mUnaryPlusI64,
|
mUnaryMinusI64, mAbsI, mAbsI64, mNot,
|
||||||
|
mUnaryPlusI, mBitnotI, mUnaryPlusI64,
|
||||||
mBitnotI64, mUnaryPlusF64, mUnaryMinusF64, mAbsF64, mZe8ToI, mZe8ToI64,
|
mBitnotI64, mUnaryPlusF64, mUnaryMinusF64, mAbsF64, mZe8ToI, mZe8ToI64,
|
||||||
mZe16ToI, mZe16ToI64, mZe32ToI64, mZeIToI64, mToU8, mToU16, mToU32,
|
mZe16ToI, mZe16ToI64, mZe32ToI64, mZeIToI64, mToU8, mToU16, mToU32,
|
||||||
mToFloat, mToBiggestFloat, mToInt, mToBiggestInt, mCharToStr, mBoolToStr,
|
mToFloat, mToBiggestFloat, mToInt, mToBiggestInt, mCharToStr, mBoolToStr,
|
||||||
|
|
@ -521,7 +527,8 @@ const
|
||||||
ConcreteTypes*: TTypeKinds = { # types of the expr that may occur in::
|
ConcreteTypes*: TTypeKinds = { # types of the expr that may occur in::
|
||||||
# var x = expr
|
# var x = expr
|
||||||
tyBool, tyChar, tyEnum, tyArray, tyObject,
|
tyBool, tyChar, tyEnum, tyArray, tyObject,
|
||||||
tySet, tyTuple, tyRange, tyPtr, tyRef, tyVar, tySequence, tyProc, tyPointer,
|
tySet, tyTuple, tyRange, tyPtr, tyRef, tyVar, tySequence, tyProc,
|
||||||
|
tyPointer,
|
||||||
tyOpenArray, tyString, tyCString, tyInt..tyInt64, tyFloat..tyFloat128}
|
tyOpenArray, tyString, tyCString, tyInt..tyInt64, tyFloat..tyFloat128}
|
||||||
|
|
||||||
ConstantDataTypes*: TTypeKinds = {tyArray, tySet, tyTuple}
|
ConstantDataTypes*: TTypeKinds = {tyArray, tySet, tyTuple}
|
||||||
|
|
@ -609,7 +616,8 @@ type
|
||||||
const
|
const
|
||||||
InitIntSetSize* = 8 # must be a power of two!
|
InitIntSetSize* = 8 # must be a power of two!
|
||||||
TrunkShift* = 9
|
TrunkShift* = 9
|
||||||
BitsPerTrunk* = 1 shl TrunkShift # needs to be a power of 2 and divisible by 64
|
BitsPerTrunk* = 1 shl TrunkShift # needs to be a power of 2 and
|
||||||
|
# divisible by 64
|
||||||
TrunkMask* = BitsPerTrunk - 1
|
TrunkMask* = BitsPerTrunk - 1
|
||||||
IntsPerTrunk* = BitsPerTrunk div (sizeof(TBitScalar) * 8)
|
IntsPerTrunk* = BitsPerTrunk div (sizeof(TBitScalar) * 8)
|
||||||
IntShift* = 5 + ord(sizeof(TBitScalar) == 8) # 5 or 6, depending on int width
|
IntShift* = 5 + ord(sizeof(TBitScalar) == 8) # 5 or 6, depending on int width
|
||||||
|
|
@ -718,7 +726,8 @@ proc discardSons(father: PNode) =
|
||||||
|
|
||||||
proc newNode(kind: TNodeKind): PNode =
|
proc newNode(kind: TNodeKind): PNode =
|
||||||
new(result)
|
new(result)
|
||||||
result.kind = kind #result.info := UnknownLineInfo(); inlined:
|
result.kind = kind
|
||||||
|
#result.info = UnknownLineInfo() inlined:
|
||||||
result.info.fileIndex = int32(- 1)
|
result.info.fileIndex = int32(- 1)
|
||||||
result.info.col = int16(- 1)
|
result.info.col = int16(- 1)
|
||||||
result.info.line = int16(- 1)
|
result.info.line = int16(- 1)
|
||||||
|
|
@ -773,8 +782,9 @@ proc NewType(kind: TTypeKind, owner: PSym): PType =
|
||||||
result.align = 2 # default alignment
|
result.align = 2 # default alignment
|
||||||
result.id = getID()
|
result.id = getID()
|
||||||
if debugIds:
|
if debugIds:
|
||||||
RegisterId(result) #if result.id < 2000 then
|
RegisterId(result)
|
||||||
# MessageOut(typeKindToStr[kind] +{&} ' has id: ' +{&} toString(result.id));
|
#if result.id < 2000 then
|
||||||
|
# MessageOut(typeKindToStr[kind] & ' has id: ' & toString(result.id))
|
||||||
|
|
||||||
proc assignType(dest, src: PType) =
|
proc assignType(dest, src: PType) =
|
||||||
dest.kind = src.kind
|
dest.kind = src.kind
|
||||||
|
|
@ -827,8 +837,9 @@ proc NewSym(symKind: TSymKind, Name: PIdent, owner: PSym): PSym =
|
||||||
result.offset = - 1
|
result.offset = - 1
|
||||||
result.id = getID()
|
result.id = getID()
|
||||||
if debugIds:
|
if debugIds:
|
||||||
RegisterId(result) #if result.id < 2000 then
|
RegisterId(result)
|
||||||
# MessageOut(name.s +{&} ' has id: ' +{&} toString(result.id));
|
#if result.id < 2000:
|
||||||
|
# MessageOut(name.s & " has id: " & toString(result.id))
|
||||||
|
|
||||||
proc initStrTable(x: var TStrTable) =
|
proc initStrTable(x: var TStrTable) =
|
||||||
x.counter = 0
|
x.counter = 0
|
||||||
|
|
|
||||||
|
|
@ -38,42 +38,34 @@ type
|
||||||
efNone, efLValue
|
efNone, efLValue
|
||||||
TEvalFlags = set[TEvalFlag]
|
TEvalFlags = set[TEvalFlag]
|
||||||
|
|
||||||
|
|
||||||
proc newStackFrame*(): PStackFrame
|
|
||||||
proc pushStackFrame*(c: PEvalContext, t: PStackFrame)
|
|
||||||
proc popStackFrame*(c: PEvalContext)
|
|
||||||
proc newEvalContext*(module: PSym, filename: string,
|
|
||||||
optEval: bool): PEvalContext
|
|
||||||
proc eval*(c: PEvalContext, n: PNode): PNode
|
proc eval*(c: PEvalContext, n: PNode): PNode
|
||||||
# eval never returns nil! This simplifies the code a lot and
|
# eval never returns nil! This simplifies the code a lot and
|
||||||
# makes it faster too.
|
# makes it faster too.
|
||||||
proc evalConstExpr*(module: PSym, e: PNode): PNode
|
proc evalConstExpr*(module: PSym, e: PNode): PNode
|
||||||
proc evalPass*(): TPass
|
|
||||||
# implementation
|
|
||||||
|
|
||||||
const
|
const
|
||||||
evalMaxIterations = 500_000 # max iterations of all loops
|
evalMaxIterations = 500_000 # max iterations of all loops
|
||||||
evalMaxRecDepth = 10_000 # max recursion depth for evaluation
|
evalMaxRecDepth = 10_000 # max recursion depth for evaluation
|
||||||
|
|
||||||
# Much better: use a timeout! -> Wether code compiles depends on the machine
|
# Much better: use a timeout! -> Wether code compiles depends on the machine
|
||||||
# the compiler runs on then! Bad idea!
|
# the compiler runs on then! Bad idea!
|
||||||
|
|
||||||
proc newStackFrame(): PStackFrame =
|
proc newStackFrame*(): PStackFrame =
|
||||||
new(result)
|
new(result)
|
||||||
initIdNodeTable(result.mapping)
|
initIdNodeTable(result.mapping)
|
||||||
result.params = @[]
|
result.params = @[]
|
||||||
|
|
||||||
proc newEvalContext(module: PSym, filename: string,
|
proc newEvalContext*(module: PSym, filename: string,
|
||||||
optEval: bool): PEvalContext =
|
optEval: bool): PEvalContext =
|
||||||
new(result)
|
new(result)
|
||||||
result.module = module
|
result.module = module
|
||||||
result.optEval = optEval
|
result.optEval = optEval
|
||||||
|
|
||||||
proc pushStackFrame(c: PEvalContext, t: PStackFrame) =
|
proc pushStackFrame*(c: PEvalContext, t: PStackFrame) {.inline.} =
|
||||||
t.next = c.tos
|
t.next = c.tos
|
||||||
c.tos = t
|
c.tos = t
|
||||||
|
|
||||||
proc popStackFrame(c: PEvalContext) =
|
proc popStackFrame*(c: PEvalContext) {.inline.} =
|
||||||
if (c.tos == nil): InternalError("popStackFrame")
|
if (c.tos == nil): InternalError("popStackFrame")
|
||||||
c.tos = c.tos.next
|
c.tos = c.tos.next
|
||||||
|
|
||||||
|
|
@ -83,10 +75,19 @@ proc stackTraceAux(x: PStackFrame) =
|
||||||
if x != nil:
|
if x != nil:
|
||||||
stackTraceAux(x.next)
|
stackTraceAux(x.next)
|
||||||
var info = if x.call != nil: x.call.info else: UnknownLineInfo()
|
var info = if x.call != nil: x.call.info else: UnknownLineInfo()
|
||||||
MsgWriteln(`%`("file: $1, line: $2",
|
# we now use the same format as in system/except.nim
|
||||||
[toFilename(info), $(toLineNumber(info))]))
|
var s = toFilename(info)
|
||||||
|
var line = toLineNumber(info)
|
||||||
|
if line > 0:
|
||||||
|
add(s, '(')
|
||||||
|
add(s, $line)
|
||||||
|
add(s, ')')
|
||||||
|
if x.prc != nil:
|
||||||
|
for k in 1..max(1, 25-s.len): add(s, ' ')
|
||||||
|
add(s, x.prc.name.s)
|
||||||
|
MsgWriteln(s)
|
||||||
|
|
||||||
proc stackTrace(c: PEvalContext, n: PNode, msg: TMsgKind, arg: string = "") =
|
proc stackTrace(c: PEvalContext, n: PNode, msg: TMsgKind, arg = "") =
|
||||||
MsgWriteln("stack trace: (most recent call last)")
|
MsgWriteln("stack trace: (most recent call last)")
|
||||||
stackTraceAux(c.tos)
|
stackTraceAux(c.tos)
|
||||||
Fatal(n.info, msg, arg)
|
Fatal(n.info, msg, arg)
|
||||||
|
|
@ -253,7 +254,6 @@ proc evalVar(c: PEvalContext, n: PNode): PNode =
|
||||||
assert(a.sons[0].kind == nkSym)
|
assert(a.sons[0].kind == nkSym)
|
||||||
var v = a.sons[0].sym
|
var v = a.sons[0].sym
|
||||||
if a.sons[2].kind != nkEmpty:
|
if a.sons[2].kind != nkEmpty:
|
||||||
#if a.sons[2].kind == nkNone: echo "Yep"
|
|
||||||
result = evalAux(c, a.sons[2], {})
|
result = evalAux(c, a.sons[2], {})
|
||||||
if isSpecial(result): return
|
if isSpecial(result): return
|
||||||
else:
|
else:
|
||||||
|
|
@ -373,6 +373,7 @@ proc evalAsgn(c: PEvalContext, n: PNode): PNode =
|
||||||
discardSons(x)
|
discardSons(x)
|
||||||
for i in countup(0, sonsLen(result) - 1): addSon(x, result.sons[i])
|
for i in countup(0, sonsLen(result) - 1): addSon(x, result.sons[i])
|
||||||
result = emptyNode
|
result = emptyNode
|
||||||
|
assert result.kind == nkEmpty
|
||||||
|
|
||||||
proc evalSwap(c: PEvalContext, n: PNode): PNode =
|
proc evalSwap(c: PEvalContext, n: PNode): PNode =
|
||||||
result = evalAux(c, n.sons[0], {efLValue})
|
result = evalAux(c, n.sons[0], {efLValue})
|
||||||
|
|
@ -918,7 +919,7 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
|
||||||
result = evalAux(c, n.sons[2], {efLValue})
|
result = evalAux(c, n.sons[2], {efLValue})
|
||||||
if result.kind == nkExceptBranch: return
|
if result.kind == nkExceptBranch: return
|
||||||
var a = result
|
var a = result
|
||||||
if (k < 0) or (k > ord(high(TNodeKind))):
|
if k < 0 or k > ord(high(TNodeKind)):
|
||||||
internalError(n.info, "request to create a NimNode with invalid kind")
|
internalError(n.info, "request to create a NimNode with invalid kind")
|
||||||
result = newNodeI(TNodeKind(int(k)),
|
result = newNodeI(TNodeKind(int(k)),
|
||||||
if a.kind == nkNilLit: n.info else: a.info)
|
if a.kind == nkNilLit: n.info else: a.info)
|
||||||
|
|
@ -1015,8 +1016,7 @@ proc evalAux(c: PEvalContext, n: PNode, flags: TEvalFlags): PNode =
|
||||||
case n.kind # atoms:
|
case n.kind # atoms:
|
||||||
of nkEmpty: result = n
|
of nkEmpty: result = n
|
||||||
of nkSym: result = evalSym(c, n, flags)
|
of nkSym: result = evalSym(c, n, flags)
|
||||||
of nkType..pred(nkNilLit): result = copyNode(n)
|
of nkType..nkNilLit: result = copyNode(n) # end of atoms
|
||||||
of nkNilLit: result = n # end of atoms
|
|
||||||
of nkCall, nkHiddenCallConv, nkMacroStmt, nkCommand, nkCallStrLit:
|
of nkCall, nkHiddenCallConv, nkMacroStmt, nkCommand, nkCallStrLit:
|
||||||
result = evalMagicOrCall(c, n)
|
result = evalMagicOrCall(c, n)
|
||||||
of nkCurly, nkBracket, nkRange:
|
of nkCurly, nkBracket, nkRange:
|
||||||
|
|
@ -1089,7 +1089,7 @@ proc evalConstExpr(module: PSym, e: PNode): PNode =
|
||||||
s.call = e
|
s.call = e
|
||||||
pushStackFrame(p, s)
|
pushStackFrame(p, s)
|
||||||
result = eval(p, e)
|
result = eval(p, e)
|
||||||
if (result != nil) and (result.kind == nkExceptBranch): result = nil
|
if result != nil and result.kind == nkExceptBranch: result = nil
|
||||||
popStackFrame(p)
|
popStackFrame(p)
|
||||||
|
|
||||||
proc myOpen(module: PSym, filename: string): PPassContext =
|
proc myOpen(module: PSym, filename: string): PPassContext =
|
||||||
|
|
@ -1100,7 +1100,7 @@ proc myOpen(module: PSym, filename: string): PPassContext =
|
||||||
proc myProcess(c: PPassContext, n: PNode): PNode =
|
proc myProcess(c: PPassContext, n: PNode): PNode =
|
||||||
result = eval(PEvalContext(c), n)
|
result = eval(PEvalContext(c), n)
|
||||||
|
|
||||||
proc evalPass(): TPass =
|
proc evalPass*(): TPass =
|
||||||
initPass(result)
|
initPass(result)
|
||||||
result.open = myOpen
|
result.open = myOpen
|
||||||
result.close = myProcess
|
result.close = myProcess
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue