summaryrefslogtreecommitdiff
path: root/src/struct.h
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-01-05 22:19:53 -0500
committerAdrian Thurston <thurston@complang.org>2015-01-05 22:19:53 -0500
commit94798b8c5670f226c18db6e24cfceb3ef4da3540 (patch)
tree753a1f95c91d2ef421cd20bdcbbf9876f9ae1d79 /src/struct.h
parent484f6b5f78cf3ecfc3e676366c4ef98e8dda9692 (diff)
downloadcolm-94798b8c5670f226c18db6e24cfceb3ef4da3540.tar.gz
some improvements to the struct macros, and code movement
Diffstat (limited to 'src/struct.h')
-rw-r--r--src/struct.h25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/struct.h b/src/struct.h
index 9c6bb959..73400d4f 100644
--- a/src/struct.h
+++ b/src/struct.h
@@ -101,29 +101,24 @@ typedef struct colm_map
struct colm_struct *colm_struct_new_size( struct colm_program *prg, int size );
struct colm_struct *colm_struct_new( struct colm_program *prg, int id );
+void colm_struct_add( struct colm_program *prg, struct colm_struct *item );
void colm_struct_delete( struct colm_program *prg, struct colm_tree **sp,
struct colm_struct *el );
struct colm_struct *colm_struct_inbuilt( struct colm_program *prg, int size,
colm_destructor_t destructor );
-#define colm_struct_get_field( obj, field ) \
- ((struct colm_tree**)(((struct colm_struct*)obj)+1))[field]
+#define colm_struct_get_field( obj, type, field ) \
+ (type)(((void**)(((struct colm_struct*)obj)+1))[field])
-#define colm_struct_get_field_type( obj, type, field ) \
- ((type*)(((struct colm_struct*)obj)+1))[field]
-
-#define colm_struct_get_addr( obj, field ) \
- &(((void **)(((struct colm_struct*)obj)+1))[field])
+#define colm_struct_set_field( obj, type, field, val ) \
+ ((type*)(((struct colm_struct*)obj)+1))[field] = val
-#define colm_struct_get_addr_type( obj, type, field ) \
- (type*)(&(((void **)(((struct colm_struct*)obj)+1))[field]))
+#define colm_struct_get_addr( obj, type, field ) \
+ (type)(&(((void **)(((struct colm_struct*)obj)+1))[field]))
-#define colm_struct_set_field( obj, field, val ) \
- ((struct colm_tree**)(((struct colm_struct*)obj)+1))[field] = val
-
-#define colm_struct_set_field_type( obj, type, field, val ) \
- ((type*)(((struct colm_struct*)obj)+1))[field] = val
+#define colm_struct_container( el, field ) \
+ ((void*)el) - (field * sizeof(void*)) - sizeof(struct colm_struct)
Parser *colm_parser_new( struct colm_program *prg, GenericInfo *gi );
Stream *colm_stream_new( struct colm_program *prg );
@@ -139,6 +134,8 @@ long colm_list_length( List *list );
Map *colm_map_new( struct colm_program *prg );
+#define STRUCT_INBUILT_ID -1
+
#if defined(__cplusplus)
}
#endif