moved henge.h to ston.h
authorken <ken@mihrtec.com>
Fri, 24 Feb 2017 18:48:20 +0000 (10:48 -0800)
committerken <ken@mihrtec.com>
Fri, 24 Feb 2017 18:48:20 +0000 (10:48 -0800)
src/binaryout.c
src/henge.h [deleted file]

index 5c58a0c..ad9c5cd 100644 (file)
@@ -22,6 +22,7 @@
 #include "../stb/stb_image.h"
 #define STB_IMAGE_WRITE_IMPLEMENTATION
 #include "../stb/stb_image_write.h"
 #include "../stb/stb_image.h"
 #define STB_IMAGE_WRITE_IMPLEMENTATION
 #include "../stb/stb_image_write.h"
+#include "../ston/ston.h"
 
 /* Public */
 void ir_binout_init(struct ir_class_t*);
 
 /* Public */
 void ir_binout_init(struct ir_class_t*);
@@ -133,7 +134,9 @@ struct bin_pixel_ht_t
   struct bin_pixel_ht_entry_t* hash_entries;
 };
 
   struct bin_pixel_ht_entry_t* hash_entries;
 };
 
+static
 struct bin_attachment_list_t **attachment_stack, **asp; //attachment_stack, attachment_stack_pointer
 struct bin_attachment_list_t **attachment_stack, **asp; //attachment_stack, attachment_stack_pointer
+static
 FILE* binaryout;
 
 #define  NAMEHASH(name, domain) (XXH32(name, u8_strlen(name), 0XCEED ) & domain) 
 FILE* binaryout;
 
 #define  NAMEHASH(name, domain) (XXH32(name, u8_strlen(name), 0XCEED ) & domain) 
@@ -370,14 +373,16 @@ bin_traverse_class
   int num_class_entries, num_rootset_entries;
   uint8_t* class_name;
 
   int num_class_entries, num_rootset_entries;
   uint8_t* class_name;
 
+  class_header.namelen = u8_strlen(class_name);
+  
+
   class_start = ftell(binaryout);
   class_name = ir_class_name(class);
 
   num_class_entries = bin_calculate_ht_entries(bin_class_sibcount(class));
   class_start = ftell(binaryout);
   class_name = ir_class_name(class);
 
   num_class_entries = bin_calculate_ht_entries(bin_class_sibcount(class));
-  num_rootset_entries = bin_calculate_ht_entries(ir_class_rootset(class));
+  num_rootset_entries = bin_calculate_ht_entries(bin_set_sibcount(ir_class_rootset(class)));
 
   /* alloc space (before hash tables) for class header */
 
   /* alloc space (before hash tables) for class header */
-  class_header.namelen = u8_strlen(class_name);
   fseek(binaryout, class_start + sizeof(class_header) + class_header.namelen ,SEEK_SET);
   
   DEF_HT_INIT(classht_start, classht_size, num_class_entries);
   fseek(binaryout, class_start + sizeof(class_header) + class_header.namelen ,SEEK_SET);
   
   DEF_HT_INIT(classht_start, classht_size, num_class_entries);
diff --git a/src/henge.h b/src/henge.h
deleted file mode 100644 (file)
index 4f61733..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*!@file
-  \brief   HENGE Memory Definition in common with STON Asset Packages
-  \details C Aligned memory structures used to define datatypes in the STON
-           Asset Package format, used for reading asset packages as runtime 
-           memory.
-  \author  Ken Grimes
-  \date    Feb 2017
-  ----------------------------------------------------------------------------*/
-#ifndef _HENGE_H_
-#define _HENGE_H_
-
-/* Henge Generic Hashtable 
-
-   Hashtables are stored as dynamically sized two dimensional arrays, whose
-   columns are provided, and whose rows, and sizes, are derived.
-
-   ht_size = header.ht_columns << header.ht_2pow;
-   ht_rows = 0x1 << header.ht_2pow;
-
-   All generic hashtables in henge must have a power-of-two number of rows.  An
-   ht_columns value that is also a power-of-two will result in a power-of-two
-   sized memory imprint for the structure, making it easy to page align.
-
-   Elements in the columns may be of any arbitrary size.
-
-   typedef uint32_t my_ht_type;
-   ht_bytes = ht_size * sizeof(my_ht_type);
-*/
-struct hng_ht_header_t
-{ uint16_t ht_columns;
-  uint8_t  ht_2pow, ht_flags;
-};
-
-#define hng_ht_size(_HEADER)             ((_HEADER)->ht_columns << (_HEADER)->ht_2pow)
-#define hng_ht_rows(_HEADER)             (0x1 << (_HEADER)->ht_2pow)
-#define hng_ht_cols(_HEADER)             (_HEADER->ht_columns)
-#define hng_ht_start(_HEADER)            (_HEADER + sizeof(*_HEADER))
-#define hng_ht_array(_HEADER,_UNIT)      ((_UNIT*)hng_ht_start(_HEADER))
-#define hng_ht_bytes(_HEADER,_UNIT)      (hng_ht_size(_HEADER) * sizeof(_UNIT))
-#define hng_ht_2bytes(_HEADER,_UNIT2POW) (hng_ht_size(_HEADER) << _UNIT2POW)
-
-#endif //_HENGE_H_