Showing the changes to src/core/ulib_machine.cpp (1 of 17 files). Show all
Unified · Split
| @@ -40,6 +40,25 @@ · 39 unmodified lines | ||
| 40 | 40 | #include <string> |
| 41 | 41 | using namespace std; |
| 42 | 42 | |
| 43 | +// exports | |
| 44 | +CK_DLL_SFUN( machine_crash_impl ); | |
| 45 | +CK_DLL_SFUN( machine_add_impl ); | |
| 46 | +CK_DLL_SFUN( machine_spork_impl ); | |
| 47 | +CK_DLL_SFUN( machine_remove_impl ); | |
| 48 | +CK_DLL_SFUN( machine_replace_impl ); | |
| 49 | +CK_DLL_SFUN( machine_status_impl ); | |
| 50 | +CK_DLL_SFUN( machine_intsize_impl ); | |
| 51 | +CK_DLL_SFUN( machine_shreds_impl ); | |
| 52 | +CK_DLL_SFUN( machine_realtime_impl ); | |
| 53 | +CK_DLL_SFUN( machine_silent_impl ); | |
| 54 | +CK_DLL_SFUN( machine_eval_impl ); | |
| 55 | +CK_DLL_SFUN( machine_eval2_impl ); | |
| 56 | +CK_DLL_SFUN( machine_eval3_impl ); | |
| 57 | +CK_DLL_SFUN( machine_version_impl ); | |
| 58 | +CK_DLL_SFUN( machine_setloglevel_impl ); | |
| 59 | +CK_DLL_SFUN( machine_getloglevel_impl ); | |
| 60 | +CK_DLL_SFUN( machine_refcount_impl); | |
| 61 | + | |
| 43 | 62 | |
| 44 | 63 | |
| 45 | 64 | |
| @@ -154,7 +173,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 108 unmodified lines | ||
| 154 | 173 | QUERY->add_sfun( QUERY, machine_version_impl, "string", "version" ); |
| 155 | 174 | QUERY->doc_func( QUERY, "return version string" ); |
| 156 | 175 | |
| 157 | − // get version string | |
| 176 | + // get set loglevel | |
| 158 | 177 | QUERY->add_sfun( QUERY, machine_setloglevel_impl, "int", "loglevel" ); |
| 159 | 178 | QUERY->add_arg( QUERY, "int", "level" ); |
| 160 | 179 | QUERY->doc_func( QUERY, "set log level\n" |
| @@ -170,10 +189,15 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 9 unmodified lines | ||
| 170 | 189 | " |- 9: FINEST\n" |
| 171 | 190 | " |- 10: ALL" ); |
| 172 | 191 | |
| 173 | − // get version string | |
| 192 | + // get log level | |
| 174 | 193 | QUERY->add_sfun( QUERY, machine_getloglevel_impl, "int", "loglevel" ); |
| 175 | 194 | QUERY->doc_func( QUERY, "get log level." ); |
| 176 | 195 | |
| 196 | + // get reference count for any object | |
| 197 | + QUERY->add_sfun( QUERY, machine_refcount_impl, "int", "refcount" ); | |
| 198 | + QUERY->add_arg( QUERY, "Object", "obj" ); | |
| 199 | + QUERY->doc_func( QUERY, "get an object's current internal reference count; this is intended for testing or curiosity; NOTE: this function intentionally does not take into account any reference counting related to the calling of this function (normally all functions increments the reference count for objects passed as arguments and decrements upon returning)" ); | |
| 200 | + | |
| 177 | 201 | // end class |
| 178 | 202 | QUERY->end_class( QUERY ); |
| 179 | 203 | |
| @@ -399,3 +423,11 @@ CK_DLL_SFUN( machine_getloglevel_impl ) · 219 unmodified lines | ||
| 399 | 423 | // return |
| 400 | 424 | RETURN->v_int = VM->carrier()->chuck->getLogLevel(); |
| 401 | 425 | } |
| 426 | + | |
| 427 | +CK_DLL_SFUN( machine_refcount_impl ) | |
| 428 | +{ | |
| 429 | + // get the argument | |
| 430 | + Chuck_Object * obj = (Chuck_Object *)GET_NEXT_OBJECT(ARGS); | |
| 431 | + // return (-1 to account for the extra refcount as part of calling this function!) | |
| 432 | + RETURN->v_int = obj != NULL ? obj->m_ref_count-1 : 0; | |
| 433 | +} | |