Example #1
0
		void ScreenEventWrapper::load_ruby_class(void)
		{
			if (!Interpreter::Ruby::get_config()->is_on("RAGE::ScreenEvent")) return;

			VALUE rage = rb_define_module("RAGE");
			rb_rage_ScreenEventClass = rb_define_class_under(rage, "ScreenEvent", EventWrapper::get_ruby_class());

			VALUE events = rb_define_module_under(rage, "Events");
			rb_define_const(events, "SCREEN", INT2FIX(RAGE_SCREEN_EVENT));
			rb_define_const(events, "SCREEN_CLOSE", INT2FIX(RAGE_EVENT_SCREEN_CLOSE));
			rb_define_const(events, "SCREEN_FOCUS", INT2FIX(RAGE_EVENT_SCREEN_FOCUS));
			rb_define_const(events, "SCREEN_LOST", INT2FIX(RAGE_EVENT_SCREEN_LOST));
			rb_define_const(events, "SCREEN_RESIZE", INT2FIX(RAGE_EVENT_SCREEN_RESIZE));

			rb_define_alloc_func(rb_rage_ScreenEventClass, ScreenEventWrapper::rb_screen_event_alloc);

			rb_define_method(rb_rage_ScreenEventClass, "initialize", RFUNC(ScreenEventWrapper::rb_initialize), -1);
			rb_define_method(rb_rage_ScreenEventClass, "register", RFUNC(ScreenEventWrapper::rb_register), 2);
			rb_define_method(rb_rage_ScreenEventClass, "unregister", RFUNC(ScreenEventWrapper::rb_unregister), 2);
			rb_define_method(rb_rage_ScreenEventClass, "clear", RFUNC(ScreenEventWrapper::rb_clear), 1);
			rb_define_method(rb_rage_ScreenEventClass, "run", RFUNC(ScreenEventWrapper::rb_run), 1);
			rb_define_method(rb_rage_ScreenEventClass, "getProcCount", RFUNC(ScreenEventWrapper::rb_get_proc_count), 1);
			rb_define_method(rb_rage_ScreenEventClass, "getProcsAsArray", RFUNC(ScreenEventWrapper::rb_get_procs_array), 1);
			rb_define_method(rb_rage_ScreenEventClass, "dispose", RFUNC(ScreenEventWrapper::rb_dispose), 0);
			rb_define_method(rb_rage_ScreenEventClass, "disposed?", RFUNC(ScreenEventWrapper::rb_disposed), 0);
		}
Example #2
0
		void FileWrapper::load_ruby_class(void)
		{
			if (!Interpreter::Ruby::get_config()->is_on("RAGE::File")) return;

			VALUE rage = rb_define_module("RAGE");
			rb_rageFileClass = rb_define_class_under(rage, "File", BaseFileWrapper::get_ruby_class());

			rb_define_alloc_func(rb_rageFileClass, FileWrapper::rb_alloc);

			rb_define_method(rb_rageFileClass, "initialize", RFUNC(FileWrapper::rb_initialize), -1);
			rb_define_method(rb_rageFileClass, "isOpen?", RFUNC(FileWrapper::rb_is_open), 0);
			rb_define_method(rb_rageFileClass, "eof?", RFUNC(FileWrapper::rb_is_eof), 0);
			rb_define_method(rb_rageFileClass, "size", RFUNC(FileWrapper::rb_get_size), 0);
			rb_define_method(rb_rageFileClass, "open", RFUNC(FileWrapper::rb_open), 2);
			rb_define_method(rb_rageFileClass, "read", RFUNC(FileWrapper::rb_read), -1);
			rb_define_method(rb_rageFileClass, "write", RFUNC(FileWrapper::rb_write), 1);
			rb_define_method(rb_rageFileClass, "writeByte", RFUNC(FileWrapper::rb_write_byte), 1);
			rb_define_method(rb_rageFileClass, "writeWord", RFUNC(FileWrapper::rb_write_word), 1);
			rb_define_method(rb_rageFileClass, "writeDWord", RFUNC(FileWrapper::rb_write_dword), 1);
			rb_define_method(rb_rageFileClass, "writeFloat", RFUNC(FileWrapper::rb_write_float), 1);
			rb_define_method(rb_rageFileClass, "writeDouble", RFUNC(FileWrapper::rb_write_double), 1);
			rb_define_method(rb_rageFileClass, "readByte", RFUNC(FileWrapper::rb_read_byte), 0);
			rb_define_method(rb_rageFileClass, "readWord", RFUNC(FileWrapper::rb_read_word), 0);
			rb_define_method(rb_rageFileClass, "readDWord", RFUNC(FileWrapper::rb_read_dword), 0);
			rb_define_method(rb_rageFileClass, "readFloat", RFUNC(FileWrapper::rb_read_float), 0);
			rb_define_method(rb_rageFileClass, "readDouble", RFUNC(FileWrapper::rb_read_double), 0);
			rb_define_method(rb_rageFileClass, "position=", RFUNC(FileWrapper::rb_set_position), 1);
			rb_define_method(rb_rageFileClass, "position", RFUNC(FileWrapper::rb_get_position), 0);
			rb_define_method(rb_rageFileClass, "close", RFUNC(FileWrapper::rb_close), 0);
			rb_define_method(rb_rageFileClass, "dispose", RFUNC(FileWrapper::rb_dispose), 0);
			rb_define_method(rb_rageFileClass, "disposed?", RFUNC(FileWrapper::rb_is_disposed), 0);

		}
