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

Showing the changes to src/core/ulib_machine.cpp (1 of 4 files). Show all

Unified · Split

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+}

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