Skip to content

Commit

Permalink
more fixes for dy(n)lib typo; fixes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Mar 8, 2011
1 parent 6d46609 commit 9b372f4
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 101 deletions.
4 changes: 2 additions & 2 deletions doc/c2nim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ from a C function prototype with the ``dynlib`` pragma:
# if defined(windows)
# define iupdll "iup.dll"
# elif defined(macosx)
# define iupdll "libiup.dynlib"
# define iupdll "libiup.dylib"
# else
# define iupdll "libiup.so"
# endif
Expand All @@ -133,7 +133,7 @@ Is translated to:
when defined(windows):
const iupdll* = "iup.dll"
elif defined(macosx):
const iupdll* = "libiup.dynlib"
const iupdll* = "libiup.dylib"
else:
const iupdll* = "libiup.so"

Expand Down
2 changes: 1 addition & 1 deletion lib/impure/graphics.nim
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ proc ipart(x: float): float = return x.trunc()
proc fpart(x: float): float = return x - ipart(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
## line algorithm
var (x1, x2, y1, y2) = (p1.x.toFloat(), p2.x.toFloat(),
Expand Down
13 changes: 7 additions & 6 deletions lib/pure/xmldom.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const
DocumentFragmentNode* = 11

# Nodes which are childless - Not sure about AttributeNode
childlessObjects = {DocumentNode, AttributeNode, TextNode, CDataSectionNode, ProcessingInstructionNode, CommentNode}
childlessObjects = {DocumentNode, AttributeNode, TextNode,
CDataSectionNode, ProcessingInstructionNode, CommentNode}
# Illegal characters
illegalChars = {'>', '<', '&', '"'}

Expand Down Expand Up @@ -73,7 +74,7 @@ type
Element = object of Node
FTagName: string # Read-only

PCharacterData = ref CharacterData
PCharacterData* = ref CharacterData
CharacterData = object of Node
data*: string

Expand Down Expand Up @@ -109,10 +110,10 @@ type
# DOMImplementation
proc getDOM*(): PDOMImplementation =
## Returns a DOMImplementation
var DOMImpl: PDOMImplementation
new(DOMImpl)
DOMImpl.Features = @[(name: "core", version: "2.0"), (name: "core", version: "1.0"), (name: "XML", version: "2.0")]
return DOMImpl
new(result)
result.Features = @[(name: "core", version: "2.0"),
(name: "core", version: "1.0"),
(name: "XML", version: "2.0")]

proc createDocument*(dom: PDOMImplementation, namespaceURI: string, qualifiedName: string): PDocument =
## Creates an XML Document object of the specified type with its document element.
Expand Down
86 changes: 43 additions & 43 deletions lib/windows/windows.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22741,144 +22741,144 @@ proc AnsiLowerBuff*(lpsz: LPSTR, cchLength: DWORD): DWORD{.stdcall,

# WinBase.h

proc FreeModule(h: HINST): WINBOOL =
proc FreeModule*(h: HINST): WINBOOL =
result = FreeLibrary(h)

proc MakeProcInstance(p, i: pointer): pointer =
proc MakeProcInstance*(p, i: pointer): pointer =
result = p

proc FreeProcInstance(p: pointer): pointer =
proc FreeProcInstance*(p: pointer): pointer =
result = p

proc GlobalDiscard(hglbMem: HGLOBAL): HGLOBAL =
proc GlobalDiscard*(hglbMem: HGLOBAL): HGLOBAL =
result = GlobalReAlloc(hglbMem, 0, GMEM_MOVEABLE)

proc LocalDiscard(hlocMem: HLOCAL): HLOCAL =
proc LocalDiscard*(hlocMem: HLOCAL): HLOCAL =
result = LocalReAlloc(hlocMem, 0, LMEM_MOVEABLE)

# WinGDI.h

proc GetGValue(rgb: int32): int8 =
proc GetGValue*(rgb: int32): int8 =
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)
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

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)

proc PALETTEINDEX(i: DWORD): COLORREF =
proc PALETTEINDEX*(i: DWORD): COLORREF =
result = COLORREF(0x01000000'i32 or i and 0xffff'i32)


proc GetRValue(rgb: COLORREF): int8 =
proc GetRValue*(rgb: COLORREF): int8 =
result = toU8(rgb)

proc GetGValue(rgb: COLORREF): int8 =
proc GetGValue*(rgb: COLORREF): int8 =
result = toU8(rgb shr 8)

proc GetBValue(rgb: COLORREF): int8 =
proc GetBValue*(rgb: COLORREF): int8 =
result = toU8(rgb shr 16)

#

proc HIBYTE(w: int32): int8 =
proc HIBYTE*(w: int32): int8 =
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)

