aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-04-16 18:46:47 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-18 20:08:19 +0300
commita76d9ceaee0a83c0af562753ad5efd01858c1c8b (patch)
treec14656d727b59bbd89c849467f65c5973075ccfe /system
parente5c04828c4c2eaec83cf25b83067064db2270c2e (diff)
switch to EMSCRIPTEN_SYMBOL which improves code size a bit by storing the pointer to the string literal as a constant as opposed to a global variable.
Diffstat (limited to 'system')
-rw-r--r--system/include/emscripten/val.h22
1 files changed, 7 insertions, 15 deletions
diff --git a/system/include/emscripten/val.h b/system/include/emscripten/val.h
index 42d8d375..09cad80e 100644
--- a/system/include/emscripten/val.h
+++ b/system/include/emscripten/val.h
@@ -56,25 +56,17 @@ namespace emscripten {
}
}
- class symbol {
- public:
- symbol() = delete;
-
- // I so wish I could require the argument to be a string literal
- symbol(const char* address)
- : address(address)
- {
+ template<const char* address>
+ struct symbol_registrar {
+ symbol_registrar() {
internal::_emval_register_symbol(address);
}
-
- operator const char*() const {
- return address;
- }
-
- private:
- const char* address;
};
+#define EMSCRIPTEN_SYMBOL(name) \
+ static const char name##_symbol[] = #name; \
+ static const symbol_registrar<name##_symbol> name##_registrar
+
class val {
public:
// missing operators: