fix binding generation bug

This commit is contained in:
Reuben Dunnington 2023-08-09 20:11:11 -07:00
parent 6da260c051
commit f922473ada
Signed by: rdunnington
GPG Key ID: 4EC5290E704FD482
1 changed files with 4 additions and 4 deletions

View File

@ -119,6 +119,7 @@ for decl in data:
s += '\n{\n\t'
retTag = decl['ret']['tag']
firstArgIndex = 0
if retTag == 'i':
s += 'returns[0].i32_val = '
elif retTag == 'I':
@ -130,12 +131,11 @@ for decl in data:
elif retTag == 'S':
retTypeName = decl['ret']['name']
retTypeCName = decl['ret'].get('cname', retTypeName)
s += '*(' + retTypeCName + '*)(bb_module_instance_mem(module, returns[0].i32_val, sizeof(' + retTypeCName + '))) = '
s += '*(' + retTypeCName + '*)(bb_module_instance_mem(module, params[0].i32_val, sizeof(' + retTypeCName + '))) = '
firstArgIndex = 1
s += cname + '('
firstArgIndex = 0
for i, arg in enumerate(decl['args']):
typeName = arg['type']['name']
typeCName = arg['type'].get('cname', typeName)
@ -209,7 +209,7 @@ for decl in data:
paramTypes.append(translateTag(tag))
numParams += 1
# dummy values to avoid 0-length arrays in C
# dummy values
if numReturns == 0:
retType = 'BB_VALTYPE_I32'