summaryrefslogtreecommitdiff
path: root/id_table.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-26 01:20:31 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-26 01:20:31 (GMT)
commita3b9b9870ebf8e6660572cc266f21d8e9c6fe4d4 (patch)
treed01a9c85d3d54bf292a8c10e2f67372dfaec1f79 /id_table.c
parent38cfb957dd74948b5b18ead36ac6cac494b9c423 (diff)
id_table.c: aliases
* id_table.c (IMPL_TYPE, IMPL_VOID): make aliases if supported on the platform. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'id_table.c')
-rw-r--r--id_table.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/id_table.c b/id_table.c
index b08f13a..b40a3c9 100644
--- a/id_table.c
+++ b/id_table.c
@@ -1510,20 +1510,35 @@ mix_id_table_foreach_values(struct mix_id_table *tbl, rb_id_table_foreach_values
#define IMPL1(name, op) TOKEN_PASTE(name, _id##op) /* expand `name' */
#define IMPL(op) IMPL1(ID_TABLE_NAME, _table##op) /* but prevent `op' */
-struct rb_id_table *rb_id_table_create(size_t size) {return (struct rb_id_table *)IMPL(_create)(size);}
-void rb_id_table_free(struct rb_id_table *tbl) { IMPL(_free)((ID_TABLE_IMPL_TYPE *)tbl);}
-void rb_id_table_clear(struct rb_id_table *tbl) { IMPL(_clear)((ID_TABLE_IMPL_TYPE *)tbl);}
-size_t rb_id_table_size(struct rb_id_table *tbl) {return IMPL(_size)((ID_TABLE_IMPL_TYPE *)tbl);}
-size_t rb_id_table_memsize(struct rb_id_table *tbl) {return IMPL(_memsize)((ID_TABLE_IMPL_TYPE *)tbl);}
-
-int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val) {return IMPL(_insert)((ID_TABLE_IMPL_TYPE *)tbl, id, val);}
-int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp) {return IMPL(_lookup)((ID_TABLE_IMPL_TYPE *)tbl, id, valp);}
-int rb_id_table_delete(struct rb_id_table *tbl, ID id) {return IMPL(_delete)((ID_TABLE_IMPL_TYPE *)tbl, id);}
-
-void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data) {
- IMPL(_foreach)((ID_TABLE_IMPL_TYPE *)tbl, func, data);}
-void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data) {
- IMPL(_foreach_values)((ID_TABLE_IMPL_TYPE *)tbl, func, data);}
+#define IMPL_TYPE1(type, prot, name, args) \
+ RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args)
+#define IMPL_TYPE(type, name, prot, args) \
+ IMPL_TYPE1(type, rb_id_table_##name prot, IMPL(_##name), args)
+#define IMPL_VOID1(prot, name, args) \
+ RUBY_ALIAS_FUNCTION_VOID(prot, name, args)
+#define IMPL_VOID(name, prot, args) \
+ IMPL_VOID1(rb_id_table_##name prot, IMPL(_##name), args)
+#define id_tbl (ID_TABLE_IMPL_TYPE *)tbl
+
+IMPL_TYPE(struct rb_id_table *, create, (size_t size), (size))
+IMPL_VOID(free, (struct rb_id_table *tbl), (id_tbl))
+IMPL_VOID(clear, (struct rb_id_table *tbl), (id_tbl))
+IMPL_TYPE(size_t, size, (struct rb_id_table *tbl), (id_tbl))
+IMPL_TYPE(size_t, memsize, (struct rb_id_table *tbl), (id_tbl))
+
+IMPL_TYPE(int , insert, (struct rb_id_table *tbl, ID id, VALUE val),
+ (id_tbl, id, val))
+IMPL_TYPE(int, lookup, (struct rb_id_table *tbl, ID id, VALUE *valp),
+ (id_tbl, id, valp))
+IMPL_TYPE(int, delete, (struct rb_id_table *tbl, ID id),
+ (id_tbl, id))
+
+IMPL_VOID(foreach,
+ (struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data),
+ (id_tbl, func, data))
+IMPL_VOID(foreach_values,
+ (struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data),
+ (id_tbl, func, data))
#if ID_TABLE_STARTUP_SIG
__attribute__((constructor))