Browse Source

Add sizes to builtin array declarations

Fixes some compile warnings.
v1.0-maintenance
Sami Vaarala 10 years ago
parent
commit
0439ea9e78
  1. 6
      src/dukutil.py
  2. 4
      src/extract_caseconv.py
  3. 2
      src/extract_chars.py
  4. 12
      src/genbuiltins.py
  5. 4
      src/genstrings.py

6
src/dukutil.py

@ -90,7 +90,7 @@ class GenerateC:
self.emitLine(' */')
self.emitLine('')
def emitArray(self, data, tablename, visibility=None, typename='char', bytesize=None, intvalues=False, const=True):
def emitArray(self, data, tablename, visibility=None, typename='char', size=None, intvalues=False, const=True):
"Emit an array as a C array."
# lenient input
@ -103,8 +103,8 @@ class GenerateC:
data = tmp
size_spec = ''
if bytesize is not None:
size_spec = '%d' % bytesize
if size is not None:
size_spec = '%d' % size
visib_qual = ''
if visibility is not None:
visib_qual = visibility + ' '

4
src/extract_caseconv.py

@ -378,8 +378,8 @@ def main():
# Generate C source and header files
genc = dukutil.GenerateC()
genc.emitHeader('extract_caseconv.py')
genc.emitArray(uc_bytes, opts.table_name_uc, bytesize=len(uc_bytes), typename='duk_uint8_t', intvalues=True, const=True)
genc.emitArray(lc_bytes, opts.table_name_lc, bytesize=len(lc_bytes), typename='duk_uint8_t', intvalues=True, const=True)
genc.emitArray(uc_bytes, opts.table_name_uc, size=len(uc_bytes), typename='duk_uint8_t', intvalues=True, const=True)
genc.emitArray(lc_bytes, opts.table_name_lc, size=len(lc_bytes), typename='duk_uint8_t', intvalues=True, const=True)
f = open(opts.out_source, 'wb')
f.write(genc.getString())
f.close()

2
src/extract_chars.py

@ -331,7 +331,7 @@ def main():
# Create C source and header files
genc = dukutil.GenerateC()
genc.emitHeader('extract_chars.py')
genc.emitArray(matchtable3, opts.table_name, bytesize=len(matchtable3), typename='duk_uint8_t', intvalues=True, const=True)
genc.emitArray(matchtable3, opts.table_name, size=len(matchtable3), typename='duk_uint8_t', intvalues=True, const=True)
if opts.out_source is not None:
f = open(opts.out_source, 'wb')
f.write(genc.getString())

12
src/genbuiltins.py

@ -1443,7 +1443,7 @@ class GenBuiltins:
def writeNativeFuncArray(self, genc):
genc.emitLine('/* native functions: %d */' % len(self.native_func_list))
genc.emitLine('const duk_c_function duk_bi_native_functions[] = {')
genc.emitLine('DUK_INTERNAL const duk_c_function duk_bi_native_functions[%d] = {' % len(self.native_func_list))
for i in self.native_func_list:
# The function pointer cast here makes BCC complain about
# "initializer too complicated", so omit the cast.
@ -1771,19 +1771,19 @@ class GenBuiltins:
genc.emitLine('')
self.writeNativeFuncArray(genc)
genc.emitLine('')
genc.emitArray(self.init_data, 'duk_builtins_data', visibility='DUK_INTERNAL', typename='duk_uint8_t', intvalues=True, const=True)
genc.emitArray(self.init_data, 'duk_builtins_data', visibility='DUK_INTERNAL', typename='duk_uint8_t', intvalues=True, const=True, size=len(self.init_data))
genc.emitLine('#ifdef DUK_USE_BUILTIN_INITJS')
genc.emitArray(self.initjs_data, 'duk_initjs_data', visibility='DUK_INTERNAL', typename='duk_uint8_t', intvalues=True, const=True)
genc.emitArray(self.initjs_data, 'duk_initjs_data', visibility='DUK_INTERNAL', typename='duk_uint8_t', intvalues=True, const=True, size=len(self.initjs_data))
genc.emitLine('#endif /* DUK_USE_BUILTIN_INITJS */')
def emitHeader(self, genc):
self.gs.emitStringsHeader(genc)
genc.emitLine('')
genc.emitLine('DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[];')
genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[];')
genc.emitLine('DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[%s];' % len(self.native_func_list))
genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[%d];' % len(self.init_data))
genc.emitLine('#ifdef DUK_USE_BUILTIN_INITJS')
genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_initjs_data[];')
genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_initjs_data[%s];' % len(self.initjs_data))
genc.emitLine('#endif /* DUK_USE_BUILTIN_INITJS */')
genc.emitLine('')
genc.emitDefine('DUK_BUILTINS_DATA_LENGTH', len(self.init_data))

4
src/genstrings.py

@ -1102,14 +1102,14 @@ class GenStrings:
return self.define_to_index.has_key(x)
def emitStringsData(self, genc):
genc.emitArray(self.strdata, 'duk_strings_data', visibility='DUK_INTERNAL', typename='duk_uint8_t', intvalues=True, const=True)
genc.emitArray(self.strdata, 'duk_strings_data', visibility='DUK_INTERNAL', typename='duk_uint8_t', intvalues=True, const=True, size=len(self.strdata))
genc.emitLine('')
genc.emitLine('/* to convert a heap stridx to a token number, subtract')
genc.emitLine(' * DUK_STRIDX_START_RESERVED and add DUK_TOK_START_RESERVED.')
genc.emitLine(' */')
def emitStringsHeader(self, genc):
genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[];')
genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[%d];' % len(self.strdata))
genc.emitLine('')
genc.emitDefine('DUK_STRDATA_DATA_LENGTH', len(self.strdata))
genc.emitDefine('DUK_STRDATA_MAX_STRLEN', self.maxlen)

Loading…
Cancel
Save