Browse Source

Symbol visibility changes for initdata

v1.0-maintenance
Sami Vaarala 10 years ago
parent
commit
93a8f9417c
  1. 7
      src/dukutil.py
  2. 10
      src/genbuiltins.py
  3. 4
      src/genstrings.py

7
src/dukutil.py

@ -90,7 +90,7 @@ class GenerateC:
self.emitLine(' */') self.emitLine(' */')
self.emitLine('') self.emitLine('')
def emitArray(self, data, tablename, typename='char', bytesize=None, intvalues=False, const=True): def emitArray(self, data, tablename, visibility=None, typename='char', bytesize=None, intvalues=False, const=True):
"Emit an array as a C array." "Emit an array as a C array."
# lenient input # lenient input
@ -105,10 +105,13 @@ class GenerateC:
size_spec = '' size_spec = ''
if bytesize is not None: if bytesize is not None:
size_spec = '%d' % bytesize size_spec = '%d' % bytesize
visib_qual = ''
if visibility is not None:
visib_qual = visibility + ' '
const_qual = '' const_qual = ''
if const: if const:
const_qual = 'const ' const_qual = 'const '
self.emitLine('%s%s %s[%s] = {' % (const_qual, typename, tablename, size_spec)) self.emitLine('%s%s%s %s[%s] = {' % (visib_qual, const_qual, typename, tablename, size_spec))
line = '' line = ''
for i in xrange(len(data)): for i in xrange(len(data)):

10
src/genbuiltins.py

@ -1771,19 +1771,19 @@ class GenBuiltins:
genc.emitLine('') genc.emitLine('')
self.writeNativeFuncArray(genc) self.writeNativeFuncArray(genc)
genc.emitLine('') genc.emitLine('')
genc.emitArray(self.init_data, 'duk_builtins_data', 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)
genc.emitLine('#ifdef DUK_USE_BUILTIN_INITJS') genc.emitLine('#ifdef DUK_USE_BUILTIN_INITJS')
genc.emitArray(self.initjs_data, 'duk_initjs_data', 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)
genc.emitLine('#endif /* DUK_USE_BUILTIN_INITJS */') genc.emitLine('#endif /* DUK_USE_BUILTIN_INITJS */')
def emitHeader(self, genc): def emitHeader(self, genc):
self.gs.emitStringsHeader(genc) self.gs.emitStringsHeader(genc)
genc.emitLine('') genc.emitLine('')
genc.emitLine('extern const duk_c_function duk_bi_native_functions[];') genc.emitLine('DUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[];')
genc.emitLine('extern const duk_uint8_t duk_builtins_data[];') genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[];')
genc.emitLine('#ifdef DUK_USE_BUILTIN_INITJS') genc.emitLine('#ifdef DUK_USE_BUILTIN_INITJS')
genc.emitLine('extern const duk_uint8_t duk_initjs_data[];') genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_initjs_data[];')
genc.emitLine('#endif /* DUK_USE_BUILTIN_INITJS */') genc.emitLine('#endif /* DUK_USE_BUILTIN_INITJS */')
genc.emitLine('') genc.emitLine('')
genc.emitDefine('DUK_BUILTINS_DATA_LENGTH', len(self.init_data)) genc.emitDefine('DUK_BUILTINS_DATA_LENGTH', len(self.init_data))

4
src/genstrings.py

@ -1098,14 +1098,14 @@ class GenStrings:
return self.define_to_index.has_key(x) return self.define_to_index.has_key(x)
def emitStringsData(self, genc): def emitStringsData(self, genc):
genc.emitArray(self.strdata, 'duk_strings_data', 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)
genc.emitLine('') genc.emitLine('')
genc.emitLine('/* to convert a heap stridx to a token number, subtract') 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(' * DUK_STRIDX_START_RESERVED and add DUK_TOK_START_RESERVED.')
genc.emitLine(' */') genc.emitLine(' */')
def emitStringsHeader(self, genc): def emitStringsHeader(self, genc):
genc.emitLine('extern const duk_uint8_t duk_strings_data[];') genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[];')
genc.emitLine('') genc.emitLine('')
genc.emitDefine('DUK_STRDATA_DATA_LENGTH', len(self.strdata)) genc.emitDefine('DUK_STRDATA_DATA_LENGTH', len(self.strdata))
genc.emitDefine('DUK_STRDATA_MAX_STRLEN', self.maxlen) genc.emitDefine('DUK_STRDATA_MAX_STRLEN', self.maxlen)

Loading…
Cancel
Save