Fully replace bindgen.py with bindgen2.py #25

Merged
MartinFouilleul merged 2 commits from bindgen2_all_apis into main 2023-07-29 10:22:20 +00:00
8 changed files with 669 additions and 368 deletions
Showing only changes of commit 71236240ab - Show all commits

View File

@ -36,21 +36,23 @@ if %target% == orca (
copy %pthread_dir%\bin\pthreadVC3.dll bin copy %pthread_dir%\bin\pthreadVC3.dll bin
::generate wasm3 api bindings ::generate wasm3 api bindings
python3 scripts\bindgen.py core src python3 scripts\bindgen.py core src\core_api.json^
--wasm3-bindings src\core_api_bind_gen.c
python3 scripts\bindgen.py gles src python3 scripts\bindgen.py gles src\gles_api.json^
--wasm3-bindings src\gles_api_bind_gen.c
python3 scripts\bindgen2.py canvas src\canvas_api.json^ python3 scripts\bindgen.py canvas src\canvas_api.json^
--guest-stubs sdk\orca_surface.c^ --guest-stubs sdk\orca_surface.c^
--guest-include graphics.h^ --guest-include graphics.h^
--wasm3-bindings src\canvas_api_bind_gen.c --wasm3-bindings src\canvas_api_bind_gen.c
python3 scripts\bindgen2.py clock src\clock_api.json^ python3 scripts\bindgen.py clock src\clock_api.json^
--guest-stubs sdk\orca_clock.c^ --guest-stubs sdk\orca_clock.c^
--guest-include platform_clock.h^ --guest-include platform_clock.h^
--wasm3-bindings src\clock_api_bind_gen.c --wasm3-bindings src\clock_api_bind_gen.c
python3 scripts\bindgen2.py io^ python3 scripts\bindgen.py io^
src\io_api.json^ src\io_api.json^
--guest-stubs sdk\io_stubs.c^ --guest-stubs sdk\io_stubs.c^
--wasm3-bindings src\io_api_bind_gen.c --wasm3-bindings src\io_api_bind_gen.c

View File

@ -1,131 +1,201 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
if len(sys.argv) < 2: from argparse import ArgumentParser
print("bindgen require an api name\n") import json
exit(-1);
apiName = sys.argv[1] parser = ArgumentParser(prog='bindgen.py')
cdir = '' parser.add_argument('api')
parser.add_argument('spec')
parser.add_argument('-g', '--guest-stubs')
parser.add_argument('--guest-include')
parser.add_argument('--wasm3-bindings')
if len(sys.argv) > 2: args = parser.parse_args()
cdir = sys.argv[2]
inPath = cdir + '/bindgen_' + apiName + '_api.txt' apiName = args.api
outPath = cdir + '/bindgen_' + apiName + '_api.c' spec = args.spec
guest_stubs_path = args.guest_stubs
if guest_stubs_path == None:
guest_stubs_path = 'bindgen_' + apiName + '_guest_stubs.c'
inFile = open(inPath, 'r') wasm3_bindings_path = args.wasm3_bindings
outFile = open(outPath, 'w') if wasm3_bindings_path == None:
wasm3_bindings_path = 'bindgen_' + apiName + '_wasm3_bindings.c'
stubs = [] host_bindings = open(wasm3_bindings_path, 'w')
links = [] guest_bindings = None
def gen_stub(name, sig, native_name): specFile = open(spec, 'r')
if native_name == None: data = json.load(specFile)
native_name = name
src = 'const void* ' + name + '_stub(IM3Runtime runtime, IM3ImportContext _ctx, uint64_t * _sp, void * _mem)\n' def needs_arg_ptr_stub(decl):
src += '{\n' res = (decl['ret']['tag'] == 'S')
spIndex = 0 for arg in decl['args']:
if arg['type']['tag'] == 'S':
res = True
return(res)
parsingRet = True for decl in data:
retCount = 0 if needs_arg_ptr_stub(decl):
argCount = 0 guest_bindings = open(guest_stubs_path, 'w')
retString = '' if args.guest_include != None:
argString = '' s = '#include"' + args.guest_include + '"\n\n'
print(s, file=guest_bindings)
for index, c in enumerate(sig):
if parsingRet:
if retCount > 1:
print('unsupported multiple return types\n')
break
if c == '(':
parsingRet = False
continue
elif c == ')':
print('unexpected ) while parsing return type\n')
break;
elif c == 'v':
continue
elif c == 'i':
retString = '*((i32*)&_sp[0]) = '
elif c == 'I':
retString = '*((i64*)&_sp[0]) = '
elif c == 'f':
retString = '*((f32*)&_sp[0]) = '
elif c == 'F':
retString = '*((f64*)&_sp[0]) = '
elif c == 'p':
print('returning pointers is not supported yet\n')
break break
for decl in data:
name = decl['name']
cname = decl.get('cname', name)
if needs_arg_ptr_stub(decl):
argPtrStubName = name + '_argptr_stub'
# pointer arg stub declaration
s = ''
if decl['ret']['tag'] == 'S':
s += 'void'
else: else:
print('unrecognized type ' + c + ' in procedure return\n') s += decl['ret']['name']
break
retCount += 1 s += ' ORCA_IMPORT(' + argPtrStubName + ') ('
if decl['ret']['tag'] == 'S':
s += decl['ret']['name'] + '* __retArg'
if len(decl['args']) > 0:
s += ', '
for i, arg in enumerate(decl['args']):
s += arg['type']['name']
if arg['type']['tag'] == 'S':
s += '*'
s += ' ' + arg['name']
if i+1 < len(decl['args']):
s += ', '
s += ');\n\n'
# forward function to pointer arg stub declaration
s += decl['ret']['name'] + ' ' + name + '('
for i, arg in enumerate(decl['args']):
s += arg['type']['name'] + ' ' + arg['name']
if i+1 < len(decl['args']):
s += ', '
s += ')\n'
s += '{\n'
s += '\t'
if decl['ret']['tag'] == 'S':
s += decl['ret']['name'] + ' __ret;\n\t'
elif decl['ret']['tag'] != 'v':
s += decl['ret']['name']
s += ' __ret = '
s += argPtrStubName + '('
if decl['ret']['tag'] == 'S':
s += '&__ret'
if len(decl['args']) > 0:
s += ', '
for i, arg in enumerate(decl['args']):
if arg['type']['tag'] == 'S':
s += '&'
s += arg['name']
if i+1 < len(decl['args']):
s += ', '
s += ');\n'
if decl['ret']['tag'] != 'v':
s += '\treturn(__ret);\n'
s += '}\n\n'
print(s, file=guest_bindings)
# host-side stub
s = 'const void* ' + cname + '_stub(IM3Runtime runtime, IM3ImportContext _ctx, uint64_t* _sp, void* _mem)'
gen_stub = decl.get('gen_stub', True)
if gen_stub == False:
s += ';\n\n'
else: else:
argIndex = argCount + retCount s += '\n{\n\t'
if c == ')': retTag = decl['ret']['tag']
break
elif c == 'v': if retTag == 'i':
break s += '*((i32*)&_sp[0]) = '
elif c == 'i': elif retTag == 'I':
argString += '*(i32*)&_sp[' + str(argIndex) + ']' s += '*((i64*)&_sp[0]) = '
elif c == 'I': elif retTag == 'f':
argString += '*(i64*)&_sp[' + str(argIndex) + ']' s += '*((f32*)&_sp[0]) = '
elif c == 'f': elif retTag == 'F':
argString += '*(f32*)&_sp[' + str(argIndex) + ']' s += '*((f64*)&_sp[0]) = '
elif c == 'F': elif retTag == 'S':
argString += '*(f64*)&_sp[' + str(argIndex) + ']' retTypeName = decl['ret']['name']
elif c == 'p': retTypeCName = decl['ret'].get('cname', retTypeName)
argString += '(void*)((char*)_mem + *(i32*)&_sp[' + str(argIndex) + '])' s += '*(' + retTypeCName + '*)((char*)_mem + *(i32*)&_sp[0]) = '
s += cname + '('
firstArgIndex = 0
if retTag != 'v':
firstArgIndex = 1
for i, arg in enumerate(decl['args']):
typeName = arg['type']['name']
typeCName = arg['type'].get('cname', typeName)
argTag = arg['type']['tag']
if argTag == 'i':
s += '*(i32*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'I':
s += '*(i64*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'f':
s += '*(f32*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'F':
s += '*(f64*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'p':
s += '(void*)((char*)_mem + *(i32*)&_sp[' + str(firstArgIndex + i) + '])'
elif argTag == 'S':
s += '*(' + typeCName + '*)((char*)_mem + *(i32*)&_sp[' + str(firstArgIndex + i) + '])'
else: else:
print('unrecognized type ' + c + ' in procedure signature\n') print('unrecognized type ' + c + ' in procedure signature\n')
break break
if index+2 < len(sig): if i+1 < len(decl['args']):
argString += ', ' s += ', '
argCount += 1
src += '\t' + retString + native_name + '(' + argString + ');\n' s += ');\n\treturn(0);\n}\n\n'
src += '\treturn(0);\n'
src += '}\n'
stubs.append(src)
def gen_link(name, sig): print(s, file=host_bindings)
m3_Sig = ''
for c in sig: # link function
if c == 'p': s = 'int bindgen_link_' + apiName + '_api(IM3Module module)\n{\n\t'
m3_Sig += 'i' s += 'M3Result res;\n'
for decl in data:
name = decl['name']
cname = decl.get('cname', name)
if needs_arg_ptr_stub(decl):
name = name + '_argptr_stub'
m3Sig = ''
if decl['ret']['tag'] == 'S':
m3Sig += 'v'
else: else:
m3_Sig += c m3Sig += decl['ret']['tag']
src = '\tres = m3_LinkRawFunction(module, "*", "' + name + '", "' + m3_Sig + '", ' + name + '_stub);\n' m3Sig += '('
src += '\tif(res != m3Err_none && res != m3Err_functionLookupFailed) { log_error("error: %s\\n", res); return(-1); }\n\n' if decl['ret']['tag'] == 'S':
links.append(src) m3Sig += 'i'
for arg in decl['args']:
tag = arg['type']['tag']
if tag == 'p' or tag == 'S':
tag = 'i'
m3Sig += tag
m3Sig += ')'
for line in inFile:
if line.isspace():
continue
desc = line.split()
gen_stub(desc[0], desc[1], desc[2] if len(desc) > 2 else None) s += '\tres = m3_LinkRawFunction(module, "*", "' + name + '", "' + m3Sig + '", ' + cname + '_stub);\n'
gen_link(desc[0], desc[1]) s += '\tif(res != m3Err_none && res != m3Err_functionLookupFailed) { log_error("error: %s\\n", res); return(-1); }\n\n'
linkProc = 'int bindgen_link_' + apiName + '_api(IM3Module module)\n'
linkProc += '{\n'
linkProc += '\tM3Result res;\n'
for link in links: s += '\treturn(0);\n}\n'
linkProc += link
linkProc += '\treturn(0);\n' print(s, file=host_bindings)
linkProc += '}\n'
for stub in stubs:
outFile.write(stub)
outFile.write('\n')
outFile.write(linkProc)
inFile.close()
outFile.close()

View File

@ -1,201 +0,0 @@
#!/usr/bin/env python3
from argparse import ArgumentParser
import json
parser = ArgumentParser(prog='bindgen.py')
parser.add_argument('api')
parser.add_argument('spec')
parser.add_argument('-g', '--guest-stubs')
parser.add_argument('--guest-include')
parser.add_argument('--wasm3-bindings')
args = parser.parse_args()
apiName = args.api
spec = args.spec
guest_stubs_path = args.guest_stubs
if guest_stubs_path == None:
guest_stubs_path = 'bindgen_' + apiName + '_guest_stubs.c'
wasm3_bindings_path = args.wasm3_bindings
if wasm3_bindings_path == None:
wasm3_bindings_path = 'bindgen_' + apiName + '_wasm3_bindings.c'
host_bindings = open(wasm3_bindings_path, 'w')
guest_bindings = None
specFile = open(spec, 'r')
data = json.load(specFile)
def needs_arg_ptr_stub(decl):
res = (decl['ret']['tag'] == 'S')
for arg in decl['args']:
if arg['type']['tag'] == 'S':
res = True
return(res)
for decl in data:
if needs_arg_ptr_stub(decl):
guest_bindings = open(guest_stubs_path, 'w')
if args.guest_include != None:
s = '#include"' + args.guest_include + '"\n\n'
print(s, file=guest_bindings)
break
for decl in data:
name = decl['name']
cname = decl.get('cname', name)
if needs_arg_ptr_stub(decl):
argPtrStubName = name + '_argptr_stub'
# pointer arg stub declaration
s = ''
if decl['ret']['tag'] == 'S':
s += 'void'
else:
s += decl['ret']['name']
s += ' ORCA_IMPORT(' + argPtrStubName + ') ('
if decl['ret']['tag'] == 'S':
s += decl['ret']['name'] + '* __retArg'
if len(decl['args']) > 0:
s += ', '
for i, arg in enumerate(decl['args']):
s += arg['type']['name']
if arg['type']['tag'] == 'S':
s += '*'
s += ' ' + arg['name']
if i+1 < len(decl['args']):
s += ', '
s += ');\n\n'
# forward function to pointer arg stub declaration
s += decl['ret']['name'] + ' ' + name + '('
for i, arg in enumerate(decl['args']):
s += arg['type']['name'] + ' ' + arg['name']
if i+1 < len(decl['args']):
s += ', '
s += ')\n'
s += '{\n'
s += '\t'
if decl['ret']['tag'] == 'S':
s += decl['ret']['name'] + ' __ret;\n\t'
elif decl['ret']['tag'] != 'v':
s += decl['ret']['name']
s += ' __ret = '
s += argPtrStubName + '('
if decl['ret']['tag'] == 'S':
s += '&__ret'
if len(decl['args']) > 0:
s += ', '
for i, arg in enumerate(decl['args']):
if arg['type']['tag'] == 'S':
s += '&'
s += arg['name']
if i+1 < len(decl['args']):
s += ', '
s += ');\n'
if decl['ret']['tag'] != 'v':
s += '\treturn(__ret);\n'
s += '}\n\n'
print(s, file=guest_bindings)
# host-side stub
s = 'const void* ' + cname + '_stub(IM3Runtime runtime, IM3ImportContext _ctx, uint64_t* _sp, void* _mem)'
gen_stub = decl.get('gen_stub', True)
if gen_stub == False:
s += ';\n\n'
else:
s += '\n{\n\t'
retTag = decl['ret']['tag']
if retTag == 'i':
s += '*((i32*)&_sp[0]) = '
elif retTag == 'I':
s += '*((i64*)&_sp[0]) = '
elif retTag == 'f':
s += '*((f32*)&_sp[0]) = '
elif retTag == 'F':
s += '*((f64*)&_sp[0]) = '
elif retTag == 'S':
retTypeName = decl['ret']['name']
retTypeCName = decl['ret'].get('cname', retTypeName)
s += '*(' + retTypeCName + '*)((char*)_mem + *(i32*)&_sp[0]) = '
s += cname + '('
firstArgIndex = 0
if retTag != 'v':
firstArgIndex = 1
for i, arg in enumerate(decl['args']):
typeName = arg['type']['name']
typeCName = arg['type'].get('cname', typeName)
argTag = arg['type']['tag']
if argTag == 'i':
s += '*(i32*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'I':
s += '*(i64*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'f':
s += '*(f32*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'F':
s += '*(f64*)&_sp[' + str(firstArgIndex + i) + ']'
elif argTag == 'p':
s += '(void*)((char*)_mem + *(i32*)&_sp[' + str(firstArgIndex + i) + '])'
elif argTag == 'S':
s += '*(' + typeCName + '*)((char*)_mem + *(i32*)&_sp[' + str(firstArgIndex + i) + '])'
else:
print('unrecognized type ' + c + ' in procedure signature\n')
break
if i+1 < len(decl['args']):
s += ', '
s += ');\n\treturn(0);\n}\n\n'
print(s, file=host_bindings)
# link function
s = 'int bindgen_link_' + apiName + '_api(IM3Module module)\n{\n\t'
s += 'M3Result res;\n'
for decl in data:
name = decl['name']
cname = decl.get('cname', name)
if needs_arg_ptr_stub(decl):
name = name + '_argptr_stub'
m3Sig = ''
if decl['ret']['tag'] == 'S':
m3Sig += 'v'
else:
m3Sig += decl['ret']['tag']
m3Sig += '('
if decl['ret']['tag'] == 'S':
m3Sig += 'i'
for arg in decl['args']:
tag = arg['type']['tag']
if tag == 'p' or tag == 'S':
tag = 'i'
m3Sig += tag
m3Sig += ')'
s += '\tres = m3_LinkRawFunction(module, "*", "' + name + '", "' + m3Sig + '", ' + cname + '_stub);\n'
s += '\tif(res != m3Err_none && res != m3Err_functionLookupFailed) { log_error("error: %s\\n", res); return(-1); }\n\n'
s += '\treturn(0);\n}\n'
print(s, file=host_bindings)

View File

@ -1,12 +0,0 @@
cosf f(f)
sinf f(f)
floorf f(f)
sqrtf f(f)
cos F(F)
sin F(F)
sqrt F(F)
fabs F(F)
orca_log v(iipipiip)
orca_mem_grow i(I)
orca_assert i(ppipp)

View File

@ -1,44 +0,0 @@
glCreateProgram i(v)
glCreateShader i(i)
glCompileShader v(i)
glAttachShader v(ii)
glLinkProgram v(i)
glUseProgram v(i)
glGetError i(v)
glClearColor v(ffff)
glClear v(i)
glViewport v(iiii)
glGetShaderiv v(iip)
glGetShaderInfoLog v(iipp)
glBindFramebuffer v(ii)
glBindTexture v(ii)
glActiveTexture v(i)
glGenBuffers v(ip)
glGenTextures v(ip)
glGenFramebuffers v(ip)
glFramebufferTexture2D v(iiiii)
glCheckFramebufferStatus i(i)
glTexImage2D v(iiiiiiiip)
glTexParameteri v(iii)
glBindBuffer v(ii)
glBufferData v(iipi)
glUniform1i v(ii)
glUniform2i v(iii)
glUniform1f v(if)
glUniform2f v(iff)
glUniform3f v(ifff)
glUniformMatrix4fv v(iiip)
glGetAttribLocation i(ip)
glGetUniformLocation i(ip)
glVertexAttribPointer v(iiiiip)
glEnableVertexAttribArray v(i)
glDrawArrays v(iii)

103
src/core_api.json Normal file
View File

@ -0,0 +1,103 @@
[
{
"name": "cosf",
"cname": "cosf",
"ret": {"name": "float", "tag": "f"},
"args": [ {"name": "x",
"type": {"name": "float", "tag": "f"}}]
},
{
"name": "sinf",
"cname": "sinf",
"ret": {"name": "float", "tag": "f"},
"args": [ {"name": "x",
"type": {"name": "float", "tag": "f"}}]
},
{
"name": "floorf",
"cname": "floorf",
"ret": {"name": "float", "tag": "f"},
"args": [ {"name": "x",
"type": {"name": "float", "tag": "f"}}]
},
{
"name": "sqrtf",
"cname": "sqrtf",
"ret": {"name": "float", "tag": "f"},
"args": [ {"name": "x",
"type": {"name": "float", "tag": "f"}}]
},
{
"name": "cos",
"cname": "cos",
"ret": {"name": "double", "tag": "F"},
"args": [ {"name": "x",
"type": {"name": "double", "tag": "F"}}]
},
{
"name": "sin",
"cname": "sin",
"ret": {"name": "double", "tag": "F"},
"args": [ {"name": "x",
"type": {"name": "double", "tag": "F"}}]
},
{
"name": "sqrt",
"cname": "sqrt",
"ret": {"name": "double", "tag": "F"},
"args": [ {"name": "x",
"type": {"name": "double", "tag": "F"}}]
},
{
"name": "fabs",
"cname": "fabs",
"ret": {"name": "double", "tag": "F"},
"args": [ {"name": "x",
"type": {"name": "double", "tag": "F"}}]
},
{
"name": "orca_log",
"cname": "orca_log",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "level",
"type": {"name": "log_level", "tag": "i"}},
{"name": "fileLen",
"type": {"name": "int", "tag": "i"}},
{"name": "file",
"type": {"name": "char*", "tag": "p"}},
{"name": "functionLen",
"type": {"name": "int", "tag": "i"}},
{"name": "function",
"type": {"name": "char*", "tag": "p"}},
{"name": "line",
"type": {"name": "int", "tag": "i"}},
{"name": "msgLen",
"type": {"name": "int", "tag": "i"}},
{"name": "msg",
"type": {"name": "char*", "tag": "p"}}
]
},
{
"name": "orca_mem_grow",
"cname": "orca_mem_grow",
"ret": {"name": "int", "tag": "i"},
"args": [ {"name": "size",
"type": {"name": "u64", "tag": "I"}}]
},
{
"name": "orca_assert",
"cname": "orca_assert",
"ret": {"name": "int", "tag": "i"},
"args": [ {"name": "file",
"type": {"name": "const char*", "tag": "p"}},
{"name": "function",
"type": {"name": "const char*", "tag": "p"}},
{"name": "line",
"type": {"name": "int", "tag": "i"}},
{"name": "src",
"type": {"name": "const char*", "tag": "p"}},
{"name": "note",
"type": {"name": "const char*", "tag": "p"}}
]
}
]

