Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / tuple.c
blob9dc6d204982feef2aebbebcb9f0ebb8919f3231b
1 #include <stdarg.h>
2 #include "shotgun/lib/shotgun.h"
3 #include "shotgun/lib/tuple.h"
5 OBJECT tuple_enlarge(STATE, OBJECT tup, int inc) {
6 int sz;
7 OBJECT ns;
8 sz = NUM_FIELDS(tup);
9 if(tup->gc_zone == YoungObjectZone) {
10 ns = tuple_new(state, sz + inc);
11 } else {
12 ns = NEW_OBJECT_MATURE(state->global->tuple, sz + inc);
14 object_copy_fields_from(state, tup, ns, 0, sz);
15 return ns;
18 OBJECT tuple_dup(STATE, OBJECT tup) {
19 OBJECT ns;
21 ns = tuple_new(state, NUM_FIELDS(tup));
22 object_copy_fields_from(state, tup, ns, 0, NUM_FIELDS(tup));
24 return ns;
27 OBJECT tuple_new2(STATE, int n, ...) {
28 va_list ar;
29 OBJECT tup;
30 int i;
32 tup = tuple_new(state, n);
34 va_start(ar, n);
35 for(i = 0; i < n; i++) {
36 tuple_put(state, tup, i, va_arg(ar, OBJECT));
38 va_end(ar);
39 return tup;