aboutsummaryrefslogtreecommitdiffhomepage
path: root/symbols.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-23 16:02:19 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-23 16:02:19 +0100
commit0e536bd36250419698fe884d01d5997581241d93 (patch)
treec0022c625937a45cd4afee1e6f2ddd49b0634f07 /symbols.h
parentf1accae89b8aa9247932ed8bbb46f07e03e1aa7a (diff)
downloadsciteco-0e536bd36250419698fe884d01d5997581241d93.tar.gz
system for looking up static symbols
* symbols are extracted from C header files by a TECO macro * macro is executed using a "minimal" version of SciTECO that does not include symbols (uses gcc's weak symbols) * the generated C++ code contains the symbol-name-to-define mapping as a constant sorted array and initializes the appropriate SymbolList object * a symbol lookup is super fast using a simple binary search in the symbol lists * except for object initialization, no there's no overhead for keeping the symbol lists! * build process is complicated by introduction of bootstrapping via sciteco-minimal
Diffstat (limited to 'symbols.h')
-rw-r--r--symbols.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/symbols.h b/symbols.h
new file mode 100644
index 0000000..735fdda
--- /dev/null
+++ b/symbols.h
@@ -0,0 +1,29 @@
+#ifndef __SYMBOLS_H
+#define __SYMBOLS_H
+
+#include <glib.h>
+
+class SymbolList {
+public:
+ struct Entry {
+ const gchar *name;
+ gint value;
+ };
+
+private:
+ const Entry *entries;
+ gint size;
+
+public:
+ SymbolList(const Entry *_entries = NULL, gint _size = 0)
+ : entries(_entries), size(_size) {}
+
+ gint lookup(const gchar *name);
+ GList *get_glist(void);
+};
+
+namespace Symbols {
+ extern SymbolList __attribute__((weak)) scintilla;
+}
+
+#endif