//----------------------------------------------------------------------------- // name: init_class_dude() // desc: ... //----------------------------------------------------------------------------- t_CKBOOL init_class_dude( Chuck_Env * env ) { Chuck_DL_Func * func = NULL; Chuck_Value * value = NULL; // log EM_log( CK_LOG_INFO, "class 'AudicleDude'" ); // import if( !type_engine_import_class_begin( env, "AudicleDude", "Object", env->global(), dude_ctor ) ) return FALSE; // add member dude_offset_data = type_engine_import_mvar( env, "int", "@data", FALSE ); if( dude_offset_data == CK_INVALID_OFFSET ) goto error; // add jump() func = make_new_mfun( "void", "jump", dude_jump ); if( !type_engine_import_mfun( env, func ) ) goto error; // add headbang() func = make_new_mfun( "void", "headbang", dude_headbang ); if( !type_engine_import_mfun( env, func ) ) goto error; // add leanback() func = make_new_mfun( "void", "leanback", dude_leanback ); if( !type_engine_import_mfun( env, func ) ) goto error; // add armsup() func = make_new_mfun( "int", "armsup", dude_armsup ); if( !type_engine_import_mfun( env, func ) ) goto error; // add setpos() func = make_new_mfun( "void", "pos", dude_pos ); func->add_arg( "float", "x" ); func->add_arg( "float", "y" ); func->add_arg( "float", "z" ); if( !type_engine_import_mfun( env, func ) ) goto error; // end the class import type_engine_import_class_end( env ); // keep the type around g_dude_type = type_engine_find_type( env, new_id_list("AudicleDude", 0 ) ); return TRUE; error: // end the class import type_engine_import_class_end( env ); return FALSE; }
//----------------------------------------------------------------------------- // name: init_class_pane() // desc: ... //----------------------------------------------------------------------------- t_CKBOOL init_class_pane( Chuck_Env * env ) { Chuck_DL_Func * func = NULL; Chuck_Value * value = NULL; // log EM_log( CK_LOG_INFO, "class 'AudiclePane'" ); // import if( !type_engine_import_class_begin( env, "AudiclePane", "Object", env->global(), pane_ctor ) ) return FALSE; // add member pane_offset_data = type_engine_import_mvar( env, "int", "@data", FALSE ); if( pane_offset_data == CK_INVALID_OFFSET ) goto error; // add width() func = make_new_mfun( "int", "width", pane_get_width ); if( !type_engine_import_mfun( env, func ) ) goto error; // add height() func = make_new_mfun( "int", "height", pane_get_height ); if( !type_engine_import_mfun( env, func ) ) goto error; // add setglow() func = make_new_mfun( "void", "setglow", pane_set_glow ); func->add_arg( "int", "x" ); func->add_arg( "int", "y" ); func->add_arg( "float", "val" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add getvalue() func = make_new_mfun( "int", "getvalue", pane_get_value ); func->add_arg( "int", "x" ); func->add_arg( "int", "y" ); if( !type_engine_import_mfun( env, func ) ) goto error; // end the class import type_engine_import_class_end( env ); // keep the type around g_pane_type = type_engine_find_type( env, new_id_list("AudiclePane", 0 ) ); return TRUE; error: // end the class import type_engine_import_class_end( env ); return FALSE; }
//----------------------------------------------------------------------------- // name: init_class_world() // desc: ... //----------------------------------------------------------------------------- t_CKBOOL init_class_world( Chuck_Env * env ) { Chuck_DL_Func * func = NULL; Chuck_Value * value = NULL; // log EM_log( CK_LOG_INFO, "class 'AudicleWorld'" ); // import if( !type_engine_import_class_begin( env, "AudicleWorld", "Object", env->global(), world_ctor ) ) return FALSE; // add leader() func = make_new_sfun( "AudicleDude", "leader", world_leader ); if( !type_engine_import_sfun( env, func ) ) goto error; // add add() func = make_new_sfun( "int", "add", world_add ); func->add_arg( "AudicleDude", "dude" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add remove() func = make_new_sfun( "int", "remove", world_remove ); func->add_arg( "AudicleDude", "dude" ); if( !type_engine_import_sfun( env, func ) ) goto error; // wrap up type_engine_import_class_end( env ); return TRUE; error: // wrap up type_engine_import_class_end( env ); return FALSE; }
//----------------------------------------------------------------------------- // name: init_class_serialio() // desc: ... //----------------------------------------------------------------------------- t_CKBOOL init_class_serialio( Chuck_Env * env ) { // init as base class Chuck_DL_Func * func = NULL; // log EM_log( CK_LOG_SEVERE, "class 'SerialIO'" ); std::string doc = "Handles reading and writing for serial input/output devices, such as Arduino."; Chuck_Type * type = type_engine_import_class_begin( env, "SerialIO", "IO", env->global(), serialio_ctor, serialio_dtor, doc.c_str() ); // TODO: ctor/dtor? if( !type ) return FALSE; // HACK; SPENCERTODO: better way to set this type->allocator = serialio_alloc; // add list() func = make_new_sfun( "string[]", "list", serialio_list ); func->doc = "Return list of available serial devices."; if( !type_engine_import_sfun( env, func ) ) goto error; func = make_new_mfun("int", "open", serialio_open); func->add_arg("int", "i"); func->add_arg("int", "baud"); func->add_arg("int", "mode"); func->doc = "Open serial device i with specified baud rate and mode (binary or ASCII)."; if( !type_engine_import_mfun( env, func ) ) goto error; func = make_new_mfun("void", "close", serialio_close); if( !type_engine_import_mfun( env, func ) ) goto error; // add ready (data available) func = make_new_mfun("int", "dataAvailable", serialio_ready); if( !type_engine_import_mfun( env, func ) ) goto error; // add readLine func = make_new_mfun("string", "readLine", serialio_readLine); if( !type_engine_import_mfun( env, func ) ) goto error; // add onLine func = make_new_mfun("SerialIO", "onLine", serialio_onLine); func->doc = "Wait for one line (ASCII mode only)."; if( !type_engine_import_mfun( env, func ) ) goto error; // add onByte func = make_new_mfun("SerialIO", "onByte", serialio_onByte); func->doc = "Wait for one byte (binary mode only)."; if( !type_engine_import_mfun( env, func ) ) goto error; // add onBytes func = make_new_mfun("SerialIO", "onBytes", serialio_onBytes); func->add_arg("int", "num"); func->doc = "Wait for requested number of bytes (binary mode only)."; if( !type_engine_import_mfun( env, func ) ) goto error; // add onInts func = make_new_mfun("SerialIO", "onInts", serialio_onInts); func->add_arg("int", "num"); func->doc = "Wait for requested number of ints (ASCII or binary mode)."; if( !type_engine_import_mfun( env, func ) ) goto error; // add onInts func = make_new_mfun("SerialIO", "onFloats", serialio_onFloats); func->add_arg("int", "num"); func->doc = "Wait for requested number of floats (ASCII or binary mode)."; if( !type_engine_import_mfun( env, func ) ) goto error; // add getLine func = make_new_mfun("string", "getLine", serialio_getLine); func->doc = "Get next requested line."; if( !type_engine_import_mfun( env, func ) ) goto error; // add getByte func = make_new_mfun("int", "getByte", serialio_getByte); func->doc = "Get next requested byte. "; if( !type_engine_import_mfun( env, func ) ) goto error; // add getBytes func = make_new_mfun("int[]", "getBytes", serialio_getBytes); func->doc = "Get next requested number of bytes. "; if( !type_engine_import_mfun( env, func ) ) goto error; // add getInts func = make_new_mfun("int[]", "getInts", serialio_getInts); func->doc = "Get next requested number of integers. "; if( !type_engine_import_mfun( env, func ) ) goto error; // add writeByte func = make_new_mfun("void", "writeByte", serialio_writeByte); func->add_arg("int", "b"); func->doc = "Write a single byte."; if( !type_engine_import_mfun( env, func ) ) goto error; // add writeBytes func = make_new_mfun("void", "writeBytes", serialio_writeBytes); func->add_arg("int[]", "b"); func->doc = "Write array of bytes."; if( !type_engine_import_mfun( env, func ) ) goto error; // add setBaudRate func = make_new_mfun("int", "baudRate", serialio_setBaudRate); func->add_arg("int", "r"); func->doc = "Set baud rate."; if( !type_engine_import_mfun( env, func ) ) goto error; // add getBaudRate func = make_new_mfun("int", "baudRate", serialio_getBaudRate); func->doc = "Get current baud rate."; if( !type_engine_import_mfun( env, func ) ) goto error; // add getBaudRate func = make_new_mfun("void", "flush", serialio_flush); func->doc = "Flush the IO buffer."; if( !type_engine_import_mfun( env, func ) ) goto error; // add can_wait // func = make_new_mfun("int", "can_wait", serialio_canWait); // func->doc = ""; // if( !type_engine_import_mfun( env, func ) ) goto error; // add baud rate constants type_engine_import_svar(env, "int", "B2400", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_2400, "2400 baud"); type_engine_import_svar(env, "int", "B4800", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_4800, "4800 baud"); type_engine_import_svar(env, "int", "B9600", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_9600, "9600 baud"); type_engine_import_svar(env, "int", "B19200", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_19200, "19200 baud"); type_engine_import_svar(env, "int", "B38400", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_38400, "38400 baud"); type_engine_import_svar(env, "int", "B7200", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_7200, "7200 baud"); type_engine_import_svar(env, "int", "B14400", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_14400, "14400 baud"); type_engine_import_svar(env, "int", "B28800", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_28800, "28800 baud"); type_engine_import_svar(env, "int", "B57600", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_57600, "57600 baud"); type_engine_import_svar(env, "int", "B76800", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_76800, "76800 baud"); type_engine_import_svar(env, "int", "B115200", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_115200, "115200 baud"); type_engine_import_svar(env, "int", "B230400", TRUE, (t_CKUINT) &Chuck_IO_Serial::CK_BAUD_230400, "230400 baud"); type_engine_import_svar(env, "int", "BINARY", TRUE, (t_CKUINT) &Chuck_IO_File::TYPE_BINARY, "Binary mode"); type_engine_import_svar(env, "int", "ASCII", TRUE, (t_CKUINT) &Chuck_IO_File::TYPE_ASCII, "ASCII mode"); // add examples if( !type_engine_import_add_ex( env, "serial/byte.ck" ) ) goto error; if( !type_engine_import_add_ex( env, "serial/bytes.ck" ) ) goto error; if( !type_engine_import_add_ex( env, "serial/ints-bin.ck" ) ) goto error; if( !type_engine_import_add_ex( env, "serial/ints.ck" ) ) goto error; if( !type_engine_import_add_ex( env, "serial/lines.ck" ) ) goto error; if( !type_engine_import_add_ex( env, "serial/list.ck" ) ) goto error; if( !type_engine_import_add_ex( env, "serial/write-bytes.ck" ) ) goto error; if( !type_engine_import_add_ex( env, "serial/write.ck" ) ) goto error; // end the class import type_engine_import_class_end( env ); return TRUE; error: // end the class import type_engine_import_class_end( env ); return FALSE; }
//----------------------------------------------------------------------------- // name: init_class_mouse_mania() // desc: ... //----------------------------------------------------------------------------- t_CKBOOL init_class_mouse_mania( Chuck_Env * env ) { Chuck_DL_Func * func = NULL; Chuck_Value * value = NULL; // log EM_log( CK_LOG_INFO, "class 'AudicleMouseMania'" ); // import if( !type_engine_import_class_begin( env, "AudicleMouseMania", "Object", env->global(), mouse_mania_ctor ) ) return FALSE; // add pane() func = make_new_sfun( "AudicleMousePane", "pane", mouse_mania_pane ); if( !type_engine_import_sfun( env, func ) ) goto error; // add go() func = make_new_sfun( "void", "go", mouse_mania_go ); func->add_arg( "float", "duration" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add get_item() func = make_new_sfun( "int", "get_item", mouse_mania_get ); func->add_arg( "int", "index" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add get_teleport_in() func = make_new_sfun( "int", "get_teleport_in", mouse_mania_in ); if( !type_engine_import_sfun( env, func ) ) goto error; // add get_teleport_out() func = make_new_sfun( "int", "get_teleport_out", mouse_mania_out ); if( !type_engine_import_sfun( env, func ) ) goto error; // add add_mouse() func = make_new_sfun( "void", "add_mouse", mouse_mania_add ); func->add_arg( "int", "from" ); func->add_arg( "int", "note" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add get_num_mice() func = make_new_sfun( "int", "get_num_mice", mouse_mania_get_num_mice ); if( !type_engine_import_sfun( env, func ) ) goto error; // add get_volume() func = make_new_sfun( "float", "get_volume", mouse_mania_get_volume ); if( !type_engine_import_sfun( env, func ) ) goto error; // add get_volume2() func = make_new_sfun( "float", "get_volume2", mouse_mania_get_volume2 ); if( !type_engine_import_sfun( env, func ) ) goto error; // wrap up type_engine_import_class_end( env ); return TRUE; error: // wrap up type_engine_import_class_end( env ); return FALSE; }
//----------------------------------------------------------------------------- // name: init_class_floor() // desc: ... //----------------------------------------------------------------------------- t_CKBOOL init_class_floor( Chuck_Env * env ) { Chuck_DL_Func * func = NULL; Chuck_Value * value = NULL; // log EM_log( CK_LOG_INFO, "class 'AudicleFloor'" ); // import if( !type_engine_import_class_begin( env, "AudicleFloor", "Object", env->global(), floor_ctor ) ) return FALSE; // add event() func = make_new_sfun( "Event", "event", floor_event ); if( !type_engine_import_sfun( env, func ) ) goto error; // add which() func = make_new_sfun( "int", "which", floor_which ); if( !type_engine_import_sfun( env, func ) ) goto error; // add credits() func = make_new_sfun( "int", "credits", floor_set_credits ); func->add_arg( "int", "val" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add credits() func = make_new_sfun( "int", "credits", floor_get_credits ); if( !type_engine_import_sfun( env, func ) ) goto error; // add addCredits; func = make_new_sfun( "int", "addCredits", floor_add_credits ); func->add_arg( "int", "val" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add message() func = make_new_sfun( "void", "message", floor_message ); func->add_arg( "string", "msg" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add bgcolor() func = make_new_sfun( "int", "bgcolor", floor_bgcolor ); func->add_arg( "float", "r" ); func->add_arg( "float", "g" ); func->add_arg( "float", "b" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add rotate() func = make_new_sfun( "void", "rotate", floor_rotate ); func->add_arg( "float", "r" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add angle() func = make_new_sfun( "void", "angle", floor_angle ); func->add_arg( "float", "r" ); func->add_arg( "float", "inc" ); if( !type_engine_import_sfun( env, func ) ) goto error; // add translate() func = make_new_sfun( "void", "translate", floor_translate ); func->add_arg( "float", "r" ); func->add_arg( "float", "inc" ); if( !type_engine_import_sfun( env, func ) ) goto error; // wrap up type_engine_import_class_end( env ); return TRUE; error: // wrap up type_engine_import_class_end( env ); return FALSE; }
//----------------------------------------------------------------------------- // name: libstd_query() // desc: query entry point //----------------------------------------------------------------------------- DLL_QUERY libstd_query( Chuck_DL_Query * QUERY ) { // get global Chuck_Env * env = Chuck_Env::instance(); // set name QUERY->setname( QUERY, "Std" ); /*! \example std.rand2f( 100.0, 1000.0 ) => stdout; */ // register deprecate type_engine_register_deprecate( env, "std", "Std" ); // begin class QUERY->begin_class( QUERY, "Std", "Object" ); QUERY->doc_class( QUERY, "Std is a standard library in ChucK, which includes utility functions for random number generation, unit conversions, and absolute value." ); // add abs QUERY->add_sfun( QUERY, abs_impl, "int", "abs" ); QUERY->add_arg( QUERY, "int", "value" ); QUERY->doc_func( QUERY, "Return absolute value of integer." ); // add fabs QUERY->add_sfun( QUERY, fabs_impl, "float", "fabs" ); QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Return absolute value of float." ); // add rand QUERY->add_sfun( QUERY, rand_impl, "int", "rand"); //! return int between 0 and RAND_MAX QUERY->doc_func( QUERY, "Generates random integer between 0 and Std.RAND_MAX. (NOTE: soon-to-be-deprecated; use Math.random2())." ); // add rand2 QUERY->add_sfun( QUERY, rand2_impl, "int", "rand2" ); //! integer between [min,max] QUERY->add_arg( QUERY, "int", "min" ); QUERY->add_arg( QUERY, "int", "max" ); QUERY->doc_func( QUERY, "Generates random integer in range [min, max]. (NOTE: soon-to-be-deprecated; use Math.random2())." ); // add rand QUERY->add_sfun( QUERY, randf_impl, "float", "randf" ); //! rand between -1.0,1.0 QUERY->doc_func( QUERY, "Return random floating point number in the range [-1, 1]. (Note: soon-to-be-deprecated; use Math.randomf())" ); // add rand2 QUERY->add_sfun( QUERY, rand2f_impl, "float", "rand2f" ); //! rand between min and max QUERY->add_arg( QUERY, "float", "min" ); QUERY->add_arg( QUERY, "float", "max" ); QUERY->doc_func( QUERY, "Return random floating point number in the range [min, max]. (NOTE: soon-to-be-deprecated; use Math.random2f())" ); // add srand QUERY->add_sfun( QUERY, srand_impl, "void", "srand" ); QUERY->add_arg( QUERY, "int", "seed" ); QUERY->doc_func( QUERY, "Provide a seed to the random function. Different seeds will generate very different sequences of random numbers even if the seeds are close together. " "Alternatively, a sequence of random numbers can be repeated by setting the same seed. " ); // add sgn QUERY->add_sfun( QUERY, sgn_impl, "float", "sgn" ); //! return sign of value (-1, 0, 1) QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Computes the sign of the input as -1.0 (negative), 0 (zero), or 1.0 (positive)." ); // add system //! see \example std.ck QUERY->add_sfun( QUERY, system_impl, "int", "system" ); //! issue system command QUERY->add_arg( QUERY, "string", "cmd" ); QUERY->doc_func( QUERY, "Pass a command to be executed in the shell (requires --caution-to-the-wind command-line flag)." ); // add atoi QUERY->add_sfun( QUERY, atoi_impl, "int", "atoi" ); //! string to integer QUERY->add_arg( QUERY, "string", "value" ); QUERY->doc_func( QUERY, "Converts ascii (string) to integer (int)." ); // add atof QUERY->add_sfun( QUERY, atof_impl, "float", "atof" ); //! string to float QUERY->add_arg( QUERY, "string", "value" ); QUERY->doc_func( QUERY, "Converts ascii (string) to floating point value (float)." ); // add itoa QUERY->add_sfun( QUERY, itoa_impl, "string", "itoa" ); //! int to string QUERY->add_arg( QUERY, "int", "i" ); QUERY->doc_func( QUERY, "Converts integer (int) to ascii (string)." ); // add ftoa QUERY->add_sfun( QUERY, ftoa_impl, "string", "ftoa" ); //! float to string QUERY->add_arg( QUERY, "float", "f" ); QUERY->add_arg( QUERY, "int", "precision" ); QUERY->doc_func( QUERY, "Converts floating point value (float) to ascii (string) with specified precision (number of decimal digits)." ); // add ftoi QUERY->add_sfun( QUERY, ftoi_impl, "int", "ftoi" ); //! float to int QUERY->add_arg( QUERY, "float", "f" ); QUERY->doc_func( QUERY, "Convert float to int. " ); // add getenv QUERY->add_sfun( QUERY, getenv_impl, "string", "getenv" ); //! fetch environment variable QUERY->add_arg( QUERY, "string", "value" ); QUERY->doc_func( QUERY, "Returns the value of an environment variable, such as of PATH." ); // add setenv QUERY->add_sfun( QUERY, setenv_impl, "int", "setenv" ); //! set environment variable QUERY->add_arg( QUERY, "string", "key" ); QUERY->add_arg( QUERY, "string", "value" ); QUERY->doc_func( QUERY, "Set value of environment variable named key to value." ); // add mtof //! see \example mand-o-matic.ck QUERY->add_sfun( QUERY, mtof_impl, "float", "mtof" ); //! midi note to frequency QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert a MIDI note number to frequency (Hz). Note the input value is of type float (supports fractional note number)." ); // add ftom QUERY->add_sfun( QUERY, ftom_impl, "float", "ftom" ); //! frequency to midi note QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert frequency (Hz) to MIDI note number space." ); // add powtodb QUERY->add_sfun( QUERY, powtodb_impl, "float", "powtodb" ); //! linear power to decibel QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert signal power ratio to decibels (dB)." ); // add rmstodb QUERY->add_sfun( QUERY, rmstodb_impl, "float", "rmstodb" ); //! rms to decibel QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert rms to decibels (dB)." ); // add dbtopow QUERY->add_sfun( QUERY, dbtopow_impl, "float", "dbtopow" ); //! decibel to linear QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert decibels (dB) to signal power ratio." ); // add dbtorms QUERY->add_sfun( QUERY, dbtorms_impl, "float", "dbtorms" ); //! decibel to rms QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert decibels (dB) to rms." ); // add dbtolin QUERY->add_sfun( QUERY, dbtolin_impl, "float", "dbtolin" ); //! decibel to linear QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert decibels (dB) to linear amplitude." ); // add lintodb QUERY->add_sfun( QUERY, lintodb_impl, "float", "lintodb" ); //! linear to decibel QUERY->add_arg( QUERY, "float", "value" ); QUERY->doc_func( QUERY, "Convert linear amplitude to decibels (dB)."); // add clamp QUERY->add_sfun( QUERY, clamp_impl, "int", "clamp" ); //! clamp to range (int) QUERY->add_arg( QUERY, "int", "value" ); QUERY->add_arg( QUERY, "int", "min" ); QUERY->add_arg( QUERY, "int", "max" ); QUERY->doc_func( QUERY, "Clamp integer to range [min, max]." ); // add clampf QUERY->add_sfun( QUERY, clampf_impl, "float", "clampf" ); //! clamp to range (float) QUERY->add_arg( QUERY, "float", "value" ); QUERY->add_arg( QUERY, "float", "min" ); QUERY->add_arg( QUERY, "float", "max" ); QUERY->doc_func( QUERY, "Clamp float to range [min, max]." ); // add scalef QUERY->add_sfun( QUERY, scalef_impl, "float", "scalef" ); //! scale from source range to dest range (float) QUERY->add_arg( QUERY, "float", "value" ); QUERY->add_arg( QUERY, "float", "srcmin" ); QUERY->add_arg( QUERY, "float", "srcmax" ); QUERY->add_arg( QUERY, "float", "dstmin" ); QUERY->add_arg( QUERY, "float", "dstmax" ); QUERY->doc_func( QUERY, "Scale a float from source range to destination range." ); // finish class QUERY->end_class( QUERY ); // seed the rand srand( time( NULL ) ); Chuck_DL_Func * func = NULL; #ifndef __DISABLE_KBHIT__ // KBHit // begin class (KBHit) if( !type_engine_import_class_begin( env, "KBHit", "Event", env->global(), KBHit_ctor, KBHit_dtor ) ) return FALSE; // add member variable KBHit_offset_data = type_engine_import_mvar( env, "int", "@KBHit_data", FALSE ); if( KBHit_offset_data == CK_INVALID_OFFSET ) goto error; // add on() func = make_new_mfun( "void", "on", KBHit_on ); if( !type_engine_import_mfun( env, func ) ) goto error; // add off() func = make_new_mfun( "void", "off", KBHit_off ); if( !type_engine_import_mfun( env, func ) ) goto error; // add state() func = make_new_mfun( "void", "state", KBHit_state ); if( !type_engine_import_mfun( env, func ) ) goto error; // add hit() func = make_new_mfun( "Event", "hit", KBHit_hit ); if( !type_engine_import_mfun( env, func ) ) goto error; // add more() func = make_new_mfun( "int", "more", KBHit_more ); if( !type_engine_import_mfun( env, func ) ) goto error; // add getchar() func = make_new_mfun( "int", "getchar", KBHit_getchar ); if( !type_engine_import_mfun( env, func ) ) goto error; // add can_wait() func = make_new_mfun( "int", "can_wait", KBHit_can_wait ); if( !type_engine_import_mfun( env, func ) ) goto error; // end class type_engine_import_class_end( env ); // start it KBHitManager::init(); #endif // __DISABLE_KBHIT__ // register deprecate type_engine_register_deprecate( env, "Skot", "ConsoleInput" ); #ifndef __DISABLE_PROMPTER__ // begin class (Skot) if( !type_engine_import_class_begin( env, "ConsoleInput", "Event", env->global(), Skot_ctor, Skot_dtor ) ) return FALSE; // add member variable Skot_offset_data = type_engine_import_mvar( env, "int", "@Skot_data", FALSE ); if( Skot_offset_data == CK_INVALID_OFFSET ) goto error; // add prompt() func = make_new_mfun( "Event", "prompt", Skot_prompt ); if( !type_engine_import_mfun( env, func ) ) goto error; // add prompt() func = make_new_mfun( "Event", "prompt", Skot_prompt2 ); func->add_arg( "string", "what" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add ready() func = make_new_mfun( "int", "more", Skot_more ); if( !type_engine_import_mfun( env, func ) ) goto error; // add getString() func = make_new_mfun( "string", "getLine", Skot_getLine ); if( !type_engine_import_mfun( env, func ) ) goto error; // add can_wait() func = make_new_mfun( "int", "can_wait", Skot_can_wait ); if( !type_engine_import_mfun( env, func ) ) goto error; // end class type_engine_import_class_end( env ); #endif // __DISABLE_PROMPTER__ // register deprecate type_engine_register_deprecate( env, "PRC", "StringTokenizer" ); // begin class (StrTok) if( !type_engine_import_class_begin( env, "StringTokenizer", "Object", env->global(), StrTok_ctor, StrTok_dtor ) ) return FALSE; // add member variable StrTok_offset_data = type_engine_import_mvar( env, "int", "@StrTok_data", FALSE ); if( StrTok_offset_data == CK_INVALID_OFFSET ) goto error; // add set() func = make_new_mfun( "void", "set", StrTok_set ); func->add_arg( "string", "line" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add reset() func = make_new_mfun( "void", "reset", StrTok_reset ); if( !type_engine_import_mfun( env, func ) ) goto error; // add more() func = make_new_mfun( "int", "more", StrTok_more ); if( !type_engine_import_mfun( env, func ) ) goto error; // add next() func = make_new_mfun( "string", "next", StrTok_next ); if( !type_engine_import_mfun( env, func ) ) goto error; // add get() func = make_new_mfun( "string", "next", StrTok_next2 ); func->add_arg( "string", "out" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add get() func = make_new_mfun( "string", "get", StrTok_get ); func->add_arg( "int", "index" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add get() func = make_new_mfun( "string", "get", StrTok_get2 ); func->add_arg( "int", "index" ); func->add_arg( "string", "out" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add size() func = make_new_mfun( "int", "size", StrTok_size ); if( !type_engine_import_mfun( env, func ) ) goto error; // end class type_engine_import_class_end( env ); #ifdef AJAY // begin class // init base class if( !type_engine_import_class_begin( env, "VCR", "Object", env->global(), VCR_ctor ) ) return FALSE; // add member variable VCR_offset_data = type_engine_import_mvar( env, "int", "@me", FALSE ); if( VCR_offset_data == CK_INVALID_OFFSET ) goto error; // add load() func = make_new_mfun( "int", "load", VCR_load ); func->add_arg( "string", "filename" ); func->add_arg( "int", "column" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add reset() func = make_new_mfun( "int", "reset", VCR_reset ); if( !type_engine_import_mfun( env, func ) ) goto error; // add seek() func = make_new_mfun( "int", "seek", VCR_seek ); func->add_arg( "int", "where" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add more() func = make_new_mfun( "int", "more", VCR_more ); if( !type_engine_import_mfun( env, func ) ) goto error; // add curr() func = make_new_mfun( "float", "curr", VCR_curr ); if( !type_engine_import_mfun( env, func ) ) goto error; // add next() func = make_new_mfun( "int", "next", VCR_next ); if( !type_engine_import_mfun( env, func ) ) goto error; // add pos() func = make_new_mfun( "int", "pos", VCR_pos ); if( !type_engine_import_mfun( env, func ) ) goto error; // add size() func = make_new_mfun( "int", "size", VCR_size ); if( !type_engine_import_mfun( env, func ) ) goto error; // add name() func = make_new_mfun( "string", "name", VCR_name ); if( !type_engine_import_mfun( env, func ) ) goto error; // end the class import type_engine_import_class_end( env ); #if defined(__PLATFORM_WIN32__) // begin class (Cereal) if( !type_engine_import_class_begin( env, "Cereal", "Object", env->global(), Cereal_ctor ) ) return FALSE; // add member Cereal_offset_data = type_engine_import_mvar( env, "int", "@Cereal_data", FALSE ); if( Cereal_offset_data == CK_INVALID_OFFSET ) goto error; // add open() func = make_new_mfun( "int", "open", Cereal_open ); func->add_arg( "string", "name" ); func->add_arg( "int", "baudrate" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add close() func = make_new_mfun( "void", "close", Cereal_close ); if( !type_engine_import_mfun( env, func ) ) goto error; // add more() func = make_new_mfun( "int", "more", Cereal_more ); if( !type_engine_import_mfun( env, func ) ) goto error; // add send() func = make_new_mfun( "int", "send", Cereal_send ); func->add_arg( "int", "bite" ); if( !type_engine_import_mfun( env, func ) ) goto error; // add recv() func = make_new_mfun( "int", "recv", Cereal_recv ); if( !type_engine_import_mfun( env, func ) ) goto error; // end class type_engine_import_class_end( env ); #endif return TRUE; #else return TRUE; #endif error: // end the class import type_engine_import_class_end( env ); return FALSE; }