Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ccrma/chuck
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Oct 26, 2023
2 parents 8748716 + 29367d6 commit 71fcb0a
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ navigate to the `chuck/src` directory, and run `make`:
cd chuck/src
make mac
```
OR to build a universal binary (intel + apple sillicon):
OR to build a universal binary (intel + apple silicon):
```
make mac-ub
```
Expand Down
80 changes: 79 additions & 1 deletion src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,80 @@ static t_CKBOOL CK_DLL_CALL ck_array_int_get_key( Chuck_DL_Api::ArrayInt a, cons



//-----------------------------------------------------------------------------
// name: ck_array_float_size()
// desc: get size of an array | 1.5.1.8 (nshaheed) added
//-----------------------------------------------------------------------------
static t_CKBOOL CK_DLL_CALL ck_array_float_size( Chuck_DL_Api::ArrayFloat a, t_CKINT & value )
{
// default value
value = 0;
// check
if( a == NULL ) return FALSE;

// cast to array_float
Chuck_ArrayFloat * array = (Chuck_ArrayFloat *)a;

value = array->size();
return TRUE;
}




//-----------------------------------------------------------------------------
// name: ck_array_float_push_back()
// desc: push back an element into an array | 1.5.1.8 (nshaheed) added
//-----------------------------------------------------------------------------
static t_CKBOOL CK_DLL_CALL ck_array_float_push_back( Chuck_DL_Api::ArrayFloat a, t_CKFLOAT value )
{
// check
if( a == NULL ) return FALSE;
// cast to array_float
Chuck_ArrayFloat * array = (Chuck_ArrayFloat *)a;
// action
array->push_back( value );
// done
return TRUE;
}




//-----------------------------------------------------------------------------
// name: ck_array_float_get_idx()
// desc: get an indexed element from an array | 1.5.1.8 (nshaheed) added
//-----------------------------------------------------------------------------
static t_CKBOOL CK_DLL_CALL ck_array_float_get_idx( Chuck_DL_Api::ArrayFloat a, t_CKINT idx, t_CKFLOAT & value )
{
// check
if( a == NULL ) return FALSE;
// cast to array_float
Chuck_ArrayFloat * array = (Chuck_ArrayFloat *)a;
// action
return array->get( idx, &value );
}




//-----------------------------------------------------------------------------
// name: ck_array_float_get()
// desc: get a keyed element from an array | 1.5.1.8 (nshaheed) added
//-----------------------------------------------------------------------------
static t_CKBOOL CK_DLL_CALL ck_array_float_get_key( Chuck_DL_Api::ArrayFloat a, const std::string& key, t_CKFLOAT & value )
{
// check
if( a == NULL ) return FALSE;
// cast to array_float
Chuck_ArrayFloat * array = (Chuck_ArrayFloat *)a;
// action
return array->get( key, &value );
}




//-----------------------------------------------------------------------------
// constructor for the VMApi; connects function pointers to host-side impl
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1970,7 +2044,11 @@ set_string(ck_set_string),
array_int_size(ck_array_int_size),
array_int_push_back(ck_array_int_push_back),
array_int_get_idx(ck_array_int_get_idx),
array_int_get_key(ck_array_int_get_key)
array_int_get_key(ck_array_int_get_key),
array_float_size(ck_array_float_size),
array_float_push_back(ck_array_float_push_back),
array_float_get_idx(ck_array_float_get_idx),
array_float_get_key(ck_array_float_get_key)
{ }


Expand Down
6 changes: 6 additions & 0 deletions src/core/chuck_dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ struct Chuck_DL_Api
typedef Chuck_Type * Type;
typedef Chuck_String * String;
typedef Chuck_ArrayInt * ArrayInt; // 1.5.0.1 (ge) added
typedef Chuck_ArrayFloat * ArrayFloat; // 1.5.1.8 (nshaheed) added

public:
static Chuck_DL_Api g_api;
Expand Down Expand Up @@ -916,6 +917,11 @@ struct Chuck_DL_Api
t_CKBOOL (CK_DLL_CALL * const array_int_push_back)( ArrayInt array, t_CKUINT value );
t_CKBOOL (CK_DLL_CALL * const array_int_get_idx)( ArrayInt array, t_CKINT idx, t_CKUINT & value );
t_CKBOOL (CK_DLL_CALL * const array_int_get_key)( ArrayInt array, const std::string & key, t_CKUINT & value );
// array_float operations
t_CKBOOL (CK_DLL_CALL * const array_float_size)( ArrayFloat array, t_CKINT & value );
t_CKBOOL (CK_DLL_CALL * const array_float_push_back)( ArrayFloat array, t_CKFLOAT value );
t_CKBOOL (CK_DLL_CALL * const array_float_get_idx)( ArrayFloat array, t_CKINT idx, t_CKFLOAT & value );
t_CKBOOL (CK_DLL_CALL * const array_float_get_key)( ArrayFloat array, const std::string & key, t_CKFLOAT & value );
} * const object;

// access to host-side chuck types
Expand Down
8 changes: 4 additions & 4 deletions src/core/chuck_emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,15 +1886,15 @@ t_CKBOOL emit_engine_emit_exp( Chuck_Emitter * emit, a_Exp exp, t_CKBOOL doAddRe
if( isobj( emit->env, exp->func_call.ret_type ) )
{
// the return needs to be released (later at the end of the stmt that contains this)
Chuck_Instr_Stmt_Start * start = emit->stmt_stack.size() ? emit->stmt_stack.back() : NULL;
Chuck_Instr_Stmt_Start * onStack = emit->stmt_stack.size() ? emit->stmt_stack.back() : NULL;
// check it
if( start )
if( onStack )
{
t_CKUINT offset = 0;
// acquire next offset
if( !start->nextOffset( offset ) ) return FALSE;
if( !onStack->nextOffset( offset ) ) return FALSE;
// append instruction
emit->append( new Chuck_Instr_Stmt_Remember_Object( start, offset ) );
emit->append( new Chuck_Instr_Stmt_Remember_Object( onStack, offset ) );
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,12 +1488,12 @@ static void ckvm_process_watcher( t_CKBOOL add, list<Chuck_VM_Shreds_Watcher> &
// name: subscribe_watcher() | 1.5.1.5
// desc: subscribe shreds watcher callback
//-----------------------------------------------------------------------------
void Chuck_VM::subscribe_watcher( f_shreds_watcher cb, t_CKUINT options, void * data )
void Chuck_VM::subscribe_watcher( f_shreds_watcher cb, t_CKUINT options, void * userdata )
{
// check
if( !cb ) return;
// watcher bundle
Chuck_VM_Shreds_Watcher w( cb, data );
Chuck_VM_Shreds_Watcher w( cb, userdata );
// check options and subscribe the watcher
ckvm_process_watcher( options & CKVM_SHREDS_WATCH_SPORK, m_shreds_watchers_spork, w );
ckvm_process_watcher( options & CKVM_SHREDS_WATCH_REMOVE, m_shreds_watchers_remove, w );
Expand Down
2 changes: 1 addition & 1 deletion src/core/chuck_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ struct Chuck_VM : public Chuck_Object

public:
// subscribe shreds watcher callback | 1.5.1.5
void subscribe_watcher( f_shreds_watcher cb, t_CKUINT options, void * data = NULL );
void subscribe_watcher( f_shreds_watcher cb, t_CKUINT options, void * userdata = NULL );
// notify watchers | 1.5.1.5
void notify_watchers( ckvmShredsWatcherFlag which, Chuck_VM_Shred * shred,
std::list<Chuck_VM_Shreds_Watcher> & v );
Expand Down

0 comments on commit 71fcb0a

Please sign in to comment.