From 71236240ab58682f076f5cad1bb589da1241b35d Mon Sep 17 00:00:00 2001 From: Reuben Dunnington Date: Fri, 28 Jul 2023 21:46:56 -0700 Subject: [PATCH] fully replace bindgen.py with bindgen2.py * Removes core_api and gles_api .txt bindings and replaces them with .json versions * Rename bindgen2.py to bindgen.py, effectively deleting the old script * Update build.bat to reflect new changes --- build.bat | 12 +- scripts/bindgen.py | 278 +++++++++++++++++----------- scripts/bindgen2.py | 201 -------------------- src/bindgen_core_api.txt | 12 -- src/bindgen_gles_api.txt | 44 ----- src/core_api.json | 103 +++++++++++ src/gles_api.json | 383 +++++++++++++++++++++++++++++++++++++++ src/main.c | 4 +- 8 files changed, 669 insertions(+), 368 deletions(-) delete mode 100644 scripts/bindgen2.py delete mode 100644 src/bindgen_core_api.txt delete mode 100644 src/bindgen_gles_api.txt create mode 100644 src/core_api.json create mode 100644 src/gles_api.json diff --git a/build.bat b/build.bat index a1cd857..0bbfe44 100644 --- a/build.bat +++ b/build.bat @@ -36,21 +36,23 @@ if %target% == orca ( copy %pthread_dir%\bin\pthreadVC3.dll bin ::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-include graphics.h^ --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-include platform_clock.h^ --wasm3-bindings src\clock_api_bind_gen.c - python3 scripts\bindgen2.py io^ + python3 scripts\bindgen.py io^ src\io_api.json^ --guest-stubs sdk\io_stubs.c^ --wasm3-bindings src\io_api_bind_gen.c diff --git a/scripts/bindgen.py b/scripts/bindgen.py index 0f81a54..48baa0e 100755 --- a/scripts/bindgen.py +++ b/scripts/bindgen.py @@ -1,131 +1,201 @@ #!/usr/bin/env python3 -import sys -if len(sys.argv) < 2: - print("bindgen require an api name\n") - exit(-1); +from argparse import ArgumentParser +import json -apiName = sys.argv[1] -cdir = '' +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') -if len(sys.argv) > 2: - cdir = sys.argv[2] +args = parser.parse_args() -inPath = cdir + '/bindgen_' + apiName + '_api.txt' -outPath = cdir + '/bindgen_' + apiName + '_api.c' +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' -inFile = open(inPath, 'r') -outFile = open(outPath, 'w') +wasm3_bindings_path = args.wasm3_bindings +if wasm3_bindings_path == None: + wasm3_bindings_path = 'bindgen_' + apiName + '_wasm3_bindings.c' -stubs = [] -links = [] +host_bindings = open(wasm3_bindings_path, 'w') +guest_bindings = None -def gen_stub(name, sig, native_name): - if native_name == None: - native_name = name +specFile = open(spec, 'r') +data = json.load(specFile) - src = 'const void* ' + name + '_stub(IM3Runtime runtime, IM3ImportContext _ctx, uint64_t * _sp, void * _mem)\n' - src += '{\n' - spIndex = 0 +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) - parsingRet = True - retCount = 0 - argCount = 0 - retString = '' - argString = '' +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 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 - else: - print('unrecognized type ' + c + ' in procedure return\n') - break - retCount += 1 +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: - argIndex = argCount + retCount - if c == ')': - break - elif c == 'v': - break - elif c == 'i': - argString += '*(i32*)&_sp[' + str(argIndex) + ']' - elif c == 'I': - argString += '*(i64*)&_sp[' + str(argIndex) + ']' - elif c == 'f': - argString += '*(f32*)&_sp[' + str(argIndex) + ']' - elif c == 'F': - argString += '*(f64*)&_sp[' + str(argIndex) + ']' - elif c == 'p': - argString += '(void*)((char*)_mem + *(i32*)&_sp[' + str(argIndex) + '])' + 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 index+2 < len(sig): - argString += ', ' - argCount += 1 + if i+1 < len(decl['args']): + s += ', ' - src += '\t' + retString + native_name + '(' + argString + ');\n' - src += '\treturn(0);\n' - src += '}\n' - stubs.append(src) + s += ');\n\treturn(0);\n}\n\n' -def gen_link(name, sig): - m3_Sig = '' - for c in sig: - if c == 'p': - m3_Sig += 'i' - else: - m3_Sig += c + print(s, file=host_bindings) - src = '\tres = m3_LinkRawFunction(module, "*", "' + name + '", "' + m3_Sig + '", ' + name + '_stub);\n' - src += '\tif(res != m3Err_none && res != m3Err_functionLookupFailed) { log_error("error: %s\\n", res); return(-1); }\n\n' - links.append(src) +# link function +s = 'int bindgen_link_' + apiName + '_api(IM3Module module)\n{\n\t' +s += 'M3Result res;\n' -for line in inFile: - if line.isspace(): - continue - desc = line.split() +for decl in data: + name = decl['name'] + cname = decl.get('cname', name) - gen_stub(desc[0], desc[1], desc[2] if len(desc) > 2 else None) - gen_link(desc[0], desc[1]) + if needs_arg_ptr_stub(decl): + name = name + '_argptr_stub' -linkProc = 'int bindgen_link_' + apiName + '_api(IM3Module module)\n' -linkProc += '{\n' -linkProc += '\tM3Result res;\n' + m3Sig = '' + if decl['ret']['tag'] == 'S': + m3Sig += 'v' + else: + m3Sig += decl['ret']['tag'] -for link in links: - linkProc += link + 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 += ')' -linkProc += '\treturn(0);\n' -linkProc += '}\n' -for stub in stubs: - outFile.write(stub) + 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' -outFile.write('\n') -outFile.write(linkProc) -inFile.close() -outFile.close() +s += '\treturn(0);\n}\n' + +print(s, file=host_bindings) diff --git a/scripts/bindgen2.py b/scripts/bindgen2.py deleted file mode 100644 index 48baa0e..0000000 --- a/scripts/bindgen2.py +++ /dev/null @@ -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) diff --git a/src/bindgen_core_api.txt b/src/bindgen_core_api.txt deleted file mode 100644 index f72ab71..0000000 --- a/src/bindgen_core_api.txt +++ /dev/null @@ -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) diff --git a/src/bindgen_gles_api.txt b/src/bindgen_gles_api.txt deleted file mode 100644 index 03c8df4..0000000 --- a/src/bindgen_gles_api.txt +++ /dev/null @@ -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) diff --git a/src/core_api.json b/src/core_api.json new file mode 100644 index 0000000..061dfac --- /dev/null +++ b/src/core_api.json @@ -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"}} + ] +} +] diff --git a/src/gles_api.json b/src/gles_api.json new file mode 100644 index 0000000..fcd6982 --- /dev/null +++ b/src/gles_api.json @@ -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"}} + ] +} +] diff --git a/src/main.c b/src/main.c index 874681f..700ddf5 100644 --- a/src/main.c +++ b/src/main.c @@ -298,12 +298,12 @@ void orca_runtime_init(orca_runtime* runtime) 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"clock_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" void* orca_runloop(void* user)