From 133bebd4f84d58d06394f96679b7ad19ceb67f1f Mon Sep 17 00:00:00 2001 From: nshaheed Date: Wed, 25 Oct 2023 19:07:11 -0700 Subject: [PATCH] added ArrayFloat API calls --- src/core/chuck_dl.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++- src/core/chuck_dl.h | 6 ++++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/core/chuck_dl.cpp b/src/core/chuck_dl.cpp index b2ee323f9..69628ef61 100644 --- a/src/core/chuck_dl.cpp +++ b/src/core/chuck_dl.cpp @@ -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 //----------------------------------------------------------------------------- @@ -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) { } diff --git a/src/core/chuck_dl.h b/src/core/chuck_dl.h index 750d393fe..3759b0693 100644 --- a/src/core/chuck_dl.h +++ b/src/core/chuck_dl.h @@ -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; @@ -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