Skip to content

Commit

Permalink
abolish the singleton/vector distinction for EidosValue_Object
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Dec 23, 2023
1 parent 3c2b978 commit ca2b333
Show file tree
Hide file tree
Showing 35 changed files with 467 additions and 704 deletions.
2 changes: 1 addition & 1 deletion SLiMgui/slim_gui.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
SLiMgui::SLiMgui(Community &p_community, SLiMWindowController *p_controller) :
community_(p_community),
controller_(p_controller),
self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMgui_Class)))
self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMgui_Class)))
{
}

Expand Down
6 changes: 3 additions & 3 deletions core/chromosome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ Mutation *Chromosome::ApplyMutationCallbacks(Mutation *p_mut, Genome *p_genome,

// The callback is active and matches the mutation type id of the mutation, so we need to execute it
// This code is similar to Population::ExecuteScript, but we set up an additional symbol table, and we use the return value
EidosValue_Object_singleton local_mut(p_mut, gSLiM_Mutation_Class);
EidosValue_Object local_mut(p_mut, gSLiM_Mutation_Class);
EidosValue_Int local_originalNuc(p_original_nucleotide);

// We need to actually execute the script; we start a block here to manage the lifetime of the symbol table
Expand Down Expand Up @@ -1569,7 +1569,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id)
// constants
case gID_genomicElements:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElement_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElement_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);

for (GenomicElement *genomic_element : genomic_elements_)
Expand Down Expand Up @@ -1768,7 +1768,7 @@ EidosValue_SP Chromosome::GetProperty(EidosGlobalStringID p_property_id)

case gID_species:
{
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(&species_, gSLiM_Species_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(&species_, gSLiM_Species_Class));
}

// variables
Expand Down
8 changes: 4 additions & 4 deletions core/community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extern "C" {
#pragma mark Community
#pragma mark -

Community::Community(void) : self_symbol_(gID_community, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Community_Class)))
Community::Community(void) : self_symbol_(gID_community, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Community_Class)))
{
// self_symbol_ is always a constant, but can't be marked as such on construction
self_symbol_.second->MarkAsConstant();
Expand Down Expand Up @@ -1329,7 +1329,7 @@ Species *Community::SpeciesForIndividuals(EidosValue *value)
if (value_count == 1)
return &((Individual *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_->species_;

EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value;
EidosValue_Object *object_vector_value = (EidosValue_Object *)object_value;
Individual **individuals = (Individual **)object_vector_value->data();

return Community::SpeciesForIndividualsVector(individuals, value_count);
Expand Down Expand Up @@ -1374,7 +1374,7 @@ Species *Community::SpeciesForGenomes(EidosValue *value)
if (value_count == 1)
return &((Genome *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->OwningIndividual()->subpopulation_->species_;

EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value;
EidosValue_Object *object_vector_value = (EidosValue_Object *)object_value;
Genome **genomes = (Genome **)object_vector_value->data();

return Community::SpeciesForGenomesVector(genomes, value_count);
Expand Down Expand Up @@ -1419,7 +1419,7 @@ Species *Community::SpeciesForMutations(EidosValue *value)
if (value_count == 1)
return &((Mutation *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->mutation_type_ptr_->species_;

EidosValue_Object_vector *object_vector_value = (EidosValue_Object_vector *)object_value;
EidosValue_Object *object_vector_value = (EidosValue_Object *)object_value;
Mutation **mutations = (Mutation **)object_vector_value->data();

return Community::SpeciesForMutationsVector(mutations, value_count);
Expand Down
44 changes: 22 additions & 22 deletions core/community_eidos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id)
// constants
case gID_allGenomicElementTypes:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElementType_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElementType_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);

for (auto getype : all_genomic_element_types_)
Expand All @@ -331,7 +331,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id)
}
case gID_allInteractionTypes:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_InteractionType_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_InteractionType_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);

for (auto inttype : interaction_types_)
Expand All @@ -341,7 +341,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id)
}
case gID_allMutationTypes:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);

for (auto muttype : all_mutation_types_)
Expand All @@ -351,7 +351,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id)
}
case gID_allScriptBlocks:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SLiMEidosBlock_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SLiMEidosBlock_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);
std::vector<SLiMEidosBlock*> &script_blocks = AllScriptBlocks();

Expand All @@ -363,7 +363,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id)
}
case gID_allSpecies:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);

for (auto species : all_species_)
Expand All @@ -373,7 +373,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id)
}
case gID_allSubpopulations:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Subpopulation_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Subpopulation_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);

for (auto species : all_species_)
Expand All @@ -384,7 +384,7 @@ EidosValue_SP Community::GetProperty(EidosGlobalStringID p_property_id)
}
case gID_logFiles:
{
EidosValue_Object_vector *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_LogFile_Class);
EidosValue_Object *vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_LogFile_Class);
EidosValue_SP result_SP = EidosValue_SP(vec);

