Showing the changes to src/core/ulib_machine.cpp (1 of 4 files). Show all
Unified · Split
| @@ -37,6 +37,9 @@ · 36 unmodified lines | |||
| 37 | #include "chuck_instr.h" | 37 | #include "chuck_instr.h" |
| 38 | #include "chuck.h" | 38 | #include "chuck.h" |
| 39 | 39 | ||
| 40 | #include <string> | ||
| 41 | using namespace std; | ||
| 42 | |||
| 40 | 43 | ||
| 41 | 44 | ||
| 42 | 45 | ||
| @@ -68,6 +71,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 25 unmodified lines | |||
| 68 | // add documentation | 1.4.1.0 | 71 | // add documentation | 1.4.1.0 |
| 69 | QUERY->doc_class( QUERY, "runtime interface to the ChucK virtual machine." ); | 72 | QUERY->doc_class( QUERY, "runtime interface to the ChucK virtual machine." ); |
| 70 | 73 | ||
| 74 | #ifndef __DISABLE_OTF_SERVER__ | ||
| 71 | // add add | 75 | // add add |
| 72 | //! compile and spork a new shred from file at 'path' into the VM now | 76 | //! compile and spork a new shred from file at 'path' into the VM now |
| 73 | //! returns the shred ID | 77 | //! returns the shred ID |
| @@ -105,6 +109,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 31 unmodified lines | |||
| 105 | //! (see example/status.ck) | 109 | //! (see example/status.ck) |
| 106 | QUERY->add_sfun( QUERY, machine_status_impl, "int", "status" ); | 110 | QUERY->add_sfun( QUERY, machine_status_impl, "int", "status" ); |
| 107 | QUERY->doc_func( QUERY, "display current status of virtual machine." ); | 111 | QUERY->doc_func( QUERY, "display current status of virtual machine." ); |
| 112 | #endif // __DISABLE_OTF_SERVER__ | ||
| 108 | 113 | ||
| 109 | // add shreds | 114 | // add shreds |
| 110 | //! get list of active shreds by id | 115 | //! get list of active shreds by id |
| @@ -145,6 +150,10 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 34 unmodified lines | |||
| 145 | QUERY->add_sfun( QUERY, machine_realtime_impl, "int", "realtime" ); | 150 | QUERY->add_sfun( QUERY, machine_realtime_impl, "int", "realtime" ); |
| 146 | QUERY->doc_func( QUERY, "return true if the shred is in realtime mode, false if it's in silent mode (i.e. --silent is enabled)" ); | 151 | QUERY->doc_func( QUERY, "return true if the shred is in realtime mode, false if it's in silent mode (i.e. --silent is enabled)" ); |
| 147 | 152 | ||
| 153 | // get version string | ||
| 154 | QUERY->add_sfun( QUERY, machine_version_impl, "string", "version" ); | ||
| 155 | QUERY->doc_func( QUERY, "return version string" ); | ||
| 156 | |||
| 148 | // end class | 157 | // end class |
| 149 | QUERY->end_class( QUERY ); | 158 | QUERY->end_class( QUERY ); |
| 150 | 159 | ||
| @@ -154,23 +163,6 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 3 unmodified lines | |||
| 154 | 163 | ||
| 155 | 164 | ||
| 156 | 165 | ||
| 157 | static Chuck_Compiler * the_compiler = NULL; | ||
| 158 | static proc_msg_func the_func = NULL; | ||
| 159 | //----------------------------------------------------------------------------- | ||
| 160 | // name: machine_init() | ||
| 161 | // desc: ... | ||
| 162 | //----------------------------------------------------------------------------- | ||
| 163 | t_CKBOOL machine_init( Chuck_Compiler * compiler, proc_msg_func proc_msg ) | ||
| 164 | { | ||
| 165 | the_compiler = compiler; | ||
| 166 | the_func = proc_msg; | ||
| 167 | |||
| 168 | return TRUE; | ||
| 169 | } | ||
| 170 | |||
| 171 | |||
| 172 | |||
| 173 | |||
| 174 | //----------------------------------------------------------------------------- | 166 | //----------------------------------------------------------------------------- |
| 175 | // name: machine_intsize() | 167 | // name: machine_intsize() |
| 176 | // desc: integer size in bits | 168 | // desc: integer size in bits |
| @@ -218,6 +210,24 @@ t_CKUINT machine_eval( Chuck_String * codeStr, Chuck_String * argsTogether, · 41 unmodified lines | |||
| 218 | 210 | ||
| 219 | 211 | ||
| 220 | 212 | ||
| 213 | |||
| 214 | |||
| 215 | #ifndef __DISABLE_OTF_SERVER__ | ||
| 216 | static Chuck_Compiler * the_compiler = NULL; | ||
| 217 | static proc_msg_func the_func = NULL; | ||
| 218 | //----------------------------------------------------------------------------- | ||
| 219 | // name: machine_init() | ||
| 220 | // desc: ... | ||
| 221 | //----------------------------------------------------------------------------- | ||
| 222 | t_CKBOOL machine_init( Chuck_Compiler * compiler, proc_msg_func proc_msg ) | ||
| 223 | { | ||
| 224 | the_compiler = compiler; | ||
| 225 | the_func = proc_msg; | ||
| 226 | |||
| 227 | return TRUE; | ||
| 228 | } | ||
| 229 | |||
| 230 | |||
| 221 | // add | 231 | // add |
| 222 | CK_DLL_SFUN( machine_crash_impl ) | 232 | CK_DLL_SFUN( machine_crash_impl ) |
| 223 | { | 233 | { |
| @@ -269,6 +279,8 @@ CK_DLL_SFUN( machine_status_impl ) · 45 unmodified lines | |||
| 269 | RETURN->v_int = (int)the_func( SHRED->vm_ref, the_compiler, &msg, TRUE, NULL ); | 279 | RETURN->v_int = (int)the_func( SHRED->vm_ref, the_compiler, &msg, TRUE, NULL ); |
| 270 | } | 280 | } |
| 271 | 281 | ||
| 282 | #endif // __DISABLE_OTF_SERVER__ | ||
| 283 | |||
| 272 | // intsize | 284 | // intsize |
| 273 | CK_DLL_SFUN( machine_intsize_impl ) | 285 | CK_DLL_SFUN( machine_intsize_impl ) |
| 274 | { | 286 | { |
| @@ -330,3 +342,15 @@ CK_DLL_SFUN( machine_eval3_impl ) · 55 unmodified lines | |||
| 330 | 342 | ||
| 331 | RETURN->v_int = machine_eval( code, argsTogether, count, VM ); | 343 | RETURN->v_int = machine_eval( code, argsTogether, count, VM ); |
| 332 | } | 344 | } |
| 345 | |||
| 346 | CK_DLL_SFUN( machine_version_impl ) | ||
| 347 | { | ||
| 348 | // get version string | ||
| 349 | string vs = VM->carrier()->chuck->version(); | ||
| 350 | // make chuck string | ||
| 351 | Chuck_String * s = new Chuck_String( vs ); | ||
| 352 | // initialize | ||
| 353 | initialize_object(s, VM->carrier()->env->t_string ); | ||
| 354 | // return | ||
| 355 | RETURN->v_string = s; | ||
| 356 | } | ||