diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/pure/algorithm.nim | 4 | ||||
-rw-r--r-- | lib/pure/asyncio.nim | 18 | ||||
-rw-r--r-- | lib/pure/collections/sequtils.nim | 4 | ||||
-rw-r--r-- | lib/pure/events.nim | 13 | ||||
-rwxr-xr-x | lib/pure/httpserver.nim | 3 | ||||
-rwxr-xr-x | lib/pure/streams.nim | 15 | ||||
-rwxr-xr-x | lib/system.nim | 14 | ||||
-rwxr-xr-x | lib/system/gc.nim | 2 | ||||
-rwxr-xr-x | lib/system/hti.nim | 2 | ||||
-rwxr-xr-x | lib/system/threads.nim | 4 | ||||
-rwxr-xr-x | lib/wrappers/gtk/atk.nim | 2 | ||||
-rwxr-xr-x | lib/wrappers/gtk/gdk2.nim | 4 | ||||
-rwxr-xr-x | lib/wrappers/gtk/glib2.nim | 2 | ||||
-rwxr-xr-x | lib/wrappers/libcurl.nim | 2 | ||||
-rwxr-xr-x | lib/wrappers/mysql.nim | 4 | ||||
-rwxr-xr-x | lib/wrappers/opengl/glu.nim | 6 | ||||
-rwxr-xr-x | lib/wrappers/python.nim | 2 | ||||
-rwxr-xr-x | lib/wrappers/sdl/sdl.nim | 1 | ||||
-rwxr-xr-x | lib/wrappers/x11/xresource.nim | 2 |
19 files changed, 57 insertions, 47 deletions
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim index b1064af0d..03eb7da39 100755 --- a/lib/pure/algorithm.nim +++ b/lib/pure/algorithm.nim @@ -56,7 +56,7 @@ const onlySafeCode = true proc merge[T](a, b: var openArray[T], lo, m, hi: int, - cmp: proc (x, y: T): int, order: TSortOrder) = + cmp: proc (x, y: T): int {.closure.}, order: TSortOrder) = template `<-` (a, b: expr) = when false: a = b @@ -102,7 +102,7 @@ proc merge[T](a, b: var openArray[T], lo, m, hi: int, if k < j: copyMem(addr(a[k]), addr(b[i]), sizeof(T)*(j-k)) proc sort*[T](a: var openArray[T], - cmp: proc (x, y: T): int, + cmp: proc (x, y: T): int {.closure.}, order = TSortOrder.Ascending) = ## Default Nimrod sort. The sorting is guaranteed to be stable and ## the worst case is guaranteed to be O(n log n). diff --git a/lib/pure/asyncio.nim b/lib/pure/asyncio.nim index 417a220f9..ac94f2087 100644 --- a/lib/pure/asyncio.nim +++ b/lib/pure/asyncio.nim @@ -33,14 +33,14 @@ type TDelegate = object deleVal*: PObject - handleRead*: proc (h: PObject) - handleWrite*: proc (h: PObject) - handleConnect*: proc (h: PObject) + handleRead*: proc (h: PObject) {.nimcall.} + handleWrite*: proc (h: PObject) {.nimcall.} + handleConnect*: proc (h: PObject) {.nimcall.} - handleAccept*: proc (h: PObject) - getSocket*: proc (h: PObject): tuple[info: TInfo, sock: TSocket] + handleAccept*: proc (h: PObject) {.nimcall.} + getSocket*: proc (h: PObject): tuple[info: TInfo, sock: TSocket] {.nimcall.} - task*: proc (h: PObject) + task*: proc (h: PObject) {.nimcall.} mode*: TMode PDelegate* = ref TDelegate @@ -56,10 +56,10 @@ type userArg: PObject - handleRead*: proc (s: PAsyncSocket, arg: PObject) - handleConnect*: proc (s: PAsyncSocket, arg: PObject) + handleRead*: proc (s: PAsyncSocket, arg: PObject) {.nimcall.} + handleConnect*: proc (s: PAsyncSocket, arg: PObject) {.nimcall.} - handleAccept*: proc (s: PAsyncSocket, arg: PObject) + handleAccept*: proc (s: PAsyncSocket, arg: PObject) {.nimcall.} lineBuffer: TaintedString ## Temporary storage for ``recvLine`` diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim index e3034d635..04eab419b 100644 --- a/lib/pure/collections/sequtils.nim +++ b/lib/pure/collections/sequtils.nim @@ -39,14 +39,14 @@ proc zip*[S, T](seq1: seq[S], seq2: seq[T]): seq[tuple[a: S, b: T]] = newSeq(result, m) for i in 0 .. m-1: result[i] = (seq1[i], seq2[i]) -iterator filter*[T](seq1: seq[T], pred: proc(item: T): bool): T = +iterator filter*[T](seq1: seq[T], pred: proc(item: T): bool {.closure.}): T = ## Iterates through a sequence and yields every item that fulfills the ## predicate. for i in countup(0, len(seq1) -1): var item = seq1[i] if pred(item): yield seq1[i] -proc filter*[T](seq1: seq[T], pred: proc(item: T): bool): seq[T] = +proc filter*[T](seq1: seq[T], pred: proc(item: T): bool {.closure.}): seq[T] = ## Returns all items in a sequence that fulfilled the predicate. accumulateResult(filter(seq1, pred)) diff --git a/lib/pure/events.nim b/lib/pure/events.nim index c3c4cb0dc..894091bf7 100644 --- a/lib/pure/events.nim +++ b/lib/pure/events.nim @@ -11,7 +11,8 @@ ## ## This module implements an event system that is not dependant on external ## graphical toolkits. It was originally called ``NimEE`` because -## it was inspired by Python's PyEE module. There are two ways you can use events: one is a python-inspired way; the other is more of a C-style way. +## it was inspired by Python's PyEE module. There are two ways you can use +## events: one is a python-inspired way; the other is more of a C-style way. ## ## .. code-block:: Nimrod ## var ee = initEventEmitter() @@ -44,22 +45,21 @@ type proc initEventHandler*(name: string): TEventHandler = ## Initializes an EventHandler with the specified name and returns it. - #new(result) result.handlers = @[] result.name = name -proc addHandler*(handler: var TEventHandler, func: proc(e: TEventArgs)) = +proc addHandler*(handler: var TEventHandler, func: proc(e: TEventArgs) {.closure.}) = ## Adds the callback to the specified event handler. handler.handlers.add(func) -proc removeHandler*(handler: var TEventHandler, func: proc(e: TEventArgs)) = +proc removeHandler*(handler: var TEventHandler, func: proc(e: TEventArgs) {.closure.}) = ## Removes the callback from the specified event handler. for i in countup(0, len(handler.handlers) -1): if func == handler.handlers[i]: handler.handlers.del(i) break -proc containsHandler*(handler: var TEventHandler, func: proc(e: TEventArgs)): bool = +proc containsHandler*(handler: var TEventHandler, func: proc(e: TEventArgs) {.closure.}): bool = ## Checks if a callback is registered to this event handler. return handler.handlers.contains(func) @@ -73,7 +73,7 @@ proc getEventhandler(emitter: var TEventEmitter, event: string): int = if emitter.s[k].name == event: return k return -1 -proc on*(emitter: var TEventEmitter, event: string, func: proc(e: TEventArgs)) = +proc on*(emitter: var TEventEmitter, event: string, func: proc(e: TEventArgs) {.closure.}) = ## Assigns a event handler with the specified callback. If the event ## doesn't exist, it will be created. var i = getEventHandler(emitter, event) @@ -99,5 +99,4 @@ proc emit*(emitter: var TEventEmitter, event: string, args: TEventArgs) = proc initEventEmitter*(): TEventEmitter = ## Creates and returns a new EventEmitter. - #new(result) result.s = @[] diff --git a/lib/pure/httpserver.nim b/lib/pure/httpserver.nim index 046844db4..afed45d39 100755 --- a/lib/pure/httpserver.nim +++ b/lib/pure/httpserver.nim @@ -347,7 +347,8 @@ proc close*(s: TServer) = ## closes the server (and the socket the server uses). close(s.socket) -proc run*(handleRequest: proc (client: TSocket, path, query: string): bool, +proc run*(handleRequest: proc (client: TSocket, + path, query: string): bool {.closure.}, port = TPort(80)) = ## encapsulates the server object and main loop var s: TServer diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 78800165a..6e2e19be5 100755 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -23,13 +23,14 @@ type ## here shouldn't be used directly. They are ## accessible so that a stream implementation ## can override them. - closeImpl*: proc (s: PStream) - atEndImpl*: proc (s: PStream): bool - setPositionImpl*: proc (s: PStream, pos: int) - getPositionImpl*: proc (s: PStream): int - readDataImpl*: proc (s: PStream, buffer: pointer, bufLen: int): int - writeDataImpl*: proc (s: PStream, buffer: pointer, bufLen: int) - flushImpl*: proc (s: PStream) + closeImpl*: proc (s: PStream) {.nimcall.} + atEndImpl*: proc (s: PStream): bool {.nimcall.} + setPositionImpl*: proc (s: PStream, pos: int) {.nimcall.} + getPositionImpl*: proc (s: PStream): int {.nimcall.} + readDataImpl*: proc (s: PStream, buffer: pointer, + bufLen: int): int {.nimcall.} + writeDataImpl*: proc (s: PStream, buffer: pointer, bufLen: int) {.nimcall.} + flushImpl*: proc (s: PStream) {.nimcall.} proc flush*(s: PStream) = ## flushes the buffers that the stream `s` might use. diff --git a/lib/system.nim b/lib/system.nim index 6cb99b6cf..6e8fd00b3 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -111,7 +111,7 @@ proc new*[T](a: var ref T) {.magic: "New", noSideEffect.} proc internalNew*[T](a: var ref T) {.magic: "New", noSideEffect.} ## leaked implementation detail. Do not use. -proc new*[T](a: var ref T, finalizer: proc (x: ref T)) {. +proc new*[T](a: var ref T, finalizer: proc (x: ref T) {.nimcall.}) {. magic: "NewFinalize", noSideEffect.} ## creates a new object of type ``T`` and returns a safe (traced) ## reference to it in ``a``. When the garbage collector frees the object, @@ -1416,13 +1416,13 @@ proc pop*[T](s: var seq[T]): T {.inline, noSideEffect.} = result = s[L] setLen(s, L) -proc each*[T, S](data: openArray[T], op: proc (x: T): S): seq[S] = +proc each*[T, S](data: openArray[T], op: proc (x: T): S {.closure.}): seq[S] = ## The well-known ``map`` operation from functional programming. Applies ## `op` to every item in `data` and returns the result as a sequence. newSeq(result, data.len) for i in 0..data.len-1: result[i] = op(data[i]) -proc each*[T](data: var openArray[T], op: proc (x: var T)) = +proc each*[T](data: var openArray[T], op: proc (x: var T) {.closure.}) = ## The well-known ``map`` operation from functional programming. Applies ## `op` to every item in `data`. for i in 0..data.len-1: op(data[i]) @@ -1567,11 +1567,11 @@ const nimrodStackTrace = compileOption("stacktrace") # of the code var - dbgLineHook*: proc () + dbgLineHook*: proc () {.nimcall.} ## set this variable to provide a procedure that should be called before ## each executed instruction. This should only be used by debuggers! ## Only code compiled with the ``debugger:on`` switch calls this hook. - globalRaiseHook*: proc (e: ref E_Base): bool + globalRaiseHook*: proc (e: ref E_Base): bool {.nimcall.} ## with this hook you can influence exception handling on a global level. ## If not nil, every 'raise' statement ends up calling this hook. Ordinary ## application code should never set this hook! You better know what you @@ -1579,7 +1579,7 @@ var ## exception is caught and does not propagate further through the call ## stack. - localRaiseHook* {.threadvar.}: proc (e: ref E_Base): bool + localRaiseHook* {.threadvar.}: proc (e: ref E_Base): bool {.nimcall.} ## with this hook you can influence exception handling on a ## thread local level. ## If not nil, every 'raise' statement ends up calling this hook. Ordinary @@ -1587,7 +1587,7 @@ var ## do when setting this. If ``localRaiseHook`` returns false, the exception ## is caught and does not propagate further through the call stack. - outOfMemHook*: proc () + outOfMemHook*: proc () {.nimcall.} ## set this variable to provide a procedure that should be called ## in case of an `out of memory`:idx: event. The standard handler ## writes an error message and terminates the program. `outOfMemHook` can diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 1c6caeb77..18a7a81ed 100755 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -45,7 +45,7 @@ type TWalkOp = enum waZctDecRef, waPush, waCycleDecRef - TFinalizer {.compilerproc.} = proc (self: pointer) + TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall.} # A ref type can have a finalizer that is called before the object's # storage is freed. diff --git a/lib/system/hti.nim b/lib/system/hti.nim index d79679107..93dc79e3d 100755 --- a/lib/system/hti.nim +++ b/lib/system/hti.nim @@ -62,7 +62,7 @@ type # This should be he same as ast.TTypeKind base: ptr TNimType node: ptr TNimNode # valid for tyRecord, tyObject, tyTuple, tyEnum finalizer: pointer # the finalizer for the type - marker: proc (p: pointer, op: int) # marker proc for GC + marker: proc (p: pointer, op: int) {.nimcall.} # marker proc for GC PNimType = ptr TNimType # node.len may be the ``first`` element of a set diff --git a/lib/system/threads.nim b/lib/system/threads.nim index e0812f41c..0151755c9 100755 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -255,9 +255,9 @@ type ## that **must not** be part of a message! Use ## a ``TThreadId`` for that. when TArg is void: - dataFn: proc () + dataFn: proc () {.nimcall.} else: - dataFn: proc (m: TArg) + dataFn: proc (m: TArg) {.nimcall.} data: TArg TThreadId*[TArg] = ptr TThread[TArg] ## the current implementation uses ## a pointer as a thread ID. diff --git a/lib/wrappers/gtk/atk.nim b/lib/wrappers/gtk/atk.nim index 3ae687aed..f59d95f87 100755 --- a/lib/wrappers/gtk/atk.nim +++ b/lib/wrappers/gtk/atk.nim @@ -419,7 +419,7 @@ type pad32*: TFunction TEventListener* = proc (para1: PObject){.cdecl.} - TEventListenerInitProc* = proc () + TEventListenerInitProc* = proc (){.cdecl.} TEventListenerInit* = proc (para1: TEventListenerInitProc){.cdecl.} PKeyEventStruct* = ptr TKeyEventStruct TKeyEventStruct*{.final, pure.} = object diff --git a/lib/wrappers/gtk/gdk2.nim b/lib/wrappers/gtk/gdk2.nim index 67ee5b15c..d84f7ccc3 100755 --- a/lib/wrappers/gtk/gdk2.nim +++ b/lib/wrappers/gtk/gdk2.nim @@ -291,7 +291,7 @@ type PEvent* = ptr TEvent TEventFunc* = proc (event: PEvent, data: gpointer){.cdecl.} PXEvent* = ptr TXEvent - TXEvent* = proc () + TXEvent* = proc () {.cdecl.} PFilterReturn* = ptr TFilterReturn TFilterReturn* = enum FILTER_CONTINUE, FILTER_TRANSLATE, FILTER_REMOVE @@ -775,7 +775,7 @@ type PWindowObjectClass* = ptr TWindowObjectClass TWindowObjectClass* = object of TDrawableClass window_invalidate_maybe_recurse_child_func* = proc (para1: PWindow, - para2: gpointer): gboolean + para2: gpointer): gboolean {.cdecl.} proc TYPE_COLORMAP*(): GType proc COLORMAP*(anObject: pointer): PColormap diff --git a/lib/wrappers/gtk/glib2.nim b/lib/wrappers/gtk/glib2.nim index 57d561432..4d3d32b29 100755 --- a/lib/wrappers/gtk/glib2.nim +++ b/lib/wrappers/gtk/glib2.nim @@ -2676,7 +2676,7 @@ when false: proc g_critical*(format: cstring){.varargs.} proc g_warning*(format: cstring){.varargs.} type - TGPrintFunc* = proc (str: cstring) + TGPrintFunc* = proc (str: cstring){.cdecl, varargs.} proc g_set_print_handler*(func: TGPrintFunc): TGPrintFunc{.cdecl, dynlib: gliblib, importc: "g_set_print_handler".} diff --git a/lib/wrappers/libcurl.nim b/lib/wrappers/libcurl.nim index 875f1cbc8..bd8616759 100755 --- a/lib/wrappers/libcurl.nim +++ b/lib/wrappers/libcurl.nim @@ -104,7 +104,7 @@ type Tfree_callback* = proc (p: pointer){.cdecl.} Trealloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.} Tstrdup_callback* = proc (str: cstring): cstring{.cdecl.} - Tcalloc_callback* = proc (nmemb: int, size: int): pointer + Tcalloc_callback* = proc (nmemb: int, size: int): pointer{.noconv.} Tinfotype* = enum INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT, INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END diff --git a/lib/wrappers/mysql.nim b/lib/wrappers/mysql.nim index 2a7a10c58..5a8d4c98b 100755 --- a/lib/wrappers/mysql.nim +++ b/lib/wrappers/mysql.nim @@ -8,6 +8,8 @@ # {.deadCodeElim: on.} +{.push, callconv: cdecl.} + when defined(Unix): const lib = "libmysqlclient.so.15" @@ -1071,3 +1073,5 @@ proc INTERNAL_NUM_FIELD(f: Pst_mysql_field): bool = proc reload(mysql: PMySQL): cint = result = refresh(mysql, REFRESH_GRANT) + +{.pop.} diff --git a/lib/wrappers/opengl/glu.nim b/lib/wrappers/opengl/glu.nim index 29edb0df2..e00120d83 100755 --- a/lib/wrappers/opengl/glu.nim +++ b/lib/wrappers/opengl/glu.nim @@ -12,6 +12,11 @@ import GL when defined(windows): + {.push, callconv: stdcall.} +else: + {.push, callconv: cdecl.} + +when defined(windows): const dllname = "glu32.dll" elif defined(macosx): @@ -326,4 +331,5 @@ const # Contours types -- obsolete! GLU_ERROR* = GLU_TESS_ERROR GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG +{.pop.} # implementation diff --git a/lib/wrappers/python.nim b/lib/wrappers/python.nim index 3c5fd46db..3d0b923e2 100755 --- a/lib/wrappers/python.nim +++ b/lib/wrappers/python.nim @@ -1156,7 +1156,7 @@ proc PyWeakref_NewProxy*(ob, callback: PPyObject): PPyObject{.cdecl, importc, dy proc PyWeakref_NewRef*(ob, callback: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} proc PyWrapper_New*(ob1, ob2: PPyObject): PPyObject{.cdecl, importc, dynlib: dllname.} proc PyBool_FromLong*(ok: int): PPyObject{.cdecl, importc, dynlib: dllname.} #- -proc Py_AtExit*(prc: proc ()): int{.cdecl, importc, dynlib: dllname.} #- +proc Py_AtExit*(prc: proc () {.cdecl.}): int{.cdecl, importc, dynlib: dllname.} #- #Py_Cleanup:procedure; cdecl, importc, dynlib: dllname; #- proc Py_CompileString*(s1, s2: cstring, i: int): PPyObject{.cdecl, importc, dynlib: dllname.} #- diff --git a/lib/wrappers/sdl/sdl.nim b/lib/wrappers/sdl/sdl.nim index 597a9b0b0..a6f8de5d7 100755 --- a/lib/wrappers/sdl/sdl.nim +++ b/lib/wrappers/sdl/sdl.nim @@ -1279,7 +1279,6 @@ type # This is the system-independent thread info struc TByteArray* = array[0..32767, int8] PWordArray* = ptr TWordArray TWordArray* = array[0..16383, int16] # Generic procedure pointer - TProcedure* = proc () type TEventSeq = set[TEventKind] template evconv(procName: expr, ptrName: typeDesc, assertions: TEventSeq): stmt {.immediate.} = diff --git a/lib/wrappers/x11/xresource.nim b/lib/wrappers/x11/xresource.nim index ddb2a89c2..f553b4413 100755 --- a/lib/wrappers/x11/xresource.nim +++ b/lib/wrappers/x11/xresource.nim @@ -137,7 +137,7 @@ const XrmEnumOneLevel* = 1 type - funcbool* = proc (): TBool + funcbool* = proc (): TBool {.cdecl.} proc XrmEnumerateDatabase*(para1: TXrmDatabase, para2: TXrmNameList, para3: TXrmClassList, para4: int32, para5: funcbool, |