Skip to content

Commit

Permalink
rename ctors and dtor in chuck type
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 23, 2023
1 parent b46e1ae commit ddc866c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/core/chuck_oo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Chuck_Object::~Chuck_Object()
}

// chuck-defined destructor | 1.5.2.0 (ge) added
if( type->dtor )
if( type->dtor_the )
{
// verify
if( !type->dtor_invoker )
Expand Down
8 changes: 4 additions & 4 deletions src/core/chuck_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3166,9 +3166,9 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f )
// set constructor flag
func->is_ctor = TRUE;
// set in class as constructor; if not NULL, then a ctor is already set, and this is an overloading
if( env->class_def->ctors == NULL )
if( env->class_def->ctors_all == NULL )
{
CK_SAFE_REF_ASSIGN( env->class_def->ctors, func );
CK_SAFE_REF_ASSIGN( env->class_def->ctors_all, func );
}
// check if default constructor
func->is_default_ctor = (f->arg_list == NULL);
Expand All @@ -3183,15 +3183,15 @@ t_CKBOOL type_engine_scan2_func_def( Chuck_Env * env, a_Func_Def f )
if( isInDtor )
{
// verify
if( env->class_def->dtor != NULL )
if( env->class_def->dtor_the != NULL )
{
EM_error2( f->where, "(internal error): unexpected destructor found in '%s'...", env->class_def->c_name() );
return FALSE;
}
// set destructor flag
func->is_dtor = TRUE;
// set in class as destructor
CK_SAFE_REF_ASSIGN( env->class_def->dtor, func );
CK_SAFE_REF_ASSIGN( env->class_def->dtor_the, func );
// set invoker
env->class_def->dtor_invoker = new Chuck_VM_DtorInvoker;
// init invoker
Expand Down
10 changes: 5 additions & 5 deletions src/core/chuck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5880,7 +5880,7 @@ Chuck_Func * type_engine_check_ctor_call( Chuck_Env * env, Chuck_Type * type, a_
}

// locate the constructor by type name
Chuck_Func * funcGroup = actualType->ctors;
Chuck_Func * funcGroup = actualType->ctors_all;
// verify
if( !funcGroup )
{
Expand Down Expand Up @@ -9313,9 +9313,9 @@ Chuck_Type::Chuck_Type( Chuck_Env * env, te_Type _id, const std::string & _n,
is_complete = TRUE;
has_pre_ctor = FALSE;
has_pre_dtor = FALSE;
ctors = NULL;
ctors_all = NULL;
ctor_default = NULL;
dtor = NULL;
dtor_the = NULL;
dtor_invoker = NULL;
allocator = NULL;

Expand Down Expand Up @@ -9361,9 +9361,9 @@ void Chuck_Type::reset()
// release references
CK_SAFE_RELEASE( info );
CK_SAFE_RELEASE( owner );
CK_SAFE_RELEASE( ctors ); // 1.5.2.0 (ge) added
CK_SAFE_RELEASE( ctors_all ); // 1.5.2.0 (ge) added
CK_SAFE_RELEASE( ctor_default ); // 1.5.2.0 (ge) added
CK_SAFE_RELEASE( dtor ); // 1.5.2.0 (ge) added
CK_SAFE_RELEASE( dtor_the ); // 1.5.2.0 (ge) added

// TODO: uncomment this, fix it to behave correctly
// TODO: make it safe to do this, as there are multiple instances of ->parent assignments without add-refs
Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -933,11 +933,11 @@ struct Chuck_Type : public Chuck_Object
// of this type (via new_array_type()), but this flag is this specific type only
t_CKBOOL has_pre_dtor;
// constructor(s), potentially overloaded | 1.5.2.0 (ge) added
Chuck_Func * ctors;
Chuck_Func * ctors_all;
// default constructor (no arguments) | 1.5.2.0 (ge) added
Chuck_Func * ctor_default;
// destructor (also see this->info->pre_dtor) | 1.5.2.0 (ge) added
Chuck_Func * dtor;
Chuck_Func * dtor_the;
// destructor invoker (needed since dtor could run outside of chuck shreduling) | 1.5.2.0
Chuck_VM_DtorInvoker * dtor_invoker;
// custom allocator
Expand Down

0 comments on commit ddc866c

Please sign in to comment.