proc LOBYTE(w: int32): int8 =
proc LOBYTE*(w: int32): int8 =
result = toU8(w)

proc LOWORD(L: int32): int16 =
proc LOWORD*(L: int32): int16 =
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

proc MAKEWORD(a, b: int32): int16 =
proc MAKEWORD*(a, b: int32): int16 =
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
result = HIWORD(L)

proc ZEXT_HIWORD(L: int32): int32 =
proc ZEXT_HIWORD*(L: int32): int32 =
# return type might be wrong
result = ze(HIWORD(L))

proc SEXT_LOWORD(L: int32): int32 =
proc SEXT_LOWORD*(L: int32): int32 =
result = LOWORD(L)

proc INDEXTOOVERLAYMASK(i: int32): int32 =
proc INDEXTOOVERLAYMASK*(i: int32): int32 =
# return type might be wrong
result = i shl 8'i32

proc INDEXTOSTATEIMAGEMASK(i: int32): int32 =
proc INDEXTOSTATEIMAGEMASK*(i: int32): int32 =
# return type might be wrong
result = i shl 12'i32

proc MAKEINTATOM(i: int32): LPTSTR =
proc MAKEINTATOM*(i: int32): LPTSTR =
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
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

proc SUBLANGID(lgid: int32): int32 =
proc SUBLANGID*(lgid: int32): int32 =
# return type might be wrong
result = toU16(lgid) shr 10'i16

proc LANGIDFROMLCID(lcid: int32): int16 =
proc LANGIDFROMLCID*(lcid: int32): int16 =
result = toU16(lcid)

proc SORTIDFROMLCID(lcid: int32): int16 =
proc SORTIDFROMLCID*(lcid: int32): int16 =
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)

proc MAKELPARAM(L, h: int32): LPARAM =
proc MAKELPARAM*(L, h: int32): LPARAM =
result = LPARAM(MAKELONG(L, h))

proc MAKELRESULT(L, h: int32): LRESULT =
proc MAKELRESULT*(L, h: int32): LRESULT =
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

proc MAKEWPARAM(L, h: int32): WPARAM =
proc MAKEWPARAM*(L, h: int32): WPARAM =
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))

proc GET_Y_LPARAM(lp: Windows.LParam): int32 =
proc GET_Y_LPARAM*(lp: Windows.LParam): int32 =
result = int16(HIWORD(lp))

proc UNICODE_NULL(): WCHAR =
proc UNICODE_NULL*(): WCHAR =
result = 0'i16



proc GetFirstChild(h: HWND): HWND =
proc GetFirstChild*(h: HWND): HWND =
result = GetTopWindow(h)

proc GetNextSibling(h: HWND): HWND =
proc GetNextSibling*(h: HWND): HWND =
result = GetWindow(h, GW_HWNDNEXT)

proc GetWindowID(h: HWND): int32 =
proc GetWindowID*(h: HWND): int32 =
result = GetDlgCtrlID(h)

proc SubclassWindow(h: HWND, p: LONG): LONG =
proc SubclassWindow*(h: HWND, p: LONG): LONG =
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
result = HIWORD(w)

Expand Down
9 changes: 5 additions & 4 deletions lib/wrappers/cairo/cairo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@
#

when defined(windows):
const
LIB_CAIRO* = "libcairo-2.dll"
const LIB_CAIRO* = "libcairo-2.dll"
elif defined(macosx):
const LIB_CAIRO* = "libcairo.dylib"
else:
const
LIB_CAIRO* = "libcairo.so"
const LIB_CAIRO* = "libcairo.so"

