aboutsummaryrefslogtreecommitdiff
path: root/common.h
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-06-05 10:58:57 +0800
committerDeterminant <[email protected]>2015-06-05 10:58:57 +0800
commitdf737041e4a9f3f55978cc74db9a9cea27fa9fa0 (patch)
treed656820be286550bc548f7c5ed4b1dcfecf3691c /common.h
parentea6f2990f99dd9ded6a0e74d75a3ec84900a2518 (diff)
add profiling; add ce accurarcy; several other changes
Diffstat (limited to 'common.h')
-rw-r--r--common.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/common.h b/common.h
index 51e90ee..8be19b0 100644
--- a/common.h
+++ b/common.h
@@ -1,3 +1,5 @@
+#ifndef NERV_COMMON_H
+#define NERV_COMMON_H
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
@@ -5,6 +7,29 @@
#include <stdio.h>
#include <stdlib.h>
+typedef struct HashNode {
+ const char *key;
+ void *val;
+ struct HashNode *next;
+} HashNode;
+
+typedef int (*HashMapCmp_t)(const char *a, const char *b);
+typedef size_t (*HashKey_t)(const char *key);
+
+typedef struct HashMap {
+ HashNode **bucket;
+ HashMapCmp_t cmp;
+ HashKey_t hfunc;
+ size_t size;
+} HashMap;
+
+HashMap *hashmap_create(size_t size, HashKey_t hfunc, HashMapCmp_t cmp);
+void *hashmap_getval(HashMap *h, const char *key);
+void hashmap_setval(HashMap *h, const char *key, void *val);
+
+size_t bkdr_hash(const char *key);
+
int nerv_error(lua_State *L, const char *err_mesg_fmt, ...);
int nerv_error_method_not_implemented(lua_State *L);
void luaN_append_methods(lua_State *L, const luaL_Reg *mlist);
+#endif