static void FUNC ( void )
{
  static UINT4   dims[3]    = { 1, 2, 4 };
  UINT4Vector    dimLength  = { 3, dims };
#ifndef LAL_NDEBUG
  static UINT4   dbad[3]    = { 1, 0, 4 };
  UINT4Vector    badLength1 = { 3, NULL };
  UINT4Vector    badLength2 = { 0, dims };
  UINT4Vector    badLength3 = { 3, dbad };
#endif
  static LALStatus  status;
  static VTYPE  *array;
  static VTYPE   astore;
  static TYPE    datum;


  /*
   *
   * Test ordinary behavior.
   *
   */


  CFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  /* resize up */
  /*
   * dimLength.data[0] *= 2;
   * dimLength.data[1] *= 3;
   * dimLength.data[2] *= 4;
  */
  dims[0] *= 2;
  dims[1] *= 3;
  dims[2] *= 4;
  RFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  /* resize down */
  dims[0] /= 2;
  dims[1] /= 3;
  dims[2] /= 2;
  RFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  /* resize down again */
  dims[2] /= 2;
  RFUNC ( &status, &array, &dimLength );
  TestStatus( &status, CODES( 0 ), 1 );

  memset( array->data, 0, dims[0]*dims[1]*dims[2]*sizeof( TYPE ) );

  DFUNC ( &status, &array );
  TestStatus( &status, CODES( 0 ), 1 );

  LALCheckMemoryLeaks();


  /*
   *
   * Test error codes.
   *
   */


#ifndef LAL_NDEBUG

  if ( ! lalNoDebug )
  {
    CFUNC ( &status, &array, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    RFUNC ( &status, &array, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    CFUNC ( &status, &array, &badLength2 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );

    RFUNC ( &status, &array, &badLength2 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );

    CFUNC ( &status, &array, &badLength3 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );

    RFUNC ( &status, &array, &badLength3 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1 );
    LALCheckMemoryLeaks();

    DFUNC ( &status, NULL );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    CFUNC ( &status, NULL, &dimLength );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    RFUNC ( &status, NULL, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1 );

    DFUNC ( &status, &array );
    TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );

    array = &astore;
    CFUNC ( &status, &array, &dimLength );
    TestStatus( &status, CODES( AVFACTORIESH_EUPTR ), 1 );

    RFUNC ( &status, &array, &badLength1 );
    TestStatus( &status, CODES( AVFACTORIESH_EVPTR ), 1);

    RFUNC ( &status, &array, &badLength2 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);

    RFUNC ( &status, &array, &badLength3 );
    TestStatus( &status, CODES( AVFACTORIESH_ELENGTH ), 1);

    DFUNC ( &status, &array );
    TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );

    array->data = &datum;
    DFUNC ( &status, &array );
    TestStatus( &status, CODES( AVFACTORIESH_EDPTR ), 1 );
    ClearStatus( &status );
  }

#else
  array = &astore;
  array->data = &datum;
#endif

  LALCheckMemoryLeaks();
  printf( "PASS: tests of %s, %s, and %s\n", STRING(CFUNC), STRING(RFUNC), STRING(DFUNC));

  return;
}
Example #4
0
void JoystickWrapper::load_ruby_class(void)
{
    if (!Interpreter::Ruby::get_config()->is_on("RAGE::Joystick")) return;

    VALUE rage = rb_define_module("RAGE");

    rb_rage_JoystickClass = rb_define_class_under(rage, "Joystick", rb_cObject);

    rb_define_alloc_func(rb_rage_JoystickClass, JoystickWrapper::rb_alloc);

    rb_define_method(rb_rage_JoystickClass, "initialize", RFUNC(JoystickWrapper::rb_initialize), 1);
    rb_define_method(rb_rage_JoystickClass, "isActive?", RFUNC(JoystickWrapper::rb_is_active), 0);
    rb_define_method(rb_rage_JoystickClass, "buttonRepeat?", RFUNC(JoystickWrapper::rb_button_repeat), 1);
    rb_define_method(rb_rage_JoystickClass, "buttonDown?", RFUNC(JoystickWrapper::rb_button_down), 1);
    rb_define_method(rb_rage_JoystickClass, "buttonUp?", RFUNC(JoystickWrapper::rb_button_up), 1);
    rb_define_method(rb_rage_JoystickClass, "getAxis", RFUNC(JoystickWrapper::rb_get_axis), 2);
    rb_define_method(rb_rage_JoystickClass, "getName", RFUNC(JoystickWrapper::rb_get_name), 0);
    rb_define_method(rb_rage_JoystickClass, "getButtonName", RFUNC(JoystickWrapper::rb_get_button_name), 1);
    rb_define_method(rb_rage_JoystickClass, "getStickName", RFUNC(JoystickWrapper::rb_get_stick_name), 1);
    rb_define_method(rb_rage_JoystickClass, "getAxisName", RFUNC(JoystickWrapper::rb_get_axis_name), 2);
    rb_define_method(rb_rage_JoystickClass, "getMaxButtons", RFUNC(JoystickWrapper::rb_get_max_buttons), 0);
    rb_define_method(rb_rage_JoystickClass, "getMaxSticks", RFUNC(JoystickWrapper::rb_get_max_sticks), 0);
    rb_define_method(rb_rage_JoystickClass, "getMaxAxis", RFUNC(JoystickWrapper::rb_get_max_axis), 1);
    rb_define_method(rb_rage_JoystickClass, "update", RFUNC(JoystickWrapper::rb_update), 0);
    rb_define_method(rb_rage_JoystickClass, "dispose", RFUNC(JoystickWrapper::rb_dispose), 0);
    rb_define_method(rb_rage_JoystickClass, "disposed?", RFUNC(JoystickWrapper::rb_is_disposed), 0);

}