3
%typemap(in) (int nattributes, const char **names, const int *values) (VALUE keys_ary, int i, VALUE key, VALUE val) {
4
Check_Type($input, T_HASH);
5
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
9
$2 = (char **) malloc($1*sizeof(char *));
10
$3 = (int *) malloc($1*sizeof(int));
11
keys_ary = rb_funcall($input, rb_intern("keys"), 0, NULL);
12
for (i = 0; i < $1; i++) {
13
key = rb_ary_entry(keys_ary, i);
14
val = rb_hash_aref($input, key);
15
Check_Type(key, T_STRING);
16
Check_Type(val, T_FIXNUM);
17
$2[i] = STR2CSTR(key);
23
%typemap(freearg) (int nattributes, const char **names, const int *values) {
29
void setVitalStats(const char *person, int nattributes, const char **names, const int *values) {
31
printf("Name: %s\n", person);
32
for (i = 0; i < nattributes; i++) {
33
printf(" %s => %d\n", names[i], values[i]);