From 93a8f9417c728e9c25cc9e2039881e8df191876d Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Wed, 8 Oct 2014 15:40:34 +0300 Subject: [PATCH] Symbol visibility changes for initdata --- src/dukutil.py | 7 +++++-- src/genbuiltins.py | 10 +++++----- src/genstrings.py | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/dukutil.py b/src/dukutil.py index 43429e9b..4610f282 100644 --- a/src/dukutil.py +++ b/src/dukutil.py @@ -90,7 +90,7 @@ class GenerateC: 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." # lenient input @@ -105,10 +105,13 @@ class GenerateC: size_spec = '' if bytesize is not None: size_spec = '%d' % bytesize + visib_qual = '' + if visibility is not None: + visib_qual = visibility + ' ' const_qual = '' if 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 = '' for i in xrange(len(data)): diff --git a/src/genbuiltins.py b/src/genbuiltins.py index 220956b5..2d3d80ba 100644 --- a/src/genbuiltins.py +++ b/src/genbuiltins.py @@ -1771,19 +1771,19 @@ class GenBuiltins: genc.emitLine('') self.writeNativeFuncArray(genc) 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.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 */') def emitHeader(self, genc): self.gs.emitStringsHeader(genc) genc.emitLine('') - genc.emitLine('extern 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_c_function duk_bi_native_functions[];') + genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[];') 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('') genc.emitDefine('DUK_BUILTINS_DATA_LENGTH', len(self.init_data)) diff --git a/src/genstrings.py b/src/genstrings.py index cd1bd317..cdb3d648 100644 --- a/src/genstrings.py +++ b/src/genstrings.py @@ -1098,14 +1098,14 @@ class GenStrings: return self.define_to_index.has_key(x) 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('/* 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('extern const duk_uint8_t duk_strings_data[];') + genc.emitLine('DUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[];') genc.emitLine('') genc.emitDefine('DUK_STRDATA_DATA_LENGTH', len(self.strdata)) genc.emitDefine('DUK_STRDATA_MAX_STRLEN', self.maxlen)