Skip to content

Commit

Permalink
update *_STRING_SAFE(ARGS) macros
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 23, 2023
1 parent ddc866c commit cff2cd5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/chuck_dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class CBufferSimple;
#define GET_CK_VECTOR(ptr) (*(t_CKVECTOR *)ptr)
#define GET_CK_OBJECT(ptr) (*(Chuck_Object **)ptr)
#define GET_CK_STRING(ptr) (*(Chuck_String **)ptr)
#define GET_CK_STRING_SAFE(ptr) std::string( GET_CK_STRING(ptr)->c_str() )

// param conversion with pointer advance
#define GET_NEXT_FLOAT(ptr) (*((t_CKFLOAT *&)ptr)++)
Expand All @@ -142,7 +141,17 @@ class CBufferSimple;
#define GET_NEXT_VECTOR(ptr) (*((t_CKVECTOR *&)ptr)++)
#define GET_NEXT_OBJECT(ptr) (*((Chuck_Object **&)ptr)++)
#define GET_NEXT_STRING(ptr) (*((Chuck_String **&)ptr)++)

// string-specific operations
#ifndef __CHUCK_CHUGIN__ // CHUGIN flag NOT present
// assume macro used from host
#define GET_CK_STRING_SAFE(ptr) std::string( GET_CK_STRING(ptr)->c_str() )
#define GET_NEXT_STRING_SAFE(ptr) std::string( GET_NEXT_STRING(ptr)->c_str() )
#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)) )
#endif

// param conversion
#define SET_CK_FLOAT(ptr,v) (*(t_CKFLOAT *&)ptr=v)
Expand Down

0 comments on commit cff2cd5

Please sign in to comment.