From e055c0c7162d7d240c93227397cf3eca01ca86e7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 9 Mar 2023 15:50:58 -0800 Subject: Make shape functions static These functions don't need to be in the header file, we can declare them as static. --- shape.c | 83 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 41 insertions(+), 42 deletions(-) (limited to 'shape.c') diff --git a/shape.c b/shape.c index cf1a4426eb..dbf8d908cf 100644 --- a/shape.c +++ b/shape.c @@ -113,6 +113,47 @@ rb_shape_get_shape(VALUE obj) return rb_shape_get_shape_by_id(rb_shape_get_shape_id(obj)); } +static rb_shape_t * +shape_alloc(void) +{ + rb_vm_t *vm = GET_VM(); + shape_id_t shape_id = vm->next_shape_id; + vm->next_shape_id++; + + if (shape_id == MAX_SHAPE_ID) { + // TODO: Make an OutOfShapesError ?? + rb_bug("Out of shapes\n"); + } + + return &GET_VM()->shape_list[shape_id]; +} + +static rb_shape_t * +rb_shape_alloc_with_parent_id(ID edge_name, shape_id_t parent_id) +{ + rb_shape_t * shape = shape_alloc(); + + shape->edge_name = edge_name; + shape->next_iv_index = 0; + shape->parent_id = parent_id; + + return shape; +} + +static rb_shape_t * +rb_shape_alloc_with_size_pool_index(ID edge_name, rb_shape_t * parent, uint8_t size_pool_index) +{ + rb_shape_t * shape = rb_shape_alloc_with_parent_id(edge_name, rb_shape_id(parent)); + shape->size_pool_index = size_pool_index; + return shape; +} + +static rb_shape_t * +rb_shape_alloc(ID edge_name, rb_shape_t * parent) +{ + return rb_shape_alloc_with_size_pool_index(edge_name, parent, parent->size_pool_index); +} + static rb_shape_t* get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, bool * variation_created, bool new_shapes_allowed, bool new_shape_necessary) { @@ -383,48 +424,6 @@ rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t *value) return false; } -static rb_shape_t * -shape_alloc(void) -{ - rb_vm_t *vm = GET_VM(); - shape_id_t shape_id = vm->next_shape_id; - vm->next_shape_id++; - - if (shape_id == MAX_SHAPE_ID) { - // TODO: Make an OutOfShapesError ?? - rb_bug("Out of shapes\n"); - } - - return &GET_VM()->shape_list[shape_id]; -} - -rb_shape_t * -rb_shape_alloc_with_parent_id(ID edge_name, shape_id_t parent_id) -{ - rb_shape_t * shape = shape_alloc(); - - shape->edge_name = edge_name; - shape->next_iv_index = 0; - shape->parent_id = parent_id; - - return shape; -} - -rb_shape_t * -rb_shape_alloc_with_size_pool_index(ID edge_name, rb_shape_t * parent, uint8_t size_pool_index) -{ - rb_shape_t * shape = rb_shape_alloc_with_parent_id(edge_name, rb_shape_id(parent)); - shape->size_pool_index = size_pool_index; - return shape; -} - - -rb_shape_t * -rb_shape_alloc(ID edge_name, rb_shape_t * parent) -{ - return rb_shape_alloc_with_size_pool_index(edge_name, parent, parent->size_pool_index); -} - void rb_shape_set_shape(VALUE obj, rb_shape_t* shape) { -- cgit v1.2.1