ffi: canonical static access ffi::load (module namespace)
- '::' accesses a static/class member (here the module namespace ffi), '.'/':' sends to an instance. ffi is a module, so ffi::load is the canonical form; the native now accepts the receiver passed by '::'. - example, tests and README use ffi::load; '.load' still works (compat). - 69/69 tests
This commit is contained in:
1 parent
05f31aed68
commit
4dae4ee1cd
4 files changed
+28
-10
No files matched your search
+2
-2
@@ -3,14 +3,14 @@
|
||||
-- Like Python's ctypes/CDLL: load a shared object, bind a symbol with a
|
||||
-- signature, and call it. libffi performs the ABI-correct call.
|
||||
|
||||
local m = ffi.load("libm.so.6")
|
||||
local m = ffi::load("libm.so.6")
|
||||
local pow = m:func("pow", "double(double,double)")
|
||||
print("pow(2,10) =", pow(2, 10))
|
||||
|
||||
local sqrt = m:func("sqrt", "double(double)")
|
||||
print("sqrt(144) =", sqrt(144))
|
||||
|
||||
local c = ffi.load("libc.so.6")
|
||||
local c = ffi::load("libc.so.6")
|
||||
local getpid = c:func("getpid", "int()")
|
||||
local pid = getpid()
|
||||
print("getpid > 0:", pid > 0)
|
||||
|
||||
Reference in new issue
Block a user