History

partially re-added Machine for webchuck; added string Machine.version()

Ge Wang committed 3 years ago

Commit bc29acf1 parent b41725e4 files · +50 −26Browse files

Unified · Split

4 files
  1. src/core/chuck_compile.cpp +1 −4
  2. src/core/ulib_machine.cpp +41 −17
  3. src/core/ulib_machine.h +4 −1
  4. src/makefile +4 −4
src/core/chuck_compile.cpp+1−4
@@ -43,10 +43,7 @@ · 42 unmodified lines
43#include "uana_xform.h"43#include "uana_xform.h"
44#include "uana_extract.h"44#include "uana_extract.h"
45 45
46#ifndef __DISABLE_OTF_SERVER__
47#include "ulib_machine.h"46#include "ulib_machine.h"
48#endif
49
50#include "ulib_ai.h"47#include "ulib_ai.h"
51#include "ulib_math.h"48#include "ulib_math.h"
52#include "ulib_std.h"49#include "ulib_std.h"
@@ -687,9 +684,9 @@ t_CKBOOL load_internal_modules( Chuck_Compiler * compiler ) · 634 unmodified lines
687 if( !load_module( compiler, env, libstd_query, "Std", "global" ) ) goto error;684 if( !load_module( compiler, env, libstd_query, "Std", "global" ) ) goto error;
688 685
689 // load686 // load
690 #ifndef __DISABLE_OTF_SERVER__
691 EM_log( CK_LOG_SEVERE, "module 'machine'" );687 EM_log( CK_LOG_SEVERE, "module 'machine'" );
692 if( !load_module( compiler, env, machine_query, "Machine", "global" ) ) goto error;688 if( !load_module( compiler, env, machine_query, "Machine", "global" ) ) goto error;
689 #ifndef __DISABLE_OTF_SERVER__
693 machine_init( compiler, otf_process_msg );690 machine_init( compiler, otf_process_msg );
694 #endif691 #endif
695 692
src/core/ulib_machine.cpp+41−17
@@ -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>
41using 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.071 // 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 add75 // add add
72 //! compile and spork a new shred from file at 'path' into the VM now76 //! compile and spork a new shred from file at 'path' into the VM now
73 //! returns the shred ID77 //! 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 shreds114 // add shreds
110 //! get list of active shreds by id115 //! 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 class157 // 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
157static Chuck_Compiler * the_compiler = NULL;
158static proc_msg_func the_func = NULL;
159//-----------------------------------------------------------------------------
160// name: machine_init()
161// desc: ...
162//-----------------------------------------------------------------------------
163t_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 bits168// 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__
216static Chuck_Compiler * the_compiler = NULL;
217static proc_msg_func the_func = NULL;
218//-----------------------------------------------------------------------------
219// name: machine_init()
220// desc: ...
221//-----------------------------------------------------------------------------
222t_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// add231// add
222CK_DLL_SFUN( machine_crash_impl )232CK_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// intsize284// intsize
273CK_DLL_SFUN( machine_intsize_impl )285CK_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
346CK_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}
src/core/ulib_machine.h+4−1
@@ -42,13 +42,15 @@ struct Chuck_Compiler; · 41 unmodified lines
42 42
43// query43// query
44DLL_QUERY machine_query( Chuck_DL_Query * QUERY );44DLL_QUERY machine_query( Chuck_DL_Query * QUERY );
45
46#ifndef __DISABLE_OTF_SERVER__
45typedef t_CKUINT (* proc_msg_func)( Chuck_VM *, Chuck_Compiler *,47typedef t_CKUINT (* proc_msg_func)( Chuck_VM *, Chuck_Compiler *,
46 Net_Msg *, t_CKBOOL, void * );48 Net_Msg *, t_CKBOOL, void * );
47t_CKBOOL machine_init( Chuck_Compiler * compiler, proc_msg_func func );49t_CKBOOL machine_init( Chuck_Compiler * compiler, proc_msg_func func );
48// 1.4.0.1: TODO: refactor out of ulib machine; not all platforms have OTF50// 1.4.0.1: TODO: refactor out of ulib machine; not all platforms have OTF
51#endif // __DISABLE_OTF_SERVER__
49t_CKUINT machine_intsize();52t_CKUINT machine_intsize();
50 53
51
52// exports54// exports
53CK_DLL_SFUN( machine_crash_impl );55CK_DLL_SFUN( machine_crash_impl );
54CK_DLL_SFUN( machine_add_impl );56CK_DLL_SFUN( machine_add_impl );
@@ -63,6 +65,7 @@ CK_DLL_SFUN( machine_silent_impl ); · 8 unmodified lines
63CK_DLL_SFUN( machine_eval_impl );65CK_DLL_SFUN( machine_eval_impl );
64CK_DLL_SFUN( machine_eval2_impl );66CK_DLL_SFUN( machine_eval2_impl );
65CK_DLL_SFUN( machine_eval3_impl );67CK_DLL_SFUN( machine_eval3_impl );
68CK_DLL_SFUN( machine_version_impl );
66 69
67 70
68#endif71#endif
src/makefile+4−4
@@ -38,10 +38,10 @@ EMSCRIPTENSRCS=host_web/chuck_emscripten.cpp \ · 37 unmodified lines
38 core/chuck_ugen.cpp core/chuck_utils.cpp core/chuck_vm.cpp \38 core/chuck_ugen.cpp core/chuck_utils.cpp core/chuck_vm.cpp \
39 core/uana_extract.cpp core/uana_xform.cpp core/ugen_filter.cpp \39 core/uana_extract.cpp core/uana_xform.cpp core/ugen_filter.cpp \
40 core/ugen_osc.cpp core/ugen_stk.cpp core/ugen_xxx.cpp \40 core/ugen_osc.cpp core/ugen_stk.cpp core/ugen_xxx.cpp \
41 core/ulib_ai.cpp core/ulib_math.cpp core/ulib_regex.cpp \41 core/ulib_ai.cpp core/ulib_machine.cpp core/ulib_math.cpp \
42 core/ulib_std.cpp core/util_buffers.cpp core/util_math.c core/util_raw.c \42 core/ulib_regex.cpp core/ulib_std.cpp core/util_buffers.cpp \
43 core/util_string.cpp core/util_xforms.c core/chuck_win32.c \43 core/util_math.c core/util_raw.c core/util_string.cpp \
44 core/util_sndfile.c44 core/util_xforms.c core/chuck_win32.c core/util_sndfile.c
45 45
46 46
47.PHONY: emscripten47.PHONY: emscripten

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t