-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathffi.lua
104 lines (95 loc) · 3.7 KB
/
ffi.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- Do not change this file manually
-- Generated with dev/create-ffi.lua
-- Tracekback (error printout)
local function traceback(message)
local tp = type(message)
if tp ~= "string" and tp ~= "number" then return message end
local debug = _G.debug
if type(debug) ~= "table" then return message end
local tb = debug.traceback
if type(tb) ~= "function" then return message end
return tb(message)
end
local ffi = require 'ffi'
local C
local ok, err = xpcall(function() C = ffi.load('matio') end, traceback)
if not ok then
if ffi.os == 'Linux' then
ok, err = xpcall(function() C = ffi.load('libmatio.so.2') end, traceback)
end
if not ok then
print(err)
error('Could not find libmatio. ' ..
'Please make sure that you installd MatIO and you ' ..
'have the shared libraries (libmatio.so or libmatio.dylib) '
.. 'in your library path')
end
end
local mat = {C=C}
require 'matio.cdefs'
local defines = require 'matio.defines'
defines.register_hashdefs(mat, C)
local function register(luafuncname, funcname)
local symexists, msg = pcall(function()
local sym = C[funcname]
end)
if symexists then
mat[luafuncname] = C[funcname]
end
end
register('getLibraryVersion', 'Mat_GetLibraryVersion')
register('setVerbose', 'Mat_SetVerbose')
register('setDebug', 'Mat_SetDebug')
register('critical', 'Mat_Critical')
register('error', 'Mat_Error')
register('help', 'Mat_Help')
register('logInit', 'Mat_LogInit')
register('logClose', 'Mat_LogClose')
register('logInitFunc', 'Mat_LogInitFunc')
register('message', 'Mat_Message')
register('debugMessage', 'Mat_DebugMessage')
register('verbMessage', 'Mat_VerbMessage')
register('warning', 'Mat_Warning')
register('sizeOf', 'Mat_SizeOf')
register('sizeOfClass', 'Mat_SizeOfClass')
register('createVer', 'Mat_CreateVer')
register('close', 'Mat_Close')
register('open', 'Mat_Open')
register('getFilename', 'Mat_GetFilename')
register('getVersion', 'Mat_GetVersion')
register('rewind', 'Mat_Rewind')
register('varCalloc', 'Mat_VarCalloc')
register('varCreate', 'Mat_VarCreate')
register('varCreateStruct', 'Mat_VarCreateStruct')
register('varDelete', 'Mat_VarDelete')
register('varDuplicate', 'Mat_VarDuplicate')
register('varFree', 'Mat_VarFree')
register('varGetCell', 'Mat_VarGetCell')
register('varGetCells', 'Mat_VarGetCells')
register('varGetCellsLinear', 'Mat_VarGetCellsLinear')
register('varGetSize', 'Mat_VarGetSize')
register('varGetNumberOfFields', 'Mat_VarGetNumberOfFields')
register('varAddStructField', 'Mat_VarAddStructField')
register('varGetStructFieldnames', 'Mat_VarGetStructFieldnames')
register('varGetStructFieldByIndex', 'Mat_VarGetStructFieldByIndex')
register('varGetStructFieldByName', 'Mat_VarGetStructFieldByName')
register('varGetStructField', 'Mat_VarGetStructField')
register('varGetStructs', 'Mat_VarGetStructs')
register('varGetStructsLinear', 'Mat_VarGetStructsLinear')
register('varPrint', 'Mat_VarPrint')
register('varRead', 'Mat_VarRead')
register('varReadData', 'Mat_VarReadData')
register('varReadDataAll', 'Mat_VarReadDataAll')
register('varReadDataLinear', 'Mat_VarReadDataLinear')
register('varReadInfo', 'Mat_VarReadInfo')
register('varReadNext', 'Mat_VarReadNext')
register('varReadNextInfo', 'Mat_VarReadNextInfo')
register('varSetCell', 'Mat_VarSetCell')
register('varSetStructFieldByIndex', 'Mat_VarSetStructFieldByIndex')
register('varSetStructFieldByName', 'Mat_VarSetStructFieldByName')
register('varWrite', 'Mat_VarWrite')
register('varWriteInfo', 'Mat_VarWriteInfo')
register('varWriteData', 'Mat_VarWriteData')
register('calcSingleSubscript', 'Mat_CalcSingleSubscript')
register('calcSubscripts', 'Mat_CalcSubscripts')
return mat