Module: Vlerq

Defined in:
lib/rural.rb,
ext/vlerq_ext.c

Defined Under Namespace

Classes: Col, Row

Class Method Summary collapse

Class Method Details

.cmdlistObject



320
321
322
323
324
325
326
327
328
# File 'ext/vlerq_ext.c', line 320

static VALUE vq_cmdlist (VALUE self) {
  int i, ncmds = sizeof f_commands / sizeof f_commands[0];
  VALUE result = rb_ary_new2(ncmds);
  
  for (i = 0; i < ncmds; ++i)
    rb_ary_store(result, i, rb_str_new2(f_commands[i].name));
    
  return result;
}

.dispatchObject



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'ext/vlerq_ext.c', line 280

static VALUE vq_dispatch_keep (int argc, VALUE *argv, VALUE self) {
  int i, index;
  VALUE result;
  Item stack [MAX_STACK];
  ItemTypes type;
  const char *args;
  
  index = NUM2INT(argv[0]);
  
  PUSH_KEEP_REFS
  
  --argc; ++argv;
  args = f_commands[index].args + 2; /* skip return type and ':' */
  
  for (i = 0; args[i] != 0; ++i) {
    Assert(i < MAX_STACK);
    if (args[i] == 'X') {
      Assert(args[i+1] == 0);
      stack[i].u.ptr = (const void*) (argv+i);
      stack[i].u.len = argc-i;
      break;
    }
    if ((args[i] == 0 && i != argc) || (args[i] != 0 && i >= argc))
      rb_raise(rb_eRuntimeError, "wrong number of arguments");
    stack[i].o = argv[i];
    if (!CastObjToItem(args[i], stack+i))
      rb_raise(rb_eRuntimeError, "%s: error in arg %d",
                                    f_commands[index].name, i);
  }
  
  type = f_commands[index].proc(stack);
  if (type == IT_unknown)
    rb_raise(rb_eRuntimeError, "%s: error in result", f_commands[index].name);
  
  result = ItemAsObj(type, stack);
  
  POP_KEEP_REFS
  return result;
}