aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormax99x <max99x@gmail.com>2011-09-14 19:56:03 +0300
committermax99x <max99x@gmail.com>2011-09-14 19:56:03 +0300
commit838a00ff47a8963dc87d13a1dfe70603393ab2f5 (patch)
treed3596868497a04f2c8df5014646dfb83eaf15389 /src
parente0c5552c7f77e93d903b8f141e16793cc3c580e6 (diff)
Cleaned up library-defined global var jsifier.
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index a9b66cd2..835a8ffb 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -207,23 +207,21 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
}
var constant = null;
if (item.external) {
+ var shortident = item.ident.slice(1);
// Import external global variables from the library if available.
- if (LibraryManager.library[item.ident.slice(1)] &&
- LibraryManager.library[item.ident.slice(1)].length &&
+ if (LibraryManager.library[shortident] &&
+ LibraryManager.library[shortident].length &&
!BUILD_AS_SHARED_LIB) {
- var val = LibraryManager.library[item.ident.slice(1)];
- val = val.concat(zeros(generateStructTypes(item.type).length-1));
- val = JSON.stringify(val);
- ret.push({
- intertype: 'GlobalVariablePostSet',
- JS: item.ident + '=' + makePointer(val, null, 'ALLOC_STATIC', item.type) + ';'
- });
- if (LibraryManager.library[item.ident.slice(1) + '__postset']) {
+ var val = LibraryManager.library[shortident];
+ var padded = val.concat(makeEmptyStruct(item.type).slice(val.length));
+ var js = item.ident + '=' + makePointer(JSON.stringify(padded), null, 'ALLOC_STATIC', item.type) + ';'
+ if (LibraryManager.library[shortident + '__postset']) {
+ js += '\n' + LibraryManager.library[shortident + '__postset'];
+ }
ret.push({
intertype: 'GlobalVariablePostSet',
- JS: LibraryManager.library[item.ident.slice(1) + '__postset']
+ JS: js
});
- }
}
return ret;
} else {