383
src/gles_api.json Normal file
View File

@ -0,0 +1,383 @@
[
{
"name": "glCreateProgram",
"cname": "glCreateProgram",
"ret": {"name": "int", "tag": "i"},
"args": []
},
{
"name": "glCreateShader",
"cname": "glCreateShader",
"ret": {"name": "int", "tag": "i"},
"args": [ {"name": "shaderType",
"type": {"name": "GLenum", "tag": "i"}}]
},
{
"name": "glCompileShader",
"cname": "glCompileShader",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "shader",
"type": {"name": "GLuint", "tag": "i"}}]
},
{
"name": "glAttachShader",
"cname": "glAttachShader",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "program",
"type": {"name": "GLuint", "tag": "i"}},
{"name": "shader",
"type": {"name": "GLuint", "tag": "i"}}
]
},
{
"name": "glLinkProgram",
"cname": "glLinkProgram",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "program",
"type": {"name": "GLuint", "tag": "i"}}]
},
{
"name": "glUseProgram",
"cname": "glUseProgram",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "program",
"type": {"name": "GLuint", "tag": "i"}}]
},
{
"name": "glGetError",
"cname": "glGetError",
"ret": {"name": "GLenum", "tag": "i"},
"args": []
},
{
"name": "glClearColor",
"cname": "glClearColor",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "red",
"type": {"name": "GLfloat", "tag": "f"}},
{"name": "green",
"type": {"name": "GLfloat", "tag": "f"}},
{"name": "blue",
"type": {"name": "GLfloat", "tag": "f"}},
{"name": "alpha",
"type": {"name": "GLfloat", "tag": "f"}}
]
},
{
"name": "glClear",
"cname": "glClear",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "mask",
"type": {"name": "GLbitfield", "tag": "i"}}]
},
{
"name": "glViewport",
"cname": "glViewport",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "x",
"type": {"name": "GLint", "tag": "i"}},
{"name": "y",
"type": {"name": "GLint", "tag": "i"}},
{"name": "width",
"type": {"name": "GLsizei", "tag": "i"}},
{"name": "height",
"type": {"name": "GLsizei", "tag": "i"}}
]
},
{
"name": "glGetShaderiv",
"cname": "glGetShaderiv",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "shader",
"type": {"name": "GLuint", "tag": "i"}},
{"name": "pname",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "params",
"type": {"name": "GLint*", "tag": "p"}}
]
},
{
"name": "glGetShaderInfoLog",
"cname": "glGetShaderInfoLog",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "shader",
"type": {"name": "GLuint", "tag": "i"}},
{"name": "maxLength",
"type": {"name": "GLsizei", "tag": "i"}},
{"name": "length",
"type": {"name": "GLsizei", "tag": "p"}},
{"name": "infoLog",
"type": {"name": "GLchar", "tag": "p"}}
]
},
{
"name": "glBindFramebuffer",
"cname": "glBindFramebuffer",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "framebuffer",
"type": {"name": "GLuint", "tag": "i"}}
]
},
{
"name": "glBindTexture",
"cname": "glBindTexture",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "texture",
"type": {"name": "GLuint", "tag": "i"}}
]
},
{
"name": "glActiveTexture",
"cname": "glActiveTexture",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "texture",
"type": {"name": "GLuint", "tag": "i"}}]
},
{
"name": "glGenBuffers",
"cname": "glGenBuffers",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "n",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "buffers",
"type": {"name": "GLuint*", "tag": "p"}}
]
},
{
"name": "glGenTextures",
"cname": "glGenTextures",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "n",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "textures",
"type": {"name": "GLuint*", "tag": "p"}}
]
},
{
"name": "glGenFramebuffers",
"cname": "glGenFramebuffers",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "n",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "framebuffers",
"type": {"name": "GLuint*", "tag": "p"}}
]
},
{
"name": "glFramebufferTexture2D",
"cname": "glFramebufferTexture2D",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "attachment",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "textarget",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "texture",
"type": {"name": "GLuint", "tag": "i"}},
{"name": "level",
"type": {"name": "GLint", "tag": "i"}}
]
},
{
"name": "glCheckFramebufferStatus",
"cname": "glCheckFramebufferStatus",
"ret": {"name": "GLenum", "tag": "i"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}}]
},
{
"name": "glTexImage2D",
"cname": "glTexImage2D",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "level",
"type": {"name": "GLint", "tag": "i"}},
{"name": "internalformat",
"type": {"name": "GLint", "tag": "i"}},
{"name": "width",
"type": {"name": "GLsizei", "tag": "i"}},
{"name": "height",
"type": {"name": "GLsizei", "tag": "i"}},
{"name": "border",
"type": {"name": "GLint", "tag": "i"}},
{"name": "format",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "type",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "data",
"type": {"name": "void*", "tag": "p"}}
]
},
{
"name": "glTexParameteri",
"cname": "glTexParameteri",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "pname",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "param",
"type": {"name": "GLint", "tag": "i"}}
]
},
{
"name": "glBindBuffer",
"cname": "glBindBuffer",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "buffer",
"type": {"name": "GLuint", "tag": "i"}}
]
},
{
"name": "glBufferData",
"cname": "glBufferData",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "target",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "size",
"type": {"name": "GLsizeiptr", "tag": "i"}},
{"name": "data",
"type": {"name": "void*", "tag": "p"}},
{"name": "usage",
"type": {"name": "GLenum", "tag": "i"}}
]
},
{
"name": "glUniform1i",
"cname": "glUniform1i",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "location",
"type": {"name": "GLint", "tag": "i"}},
{"name": "v0",
"type": {"name": "GLint", "tag": "i"}}
]
},
{
"name": "glUniform2i",
"cname": "glUniform2i",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "location",
"type": {"name": "GLint", "tag": "i"}},
{"name": "v0",
"type": {"name": "GLint", "tag": "i"}},
{"name": "v1",
"type": {"name": "GLint", "tag": "i"}}
]
},
{
"name": "glUniform1f",
"cname": "glUniform1f",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "location",
"type": {"name": "GLint", "tag": "i"}},
{"name": "v0",
"type": {"name": "GLfloat", "tag": "f"}}
]
},
{
"name": "glUniform2f",
"cname": "glUniform2f",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "location",
"type": {"name": "GLint", "tag": "i"}},
{"name": "v0",
"type": {"name": "GLfloat", "tag": "f"}},
{"name": "v1",
"type": {"name": "GLfloat", "tag": "f"}}
]
},
{
"name": "glUniform3f",
"cname": "glUniform3f",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "location",
"type": {"name": "GLint", "tag": "i"}},
{"name": "v0",
"type": {"name": "GLfloat", "tag": "f"}},
{"name": "v1",
"type": {"name": "GLfloat", "tag": "f"}},
{"name": "v2",
"type": {"name": "GLfloat", "tag": "f"}}
]
},
{
"name": "glUniformMatrix4fv",
"cname": "glUniformMatrix4fv",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "location",
"type": {"name": "GLint", "tag": "i"}},
{"name": "count",
"type": {"name": "GLsizei", "tag": "i"}},
{"name": "transpose",
"type": {"name": "GLboolean", "tag": "i"}},
{"name": "value",
"type": {"name": "GLfloat*", "tag": "p"}}
]
},
{
"name": "glGetAttribLocation",
"cname": "glGetAttribLocation",
"ret": {"name": "GLint", "tag": "i"},
"args": [ {"name": "program",
"type": {"name": "GLuint", "tag": "i"}},
{"name": "name",
"type": {"name": "GLchar*", "tag": "p"}}
]
},
{
"name": "glGetUniformLocation",
"cname": "glGetUniformLocation",
"ret": {"name": "GLint", "tag": "i"},
"args": [ {"name": "program",
"type": {"name": "GLuint", "tag": "i"}},
{"name": "name",
"type": {"name": "GLchar*", "tag": "p"}}
]
},
{
"name": "glVertexAttribPointer",
"cname": "glVertexAttribPointer",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "index",
"type": {"name": "GLuint", "tag": "i"}},
{"name": "size",
"type": {"name": "GLint", "tag": "i"}},
{"name": "type",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "normalized",
"type": {"name": "GLboolean", "tag": "i"}},
{"name": "stride",
"type": {"name": "GLsizei", "tag": "i"}},
{"name": "pointer",
"type": {"name": "void*", "tag": "p"}}
]
},
{
"name": "glEnableVertexAttribArray",
"cname": "glEnableVertexAttribArray",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "index",
"type": {"name": "GLuint", "tag": "i"}}]
},
{
"name": "glDrawArrays",
"cname": "glDrawArrays",
"ret": {"name": "void", "tag": "v"},
"args": [ {"name": "mode",
"type": {"name": "GLenum", "tag": "i"}},
{"name": "first",
"type": {"name": "GLint", "tag": "i"}},
{"name": "count",
"type": {"name": "GLsizei", "tag": "i"}}
]
}
]

View File

@ -298,12 +298,12 @@ void orca_runtime_init(orca_runtime* runtime)
runtime->wasmMemory.ptr = mem_base_reserve(allocator, runtime->wasmMemory.reserved); runtime->wasmMemory.ptr = mem_base_reserve(allocator, runtime->wasmMemory.reserved);
} }
#include"bindgen_core_api.c" #include"core_api_bind_gen.c"
#include"canvas_api_bind.c" #include"canvas_api_bind.c"
#include"clock_api_bind_gen.c" #include"clock_api_bind_gen.c"
#include"io_api_bind_gen.c" #include"io_api_bind_gen.c"
#include"bindgen_gles_api.c" #include"gles_api_bind_gen.c"
#include"manual_gles_api.c" #include"manual_gles_api.c"
void* orca_runloop(void* user) void* orca_runloop(void* user)