version 0.7.0
This commit is contained in:
parent
972c510861
commit
8b2a9401a1
185 changed files with 21451 additions and 24296 deletions
|
|
@ -7,25 +7,14 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# This file implements the ability to call native procs from libraries.
|
||||
# It is not possible to do this in a platform independant way, unfortunately.
|
||||
# However, the interface has been designed to take platform differences into
|
||||
# account and been ported to all major platforms.
|
||||
#
|
||||
# interface
|
||||
|
||||
type
|
||||
EInvalidLibrary = object of EOS
|
||||
|
||||
when defined(windows) or defined(dos):
|
||||
{.define: USE_DLL.}
|
||||
elif defined(posix):
|
||||
{.define: USE_DLOPEN.}
|
||||
elif defined(mac):
|
||||
{.define: USE_DYLD.}
|
||||
|
||||
type
|
||||
TLibHandle = pointer # private type
|
||||
TProcAddr = pointer # libary loading and loading of procs:
|
||||
|
|
@ -37,15 +26,13 @@ proc nimLoadLibrary(path: string): TLibHandle {.compilerproc.}
|
|||
proc nimUnloadLibrary(lib: TLibHandle) {.compilerproc.}
|
||||
proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr {.compilerproc.}
|
||||
|
||||
#implementation
|
||||
|
||||
# this code was inspired from Lua's source code:
|
||||
# Lua - An Extensible Extension Language
|
||||
# Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
|
||||
# http://www.lua.org
|
||||
# mailto:info@lua.org
|
||||
|
||||
when defined(USE_DLOPEN):
|
||||
when defined(posix):
|
||||
#
|
||||
# =========================================================================
|
||||
# This is an implementation based on the dlfcn interface.
|
||||
|
|
@ -76,7 +63,7 @@ when defined(USE_DLOPEN):
|
|||
proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
|
||||
result = dlsym(lib, name)
|
||||
|
||||
elif defined(USE_DLL):
|
||||
elif defined(windows) or defined(dos):
|
||||
#
|
||||
# =======================================================================
|
||||
# Native Windows Implementation
|
||||
|
|
@ -96,13 +83,13 @@ elif defined(USE_DLL):
|
|||
|
||||
proc nimLoadLibrary(path: string): TLibHandle =
|
||||
result = cast[TLibHandle](winLoadLibrary(path))
|
||||
if result == nil:
|
||||
if result == nil:
|
||||
raise newException(EInvalidLibrary, "could not load: " & path)
|
||||
|
||||
proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr =
|
||||
result = GetProcAddress(cast[THINSTANCE](lib), name)
|
||||
|
||||
elif defined(USE_DYLD):
|
||||
elif defined(mac):
|
||||
#
|
||||
# =======================================================================
|
||||
# Native Mac OS X / Darwin Implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue