Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ArrayFloat API calls #389

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading