Skip to content

Commit

Permalink
add chugin DL runtime api for type name and base_name
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 23, 2023
1 parent e087ee3 commit ff6a2bc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ t_CKBOOL CK_DLL_CALL ck_type_isequal( Chuck_Type * lhs, Chuck_Type * rhs );
t_CKBOOL CK_DLL_CALL ck_type_isa( Chuck_Type * lhs, Chuck_Type * rhs );
void CK_DLL_CALL ck_callback_on_instantiate( f_callback_on_instantiate callback, Chuck_Type * base_type, Chuck_VM * vm, t_CKBOOL shouldSetShredOrigin );
ckte_Origin ck_origin_hint( Chuck_Type * type );
const char * CK_DLL_CALL ck_type_name( Chuck_Type * type );
const char * CK_DLL_CALL ck_type_base_name( Chuck_Type * type );
Chuck_VM_Shred * CK_DLL_CALL ck_get_origin_shred( Chuck_Object * object );
void CK_DLL_CALL ck_set_origin_shred( Chuck_Object * object, Chuck_VM_Shred * shred );
Chuck_VM_Shred * CK_DLL_CALL ck_shred_parent( Chuck_VM_Shred * shred );
Expand Down Expand Up @@ -2535,7 +2537,9 @@ get_vtable_offset(ck_get_vtable_offset),
is_equal(ck_type_isequal),
isa(ck_type_isa),
callback_on_instantiate(ck_callback_on_instantiate),
origin_hint(ck_origin_hint)
origin_hint(ck_origin_hint),
name(ck_type_name),
base_name(ck_type_base_name)
{ }


Expand Down Expand Up @@ -2738,6 +2742,36 @@ ckte_Origin CK_DLL_CALL ck_origin_hint( Chuck_Type * type )



//-----------------------------------------------------------------------------
// name: ck_type_name()
// desc: get type name (full, with decorations such as [])
//-----------------------------------------------------------------------------
const char * CK_DLL_CALL ck_type_name( Chuck_Type * type )
{
// null
if( !type ) return "";
// return type name
return type->c_name();
}




//-----------------------------------------------------------------------------
// name: ck_type_base_name()
// desc: get type base name (no [] decorations)
//-----------------------------------------------------------------------------
const char * CK_DLL_CALL ck_type_base_name( Chuck_Type * type )
{
// null
if( !type ) return "";
// return origin hint
return type->base_name.c_str();
}




//-----------------------------------------------------------------------------
// name: ck_shred_parent()
// desc: where did the type originate? e.g., chugin, builtin, user-defined, etc.
Expand Down
4 changes: 4 additions & 0 deletions src/core/chuck_dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,10 @@ struct Chuck_DL_Api
void (CK_DLL_CALL * const callback_on_instantiate)( f_callback_on_instantiate callback, Type base_type, Chuck_VM * vm, t_CKBOOL shouldSetShredOrigin );
// get origin hint ("where did this type originate?")
ckte_Origin (CK_DLL_CALL * const origin_hint)(Type type);
// get type name (full, with decorations) (NOTE do not save a reference to the return value; make a copy if needed) | 1.5.2.0
const char * (CK_DLL_CALL * const name)(Type type);
// get type base name (no decorations) (NOTE do not save a reference to the return value; make a copy if needed) | 1.5.2.0
const char * (CK_DLL_CALL * const base_name)(Type type);
} * const type;

// api to access host-side shreds | 1.5.2.0
Expand Down

0 comments on commit ff6a2bc

Please sign in to comment.