ext/rbs_extension/location.h in rbs-3.4.4 vs ext/rbs_extension/location.h in rbs-3.5.0.pre.1
- old
+ new
@@ -7,21 +7,28 @@
/**
* RBS::Location class
* */
extern VALUE RBS_Location;
-typedef struct rbs_loc_list {
+typedef struct {
ID name;
range rg;
- struct rbs_loc_list *next;
-} rbs_loc_list;
+} rbs_loc_entry;
+typedef unsigned int rbs_loc_entry_bitmap;
+
typedef struct {
+ unsigned short len;
+ unsigned short cap;
+ rbs_loc_entry_bitmap required_p;
+ rbs_loc_entry entries[0];
+} rbs_loc_children;
+
+typedef struct {
VALUE buffer;
range rg;
- rbs_loc_list *requireds;
- rbs_loc_list *optionals;
+ rbs_loc_children *children;
} rbs_loc;
/**
* Returns new RBS::Location object, with given buffer and range.
* */
@@ -31,15 +38,26 @@
* Return rbs_loc associated with the RBS::Location object.
* */
rbs_loc *rbs_check_location(VALUE location);
/**
+ * Allocate memory for child locations.
+ *
+ * Do not call twice for the same location.
+ * */
+void rbs_loc_alloc_children(rbs_loc *loc, unsigned short cap);
+
+/**
* Add a required child range with given name.
+ *
+ * Allocate memory for children with rbs_loc_alloc_children before calling this function.
* */
void rbs_loc_add_required_child(rbs_loc *loc, ID name, range r);
/**
* Add an optional child range with given name.
+ *
+ * Allocate memory for children with rbs_loc_alloc_children before calling this function.
* */
void rbs_loc_add_optional_child(rbs_loc *loc, ID name, range r);
/**
* Returns RBS::Location object with start/end positions.