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
4343 #include "uana_xform.h"
4444 #include "uana_extract.h"
4545
46−#ifndef __DISABLE_OTF_SERVER__
4746 #include "ulib_machine.h"
48−#endif
49−
5047 #include "ulib_ai.h"
5148 #include "ulib_math.h"
5249 #include "ulib_std.h"
@@ -687,9 +684,9 @@ t_CKBOOL load_internal_modules( Chuck_Compiler * compiler ) · 634 unmodified lines
687684 if( !load_module( compiler, env, libstd_query, "Std", "global" ) ) goto error;
688685
689686 // load
690− #ifndef __DISABLE_OTF_SERVER__
691687 EM_log( CK_LOG_SEVERE, "module 'machine'" );
692688 if( !load_module( compiler, env, machine_query, "Machine", "global" ) ) goto error;
689+ #ifndef __DISABLE_OTF_SERVER__
693690 machine_init( compiler, otf_process_msg );
694691 #endif
695692
src/core/ulib_machine.cpp+41−17
@@ -37,6 +37,9 @@ · 36 unmodified lines
3737 #include "chuck_instr.h"
3838 #include "chuck.h"
3939
40+#include <string>
41+using namespace std;
42+
4043
4144
4245
@@ -68,6 +71,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 25 unmodified lines
6871 // add documentation | 1.4.1.0
6972 QUERY->doc_class( QUERY, "runtime interface to the ChucK virtual machine." );
7073
74+#ifndef __DISABLE_OTF_SERVER__
7175 // add add
7276 //! compile and spork a new shred from file at 'path' into the VM now
7377 //! returns the shred ID
@@ -105,6 +109,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 31 unmodified lines
105109 //! (see example/status.ck)
106110 QUERY->add_sfun( QUERY, machine_status_impl, "int", "status" );
107111 QUERY->doc_func( QUERY, "display current status of virtual machine." );
112+#endif // __DISABLE_OTF_SERVER__
108113
109114 // add shreds
110115 //! get list of active shreds by id
@@ -145,6 +150,10 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 34 unmodified lines
145150 QUERY->add_sfun( QUERY, machine_realtime_impl, "int", "realtime" );
146151 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)" );
147152
153+ // get version string
154+ QUERY->add_sfun( QUERY, machine_version_impl, "string", "version" );
155+ QUERY->doc_func( QUERY, "return version string" );
156+
148157 // end class
149158 QUERY->end_class( QUERY );
150159
@@ -154,23 +163,6 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 3 unmodified lines
154163
155164
156165
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−
174166 //-----------------------------------------------------------------------------
175167 // name: machine_intsize()
176168 // desc: integer size in bits
@@ -218,6 +210,24 @@ t_CKUINT machine_eval( Chuck_String * codeStr, Chuck_String * argsTogether, · 41 unmodified lines
218210
219211
220212
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+
221231 // add
222232 CK_DLL_SFUN( machine_crash_impl )
223233 {
@@ -269,6 +279,8 @@ CK_DLL_SFUN( machine_status_impl ) · 45 unmodified lines
269279 RETURN->v_int = (int)the_func( SHRED->vm_ref, the_compiler, &msg, TRUE, NULL );
270280 }
271281
282+#endif // __DISABLE_OTF_SERVER__
283+
272284 // intsize
273285 CK_DLL_SFUN( machine_intsize_impl )
274286 {
@@ -330,3 +342,15 @@ CK_DLL_SFUN( machine_eval3_impl ) · 55 unmodified lines
330342
331343 RETURN->v_int = machine_eval( code, argsTogether, count, VM );
332344 }
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+}
src/core/ulib_machine.h+4−1
@@ -42,13 +42,15 @@ struct Chuck_Compiler; · 41 unmodified lines
4242
4343 // query
4444 DLL_QUERY machine_query( Chuck_DL_Query * QUERY );
45+
46+#ifndef __DISABLE_OTF_SERVER__
4547 typedef t_CKUINT (* proc_msg_func)( Chuck_VM *, Chuck_Compiler *,
4648 Net_Msg *, t_CKBOOL, void * );
4749 t_CKBOOL machine_init( Chuck_Compiler * compiler, proc_msg_func func );
4850 // 1.4.0.1: TODO: refactor out of ulib machine; not all platforms have OTF
51+#endif // __DISABLE_OTF_SERVER__
4952 t_CKUINT machine_intsize();
5053
51−
5254 // exports
5355 CK_DLL_SFUN( machine_crash_impl );
5456 CK_DLL_SFUN( machine_add_impl );
@@ -63,6 +65,7 @@ CK_DLL_SFUN( machine_silent_impl ); · 8 unmodified lines
6365 CK_DLL_SFUN( machine_eval_impl );
6466 CK_DLL_SFUN( machine_eval2_impl );
6567 CK_DLL_SFUN( machine_eval3_impl );
68+CK_DLL_SFUN( machine_version_impl );
6669
6770
6871 #endif
src/makefile+4−4
@@ -38,10 +38,10 @@ EMSCRIPTENSRCS=host_web/chuck_emscripten.cpp \ · 37 unmodified lines
3838 core/chuck_ugen.cpp core/chuck_utils.cpp core/chuck_vm.cpp \
3939 core/uana_extract.cpp core/uana_xform.cpp core/ugen_filter.cpp \
4040 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 \
42− core/ulib_std.cpp core/util_buffers.cpp core/util_math.c core/util_raw.c \
43− core/util_string.cpp core/util_xforms.c core/chuck_win32.c \
44− core/util_sndfile.c
41+ core/ulib_ai.cpp core/ulib_machine.cpp core/ulib_math.cpp \
42+ core/ulib_regex.cpp core/ulib_std.cpp core/util_buffers.cpp \
43+ core/util_math.c core/util_raw.c core/util_string.cpp \
44+ core/util_xforms.c core/chuck_win32.c core/util_sndfile.c
4545
4646
4747 .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