type
PByte = cstring
TStatus* = enum
Expand Down
3 changes: 3 additions & 0 deletions lib/wrappers/gtk/atk.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import
when defined(windows):
const
lib = "libatk-1.0-0.dll"
elif defined(macosx):
const
lib = "libatk-1.0.dylib"
else:
const
lib = "libatk-1.0.so"
Expand Down
4 changes: 2 additions & 2 deletions lib/wrappers/gtk/gdk2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import
when defined(win32):
const
lib = "libgdk-win32-2.0-0.dll"
elif defined(darwin):
elif defined(macosx):
# linklib gtk-x11-2.0
# linklib gdk-x11-2.0
# linklib pango-1.0.0
Expand All @@ -14,7 +14,7 @@ elif defined(darwin):
# linklib gdk_pixbuf-2.0.0
# linklib atk-1.0.0
const
lib = "gdk-x11-2.0"
lib = "libgdk-x11-2.0.dylib"
else:
const
lib = "libgdk-x11-2.0.so(|.0)"
Expand Down
4 changes: 2 additions & 2 deletions lib/wrappers/gtk/gdk2pixbuf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import
when defined(win32):
const
pixbuflib = "libgdk_pixbuf-2.0-0.dll"
elif defined(darwin):
elif defined(macosx):
const
pixbuflib = "gdk_pixbuf-2.0.0"
pixbuflib = "libgdk_pixbuf-2.0.0.dylib"
# linklib gtk-x11-2.0
# linklib gdk-x11-2.0
# linklib pango-1.0.0
Expand Down
3 changes: 3 additions & 0 deletions lib/wrappers/gtk/gdkglext.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import
when defined(WIN32):
const
GLExtLib = "libgdkglext-win32-1.0-0.dll"
elif defined(macosx):
const
GLExtLib = "libgdkglext-x11-1.0.dylib"
else:
const
GLExtLib = "libgdkglext-x11-1.0.so"
Expand Down
5 changes: 5 additions & 0 deletions lib/wrappers/gtk/glib2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ when defined(windows):
gliblib = "libglib-2.0-0.dll"
gmodulelib = "libgmodule-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:
const
gliblib = "libglib-2.0.so(|.0)"
Expand Down
4 changes: 2 additions & 2 deletions lib/wrappers/gtk/gtk2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import
when defined(win32):
const
lib = "libgtk-win32-2.0-0.dll"
elif defined(darwin):
elif defined(macosx):
const
lib = "gtk-x11-2.0"
lib = "libgtk-x11-2.0.dylib"
# linklib gtk-x11-2.0
# linklib gdk-x11-2.0
# linklib pango-1.0.0
Expand Down
11 changes: 9 additions & 2 deletions lib/wrappers/gtk/gtkglext.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
import
Glib2, Gdk2, gtk2, GdkGLExt

const
GLExtLib* = if defined(WIN32): "libgtkglext-win32-1.0-0.dll" else: "libgtkglext-x11-1.0.so"
when defined(windows):
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
HEADER_GTKGLEXT_MAJOR_VERSION* = 1
Expand Down
4 changes: 3 additions & 1 deletion lib/wrappers/gtk/gtkhtml.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import
gtk2, glib2, atk, pango, gdk2pixbuf, gdk2

when defined(windows):
{.define: WINDOWING_WIN32.}
const
htmllib = "libgtkhtml-win32-2.0-0.dll"
elif defined(macosx):
const
htmllib = "libgtkhtml-2.dylib"
else:
const
htmllib = "libgtkhtml-2.so"
Expand Down
3 changes: 3 additions & 0 deletions lib/wrappers/gtk/libglade2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import
when defined(win32):
const
LibGladeLib = "libglade-2.0-0.dll"
elif defined(macosx):
const
LibGladeLib = "libglade-2.0.dylib"
else:
const
LibGladeLib = "libglade-2.0.so"
Expand Down
3 changes: 3 additions & 0 deletions lib/wrappers/gtk/pango.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import
when defined(win32):
const
lib* = "libpango-1.0-0.dll"
elif defined(macosx):
const
lib* = "libpango-1.0.dylib"
else:
const
lib* = "libpango-1.0.so.0"
Expand Down
Loading

0 comments on commit 9b372f4

Please sign in to comment.