Skip to content

Commit

Permalink
add dl api for clearing arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 23, 2023
1 parent cff2cd5 commit e087ee3
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
81 changes: 80 additions & 1 deletion src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,21 @@ static t_CKBOOL CK_DLL_CALL ck_array_int_push_back( Chuck_DL_Api::ArrayInt array



//-----------------------------------------------------------------------------
// name: ck_array_int_clear()
// desc: clear array | 1.5.2.0 (ge) added
//-----------------------------------------------------------------------------
static void CK_DLL_CALL ck_array_int_clear( Chuck_DL_Api::ArrayInt array )
{
// check
if( array == NULL ) return;
// clear
array->clear();
}




//-----------------------------------------------------------------------------
// name: ck_array_float_size()
// desc: get size of an array | 1.5.1.8 (nshaheed) added
Expand Down Expand Up @@ -2187,6 +2202,21 @@ static t_CKBOOL CK_DLL_CALL ck_array_float_push_back( Chuck_DL_Api::ArrayFloat a



//-----------------------------------------------------------------------------
// name: ck_array_float_clear()
// desc: clear array | 1.5.2.0 (ge) added
//-----------------------------------------------------------------------------
static void CK_DLL_CALL ck_array_float_clear( Chuck_DL_Api::ArrayFloat array )
{
// check
if( array == NULL ) return;
// clear
array->clear();
}




//-----------------------------------------------------------------------------
// name: ck_array_vec2_size()
// desc: get size of an array | 1.5.2.0 (ge) added
Expand Down Expand Up @@ -2251,6 +2281,21 @@ static t_CKBOOL CK_DLL_CALL ck_array_vec2_push_back( Chuck_DL_Api::ArrayVec2 arr



//-----------------------------------------------------------------------------
// name: ck_array_vec2clear()
// desc: clear array | 1.5.2.0 (ge) added
//-----------------------------------------------------------------------------
static void CK_DLL_CALL ck_array_vec2_clear( Chuck_DL_Api::ArrayVec2 array )
{
// check
if( array == NULL ) return;
// clear
array->clear();
}




//-----------------------------------------------------------------------------
// name: ck_array_vec3_size()
// desc: get size of an array | 1.5.2.0 (ge) added
Expand Down Expand Up @@ -2315,6 +2360,20 @@ static t_CKBOOL CK_DLL_CALL ck_array_vec3_push_back( Chuck_DL_Api::ArrayVec3 arr



//-----------------------------------------------------------------------------
// name: ck_array_vec3clear()
// desc: clear array | 1.5.2.0 (ge) added
//-----------------------------------------------------------------------------
static void CK_DLL_CALL ck_array_vec3_clear( Chuck_DL_Api::ArrayVec3 array )
{
// check
if( array == NULL ) return;
// clear
array->clear();
}




//-----------------------------------------------------------------------------
// name: ck_array_vec4_size()
Expand Down Expand Up @@ -2380,6 +2439,21 @@ static t_CKBOOL CK_DLL_CALL ck_array_vec4_push_back( Chuck_DL_Api::ArrayVec4 arr



//-----------------------------------------------------------------------------
// name: ck_array_vec4clear()
// desc: clear array | 1.5.2.0 (ge) added
//-----------------------------------------------------------------------------
static void CK_DLL_CALL ck_array_vec4_clear( Chuck_DL_Api::ArrayVec4 array )
{
// check
if( array == NULL ) return;
// clear
array->clear();
}




//-----------------------------------------------------------------------------
// constructor for the VMApi; connects function pointers to host-side impl
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -2426,22 +2500,27 @@ array_int_size(ck_array_int_size),
array_int_get_idx(ck_array_int_get_idx),
array_int_get_key(ck_array_int_get_key),
array_int_push_back(ck_array_int_push_back),
array_int_clear(ck_array_int_clear),
array_float_size(ck_array_float_size),
array_float_get_idx(ck_array_float_get_idx),
array_float_get_key(ck_array_float_get_key),
array_float_push_back(ck_array_float_push_back),
array_float_clear( ck_array_float_clear ),
array_vec2_size(ck_array_vec2_size),
array_vec2_get_idx(ck_array_vec2_get_idx),
array_vec2_get_key(ck_array_vec2_get_key),
array_vec2_push_back(ck_array_vec2_push_back),
array_vec2_clear( ck_array_vec2_clear ),
array_vec3_size(ck_array_vec3_size),
array_vec3_get_idx(ck_array_vec3_get_idx),
array_vec3_get_key(ck_array_vec3_get_key),
array_vec3_push_back(ck_array_vec3_push_back),
array_vec3_clear( ck_array_vec3_clear ),
array_vec4_size(ck_array_vec4_size),
array_vec4_get_idx(ck_array_vec4_get_idx),
array_vec4_get_key(ck_array_vec4_get_key),
array_vec4_push_back(ck_array_vec4_push_back)
array_vec4_push_back(ck_array_vec4_push_back),
array_vec4_clear( ck_array_vec4_clear )
{ }


Expand Down
7 changes: 6 additions & 1 deletion src/core/chuck_dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class CBufferSimple;
#else // CHUGIN flag is present
// assume macro used from chugin; use chugins runtime API for portability
#define GET_CK_STRING_SAFE(ptr) std::string( API->object->str((Chuck_String *)ptr) )
#define GET_NEXT_STRING_SAFE(ptr) std::string( API->object->str(GET_NEXT_STRING(ptr)) )
#define GET_NEXT_STRING_SAFE(ptr) std::string( API->object->str(GET_NEXT_STRING(ptr) ) )
#endif

// param conversion
Expand Down Expand Up @@ -945,26 +945,31 @@ struct Chuck_DL_Api
t_CKINT (CK_DLL_CALL * const array_int_get_idx)( ArrayInt array, t_CKINT idx );
t_CKBOOL (CK_DLL_CALL * const array_int_get_key)( ArrayInt array, const char * key, t_CKINT & value );
t_CKBOOL (CK_DLL_CALL * const array_int_push_back)( ArrayInt array, t_CKINT value );
void (CK_DLL_CALL * const array_int_clear)( ArrayInt array );
// array_float operations
t_CKINT (CK_DLL_CALL * const array_float_size)( ArrayFloat array );
t_CKFLOAT (CK_DLL_CALL * const array_float_get_idx)( ArrayFloat array, t_CKINT idx );
t_CKBOOL (CK_DLL_CALL * const array_float_get_key)( ArrayFloat array, const char * key, t_CKFLOAT & value );
t_CKBOOL (CK_DLL_CALL * const array_float_push_back)( ArrayFloat array, t_CKFLOAT value );
void (CK_DLL_CALL * const array_float_clear)(ArrayFloat array);
// array_vec2/complex/polar/16 operations | 1.5.2.0 (ge) added
t_CKINT (CK_DLL_CALL * const array_vec2_size)( ArrayVec2 array );
t_CKVEC2 (CK_DLL_CALL * const array_vec2_get_idx)( ArrayVec2 array, t_CKINT idx );
t_CKBOOL (CK_DLL_CALL * const array_vec2_get_key)( ArrayVec2 array, const char * key, t_CKVEC2 & value );
t_CKBOOL (CK_DLL_CALL * const array_vec2_push_back)( ArrayVec2 array, const t_CKVEC2 & value );
void (CK_DLL_CALL * const array_vec2_clear)(ArrayVec2 array);
// array_vec3/24 operations | 1.5.2.0 (ge) added
t_CKINT (CK_DLL_CALL * const array_vec3_size)( ArrayVec3 array );
t_CKVEC3 (CK_DLL_CALL * const array_vec3_get_idx)( ArrayVec3 array, t_CKINT idx );
t_CKBOOL (CK_DLL_CALL * const array_vec3_get_key)( ArrayVec3 array, const char * key, t_CKVEC3 & value );
t_CKBOOL (CK_DLL_CALL * const array_vec3_push_back)( ArrayVec3 array, const t_CKVEC3 & value );
void (CK_DLL_CALL * const array_vec3_clear)(ArrayVec3 array);
// array_vec4/32 operations | 1.5.2.0 (ge) added
t_CKINT (CK_DLL_CALL * const array_vec4_size)( ArrayVec4 array );
t_CKVEC4 (CK_DLL_CALL * const array_vec4_get_idx)( ArrayVec4 array, t_CKINT idx );
t_CKBOOL (CK_DLL_CALL * const array_vec4_get_key)( ArrayVec4 array, const char * key, t_CKVEC4 & value );
t_CKBOOL (CK_DLL_CALL * const array_vec4_push_back)( ArrayVec4 array, const t_CKVEC4 & value );
void (CK_DLL_CALL * const array_vec4_clear)(ArrayVec4 array);
// (UNSAFE) get c++ vector pointers from chuck arrays | 1.5.2.0
// std::vector<t_CKUINT> * (CK_DLL_CALL * const array_int_vector)( ArrayInt array );
// std::vector<t_CKFLOAT> * (CK_DLL_CALL * const array_float_vector)( ArrayFloat array );
Expand Down

0 comments on commit e087ee3

Please sign in to comment.