for (LogFile *logfile : log_file_registry_)
Expand Down Expand Up @@ -624,7 +624,7 @@ EidosValue_SP Community::ExecuteMethod_createLogFile(EidosGlobalStringID p_metho

// Create the LogFile object
LogFile *logfile = new LogFile(*this);
result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(logfile, gSLiM_LogFile_Class));
result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(logfile, gSLiM_LogFile_Class));

// Add it to our registry; it has a retain count from new that we will take over at this point
log_file_registry_.emplace_back(logfile);
Expand Down Expand Up @@ -730,12 +730,12 @@ EidosValue_SP Community::ExecuteMethod_genomicElementTypesWithIDs(EidosGlobalStr
if (!object)
EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_genomicElementTypesWithIDs): genomicElementTypesWithIDs() did not find a genomic element type with id " << id << "." << EidosTerminate();

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_GenomicElementType_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_GenomicElementType_Class));
}
else
{
// Vector case
EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElementType_Class))->resize_no_initialize_RR(ids_count);
EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElementType_Class))->resize_no_initialize_RR(ids_count);

for (int id_index = 0; id_index < ids_count; id_index++)
{
Expand Down Expand Up @@ -769,12 +769,12 @@ EidosValue_SP Community::ExecuteMethod_interactionTypesWithIDs(EidosGlobalString
if (!object)
EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_interactionTypesWithIDs): interactionTypesWithIDs() did not find an interaction type with id " << id << "." << EidosTerminate();

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_InteractionType_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_InteractionType_Class));
}
else
{
// Vector case
EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_InteractionType_Class))->resize_no_initialize_RR(ids_count);
EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_InteractionType_Class))->resize_no_initialize_RR(ids_count);

for (int id_index = 0; id_index < ids_count; id_index++)
{
Expand Down Expand Up @@ -808,12 +808,12 @@ EidosValue_SP Community::ExecuteMethod_mutationTypesWithIDs(EidosGlobalStringID
if (!object)
EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_mutationTypesWithIDs): mutationTypesWithIDs() did not find a genomic element type with id " << id << "." << EidosTerminate();

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_MutationType_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_MutationType_Class));
}
else
{
// Vector case
EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class))->resize_no_initialize_RR(ids_count);
EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class))->resize_no_initialize_RR(ids_count);

for (int id_index = 0; id_index < ids_count; id_index++)
{
Expand Down Expand Up @@ -847,12 +847,12 @@ EidosValue_SP Community::ExecuteMethod_scriptBlocksWithIDs(EidosGlobalStringID p
if (!object)
EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_scriptBlocksWithIDs): scriptBlocksWithIDs() did not find a script block with id " << id << "." << EidosTerminate();

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_SLiMEidosBlock_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_SLiMEidosBlock_Class));
}
else
{
// Vector case
EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SLiMEidosBlock_Class))->resize_no_initialize_RR(ids_count);
EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SLiMEidosBlock_Class))->resize_no_initialize_RR(ids_count);

for (int id_index = 0; id_index < ids_count; id_index++)
{
Expand Down Expand Up @@ -886,12 +886,12 @@ EidosValue_SP Community::ExecuteMethod_speciesWithIDs(EidosGlobalStringID p_meth
if (!object)
EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_speciesWithIDs): speciesWithIDs() did not find a species with id " << id << "." << EidosTerminate();

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_Species_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_Species_Class));
}
else
{
// Vector case
EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class))->resize_no_initialize_RR(ids_count);
EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class))->resize_no_initialize_RR(ids_count);

for (int id_index = 0; id_index < ids_count; id_index++)
{
Expand Down Expand Up @@ -925,12 +925,12 @@ EidosValue_SP Community::ExecuteMethod_subpopulationsWithIDs(EidosGlobalStringID
if (!object)
EIDOS_TERMINATION << "ERROR (Community::ExecuteMethod_subpopulationsWithIDs): subpopulationsWithIDs() did not find a subpopulation with id " << id << "." << EidosTerminate();

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(object, gSLiM_Subpopulation_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object, gSLiM_Subpopulation_Class));
}
else
{
// Vector case
EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Subpopulation_Class))->resize_no_initialize_RR(ids_count);
EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Subpopulation_Class))->resize_no_initialize_RR(ids_count);

for (int id_index = 0; id_index < ids_count; id_index++)
{
Expand Down Expand Up @@ -1265,7 +1265,7 @@ EidosValue_SP Community::ExecuteMethod_rescheduleScriptBlock(EidosGlobalStringID
gSLiMScheduling << std::endl;
#endif

return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(block, gSLiM_SLiMEidosBlock_Class));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(block, gSLiM_SLiMEidosBlock_Class));
}
else if (!ticks_null && (start_null && end_null))
{
Expand All @@ -1289,7 +1289,7 @@ EidosValue_SP Community::ExecuteMethod_rescheduleScriptBlock(EidosGlobalStringID
CheckScheduling(ticks.front(), stage);

// finally, go through the tick vector and schedule blocks for sequential runs
EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SLiMEidosBlock_Class));
EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SLiMEidosBlock_Class));
EidosValue_SP result_SP = EidosValue_SP(vec);
bool first_block = true;

Expand Down
Loading

0 comments on commit ca2b333

Please sign in to comment.