comparison lua/luadyncall/src/dyncall.lua @ 0:0cfcc391201f

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:26:28 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0cfcc391201f
1 require "ldyncall"
2 require "dynload"
3
4 --- invoke dynamic foreign function call
5 -- This is a front-end function that provides several interfaces
6 -- @param target Target signature
7 -- @param ... if target is a string, then the arguments follow.
8 -- @see dodyncall for details
9
10 function dyncall(target, ...)
11 local t = type(target)
12 if t == "string" then
13 local libnames, sym, sig = target:match("^@(.+)/(.+)%((.+)")
14 local lib = dynload(libnames) -- hold reference as long as the call
15 return ldyncall.dodyncall( dynsym( lib,sym ), sig, ...)
16 else
17 return ldyncall.dodyncall( target, ...)
18 end
19 end
20
21 -- pointer utilities
22 --
23
24 topointer = ldyncall.topointer
25 NULL = topointer(0)
26
27