]> git.mdlowis.com Git - proto/gir.git/commitdiff
Added some base objects to the world
authorMike D. Lowis <mike.lowis@gentex.com>
Wed, 27 May 2015 20:05:19 +0000 (16:05 -0400)
committerMike D. Lowis <mike.lowis@gentex.com>
Wed, 27 May 2015 20:05:19 +0000 (16:05 -0400)
Makefile
source/main.c
source/world.c

index 4bef298e0101da6c8db67ea56a16714e12803af0..e481cdac35b137402ea6c10ec92459f626290c59 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ LD = $(CC)
 MAKEDEPEND = $(CPP) -M $(CPPFLAGS) -o  $<
 CCDEPGEN = -MMD -MF $*.d
 CFLAGS = -Wall -Wextra -O3 --std=c99 --pedantic $(addprefix -I,$(INCLUDES))
+LDFLAGS = -static
 
 -include $(SOURCES:.c=.d)
 
index fb5bcefe5bbbdbd97cbd2227e731e6d6be3141a7..62fcc7a90871b3abd15038bd3333eaade2cbfca2 100644 (file)
@@ -219,6 +219,8 @@ static void hashmap(void) {
 /*****************************************************************************/
 
 int main(int argc, char** argv) {
+    extern void world_init(void);
+    world_init();
     printf(":> ");
     while(true) {
         expression();
index de7f18b5a1945ff72a461e54e9e0db0ef071eb3c..3f6c6f7af658bcda7c281ba173315f28861802aa 100644 (file)
@@ -4,29 +4,56 @@
   */
 //#include "world.h"
 
+#include "set.h"
 #include "map.h"
 
-typedef struct {
-    map_t* parent;
-    map_t* self;
-    uint8_t data[];
+typedef struct object_t {
+    struct object_t* parent;
+    map_t* slots;
+    uint8_t value[];
 } object_t;
 
+set_t* Selectors = NULL;
+object_t* Lobby = NULL;
+object_t* Object = NULL;
+object_t* Number = NULL;
+object_t* String = NULL;
+object_t* Array = NULL;
+object_t* ByteArray = NULL;
+object_t* HashSet = NULL;
+object_t* HashMap = NULL;
+
 void object_free(void* obj)
 {
     object_t* object = (object_t*)obj;
     if (object->parent)
         mem_release(object->parent);
-    if (object->self)
-        mem_release(object->self);
+    if (object->slots)
+        mem_release(object->slots);
 }
 
 object_t* object_clone(object_t* parent)
 {
     object_t* obj = (object_t*)mem_allocate(sizeof(object_t), &object_free);
-    obj->parent = (NULL == parent) ? NULL : mem_retain(parent->self);
-    obj->self   = map_new(NULL, NULL);
+    if (NULL != parent)
+        mem_retain(parent);
+    obj->parent = parent;
+    obj->slots  = map_new(NULL, NULL);
     return obj;
 }
 
 
+void world_init(void)
+{
+    Selectors = set_new(NULL, NULL);
+    Lobby     = object_clone(NULL);
+    Object    = object_clone(Lobby);
+    Number    = object_clone(Object);
+    String    = object_clone(Object);
+    Array     = object_clone(Object);
+    ByteArray = object_clone(Object);
+    HashSet   = object_clone(Object);
+    HashMap   = object_clone(Object);
+}
+
+