diff --git a/SLiMgui/slim_gui.mm b/SLiMgui/slim_gui.mm index 10bbb2ba..4e457a8e 100644 --- a/SLiMgui/slim_gui.mm +++ b/SLiMgui/slim_gui.mm @@ -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))) { } diff --git a/core/chromosome.cpp b/core/chromosome.cpp index 539f8cd2..35e99db0 100644 --- a/core/chromosome.cpp +++ b/core/chromosome.cpp @@ -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 @@ -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_) @@ -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 diff --git a/core/community.cpp b/core/community.cpp index c920c14b..1de86f4e 100644 --- a/core/community.cpp +++ b/core/community.cpp @@ -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(); @@ -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); @@ -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); @@ -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); diff --git a/core/community_eidos.cpp b/core/community_eidos.cpp index b447d631..4ec76856 100644 --- a/core/community_eidos.cpp +++ b/core/community_eidos.cpp @@ -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_) @@ -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_) @@ -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_) @@ -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 &script_blocks = AllScriptBlocks(); @@ -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_) @@ -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_) @@ -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_) @@ -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); @@ -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++) { @@ -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++) { @@ -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++) { @@ -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++) { @@ -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++) { @@ -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++) { @@ -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)) { @@ -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; diff --git a/core/genome.cpp b/core/genome.cpp index 184369c7..56c067a6 100644 --- a/core/genome.cpp +++ b/core/genome.cpp @@ -382,7 +382,7 @@ void Genome::record_derived_states(Species *p_species) const void Genome::GenerateCachedEidosValue(void) { // Note that this cache cannot be invalidated as long as a symbol table might exist that this value has been placed into - self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Genome_Class)); + self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Genome_Class)); } const EidosClass *Genome::Class(void) const @@ -432,7 +432,7 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) } case gID_individual: { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(individual_, gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(individual_, gSLiM_Individual_Class)); } case gID_isNullGenome: // ACCELERATED return ((mutrun_count_ == 0) ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); @@ -443,7 +443,7 @@ EidosValue_SP Genome::GetProperty(EidosGlobalStringID p_property_id) Mutation *mut_block_ptr = gSLiM_Mutation_Block; int mut_count = mutation_count(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mut_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mut_count); EidosValue_SP result_SP = EidosValue_SP(vec); int set_index = 0; @@ -632,7 +632,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMarkerMutation(EidosObje if (returnMutation == false) return (mut ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); else - return (mut ? EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(mut, gSLiM_Mutation_Class)) : (EidosValue_SP)gStaticEidosValueNULL); + return (mut ? EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(mut, gSLiM_Mutation_Class)) : (EidosValue_SP)gStaticEidosValueNULL); } } else if (returnMutation == false) @@ -664,7 +664,7 @@ EidosValue_SP Genome::ExecuteMethod_Accelerated_containsMarkerMutation(EidosObje else // (returnMutation == true) { // We will return an object vector, one Mutation (or NULL) for each target genome; not parallelized, for now - EidosValue_Object_vector *result_obj_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->reserve(p_elements_size); + EidosValue_Object *result_obj_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->reserve(p_elements_size); bool null_genome_seen = false; for (size_t element_index = 0; element_index < p_elements_size; ++element_index) @@ -873,7 +873,7 @@ EidosValue_SP Genome::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_method // We do this by not creating a vector until we see the second match; with one match, we make a singleton. Mutation *mut_block_ptr = gSLiM_Mutation_Block; Mutation *first_match = nullptr; - EidosValue_Object_vector *vec = nullptr; + EidosValue_Object *vec = nullptr; EidosValue_SP result_SP; int run_index; @@ -895,7 +895,7 @@ EidosValue_SP Genome::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_method first_match = mut; else { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); result_SP = EidosValue_SP(vec); vec->push_object_element_RR(first_match); @@ -914,13 +914,13 @@ EidosValue_SP Genome::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_method // Now return the appropriate return value if (first_match) { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(first_match, gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(first_match, gSLiM_Mutation_Class)); } else { if (!vec) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); result_SP = EidosValue_SP(vec); } @@ -2491,7 +2491,7 @@ EidosValue_SP Genome_Class::ExecuteMethod_addNewMutation(EidosGlobalStringID p_m ((nucleotide_count != 1) && (nucleotide_count != count_to_add))) EIDOS_TERMINATION << "ERROR (Genome_Class::ExecuteMethod_addNewMutation): " << method_name << " requires that mutationType, " << ((p_method_id == gID_addNewMutation) ? "selectionCoeff, " : "") << "position, originSubpop, and nucleotide be either (1) singleton, or (2) equal in length to the other non-singleton argument(s), or (3) NULL, for originSubpop and nucleotide." << EidosTerminate(); - EidosValue_Object_vector_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + EidosValue_Object_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); if (count_to_add == 0) return retval; @@ -3225,12 +3225,12 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromMS(EidosGlobalStringID p_metho // Return the instantiated mutations int mutation_count = (int)mutation_indices.size(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); for (int mut_index = 0; mut_index < mutation_count; ++mut_index) vec->set_object_element_no_check_no_previous_RR(mut_block_ptr + mutation_indices[mut_index], mut_index); - return EidosValue_Object_vector_SP(vec); + return EidosValue_Object_SP(vec); } // ********************* + (o)readFromVCF(s$ filePath = NULL, [Nio mutationType = NULL]) @@ -3809,12 +3809,12 @@ EidosValue_SP Genome_Class::ExecuteMethod_readFromVCF(EidosGlobalStringID p_meth // Return the instantiated mutations Mutation *mut_block_ptr = gSLiM_Mutation_Block; int mutation_count = (int)mutation_indices.size(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); for (int mut_index = 0; mut_index < mutation_count; ++mut_index) vec->set_object_element_no_check_no_previous_RR(mut_block_ptr + mutation_indices[mut_index], mut_index); - return EidosValue_Object_vector_SP(vec); + return EidosValue_Object_SP(vec); } // ********************* + (void)removeMutations([No mutations = NULL], [logical$ substitute = F]) diff --git a/core/genomic_element.cpp b/core/genomic_element.cpp index 1f71055f..17a84b8f 100644 --- a/core/genomic_element.cpp +++ b/core/genomic_element.cpp @@ -58,7 +58,7 @@ std::ostream &operator<<(std::ostream &p_outstream, const GenomicElement &p_geno void GenomicElement::GenerateCachedEidosValue(void) { // Note that this cache cannot be invalidated as long as a symbol table might exist that this value has been placed into - self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_GenomicElement_Class)); + self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_GenomicElement_Class)); } const EidosClass *GenomicElement::Class(void) const @@ -149,7 +149,7 @@ EidosValue *GenomicElement::GetProperty_Accelerated_tag(EidosObject **p_values, EidosValue *GenomicElement::GetProperty_Accelerated_genomicElementType(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElementType_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElementType_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/genomic_element_type.cpp b/core/genomic_element_type.cpp index 5c3d0d6a..70857ada 100644 --- a/core/genomic_element_type.cpp +++ b/core/genomic_element_type.cpp @@ -36,7 +36,7 @@ #pragma mark - GenomicElementType::GenomicElementType(Species &p_species, slim_objectid_t p_genomic_element_type_id, std::vector p_mutation_type_ptrs, std::vector p_mutation_fractions) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('g', p_genomic_element_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_GenomicElementType_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('g', p_genomic_element_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_GenomicElementType_Class))), species_(p_species), genomic_element_type_id_(p_genomic_element_type_id), mutation_type_ptrs_(std::move(p_mutation_type_ptrs)), mutation_fractions_(std::move(p_mutation_fractions)), mutation_matrix_(nullptr) { // self_symbol_ is always a constant, but can't be marked as such on construction @@ -259,7 +259,7 @@ EidosValue_SP GenomicElementType::GetProperty(EidosGlobalStringID p_property_id) } case gID_mutationTypes: { - 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 mut_type : mutation_type_ptrs_) @@ -279,7 +279,7 @@ EidosValue_SP GenomicElementType::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 diff --git a/core/individual.cpp b/core/individual.cpp index d0223c67..544cd387 100644 --- a/core/individual.cpp +++ b/core/individual.cpp @@ -313,7 +313,7 @@ int Individual::SharedParentCountWithIndividual(Individual &p_ind) void Individual::GenerateCachedEidosValue(void) { // Note that this cache cannot be invalidated as long as a symbol table might exist that this value has been placed into - self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Individual_Class)); + self_value_ = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Individual_Class)); } const EidosClass *Individual::Class(void) const @@ -340,7 +340,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (killed_) EIDOS_TERMINATION << "ERROR (Individual::GetProperty): property subpopulation is not available for individuals that have been killed; they have no subpopulation." << EidosTerminate(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(subpopulation_, gSLiM_Subpopulation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(subpopulation_, gSLiM_Subpopulation_Class)); } case gID_index: // ACCELERATED { @@ -348,7 +348,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) } case gID_genomes: { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(2); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(2); vec->set_object_element_no_check_NORR(genome1_, 0); vec->set_object_element_no_check_NORR(genome2_, 1); @@ -363,17 +363,17 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) if (genome1null) { if (genome2null) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class)); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome2_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome2_, gSLiM_Genome_Class)); } else { if (genome2null) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome1_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome1_, gSLiM_Genome_Class)); else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(2); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(2); vec->set_object_element_no_check_NORR(genome1_, 0); vec->set_object_element_no_check_NORR(genome2_, 1); @@ -384,11 +384,11 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) } case gID_genome1: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome1_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome1_, gSLiM_Genome_Class)); } case gID_genome2: // ACCELERATED { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(genome2_, gSLiM_Genome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(genome2_, gSLiM_Genome_Class)); } case gID_sex: { @@ -496,7 +496,7 @@ EidosValue_SP Individual::GetProperty(EidosGlobalStringID p_property_id) // We reserve a vector large enough to hold all the mutations from both genomes; probably usually overkill, but it does little harm int genome1_size = (genome1_->IsNull() ? 0 : genome1_->mutation_count()); int genome2_size = (genome2_->IsNull() ? 0 : genome2_->mutation_count()); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); EidosValue_SP result_SP = EidosValue_SP(vec); if ((genome1_size == 0) && (genome2_size == 0)) @@ -1069,7 +1069,7 @@ EidosValue *Individual::GetProperty_Accelerated_spatialPosition(EidosObject **p_ EidosValue *Individual::GetProperty_Accelerated_subpopulation(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Subpopulation_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Subpopulation_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1086,7 +1086,7 @@ EidosValue *Individual::GetProperty_Accelerated_subpopulation(EidosObject **p_va EidosValue *Individual::GetProperty_Accelerated_genome1(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1100,7 +1100,7 @@ EidosValue *Individual::GetProperty_Accelerated_genome1(EidosObject **p_values, EidosValue *Individual::GetProperty_Accelerated_genome2(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { @@ -1977,7 +1977,7 @@ EidosValue_SP Individual::ExecuteMethod_uniqueMutationsOfType(EidosGlobalStringI // We try to reserve a vector large enough to hold all the mutations; probably usually overkill, but it does little harm int genome1_size = (genome1_->IsNull() ? 0 : genome1_->mutation_count()); int genome2_size = (genome2_->IsNull() ? 0 : genome2_->mutation_count()); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); EidosValue_SP result_SP = EidosValue_SP(vec); if ((genome1_size == 0) && (genome2_size == 0)) diff --git a/core/interaction_type.cpp b/core/interaction_type.cpp index 87b023e2..c0e02658 100755 --- a/core/interaction_type.cpp +++ b/core/interaction_type.cpp @@ -76,7 +76,7 @@ void InteractionType::_WarmUp(void) InteractionType::InteractionType(Community &p_community, slim_objectid_t p_interaction_type_id, std::string p_spatiality_string, bool p_reciprocal, double p_max_distance, IndividualSex p_receiver_sex, IndividualSex p_exerter_sex) : self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('i', p_interaction_type_id)), - EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_InteractionType_Class))), + EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_InteractionType_Class))), spatiality_string_(std::move(p_spatiality_string)), reciprocal_(p_reciprocal), max_distance_(p_max_distance), max_distance_sq_(p_max_distance * p_max_distance), if_type_(SpatialKernelType::kFixed), if_param1_(1.0), if_param2_(0.0), community_(p_community), interaction_type_id_(p_interaction_type_id) { @@ -3219,7 +3219,7 @@ void InteractionType::FindNeighbors1_3(SLiM_kdNode *root, double *nd, slim_popsi } // find all neighbors in 1D -void InteractionType::FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals) +void InteractionType::FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals) { double d = dist_sq1(root, nd); #ifndef __clang_analyzer__ @@ -3255,7 +3255,7 @@ void InteractionType::FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsi } // find all neighbors in 2D -void InteractionType::FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase) +void InteractionType::FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase) { double d = dist_sq2(root, nd); #ifndef __clang_analyzer__ @@ -3293,7 +3293,7 @@ void InteractionType::FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsi } // find all neighbors in 3D -void InteractionType::FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase) +void InteractionType::FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase) { double d = dist_sq3(root, nd); #ifndef __clang_analyzer__ @@ -3335,7 +3335,7 @@ void InteractionType::FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsi // They were not thread-safe, and were replaced by FillSparseVectorForReceiverDistances_ALL_NEIGHBORS(); // now (11/2/2023) that has turned into FillSparseVectorForReceiverDistances() using kd_root_ALL_, below. -void InteractionType::FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object_vector &p_result_vec, Individual *p_excluded_individual, bool constraints_active) +void InteractionType::FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object &p_result_vec, Individual *p_excluded_individual, bool constraints_active) { // If this method is passed kd_root_ALL_, from EnsureKDTreePresent_ALL(), it finds all neighbors, regardless // of exerter constraints. If it is passed kd_root_EXERTERS_, from EnsureKDTreePresent_EXERTERS(), it finds @@ -4218,7 +4218,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID { // With no receivers, return an empty Dictionary EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->ContentsChanged("InteractionType::ExecuteMethod_drawByStrength()"); @@ -4258,7 +4258,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID { // This is the single-threaded, single-receiver case; it returns a vector of Individual objects if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); @@ -4269,7 +4269,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID // Check constraints for the receiver; if the individual is disqualified, no draws can occur and the return is empty if (!CheckIndividualConstraints(receiver, receiver_constraints_)) // potentially raises - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (spatiality_ == 0) { @@ -4279,7 +4279,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID slim_popsize_t receiver_index = ((exerter_subpop == receiver->subpopulation_) && (receiver->index_ >= 0) ? receiver->index_ : -1); std::vector &callbacks = exerter_subpop_data.evaluation_interaction_callbacks_; - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); double total_interaction_strength = 0.0; std::vector cached_strength; std::vector &exerters = exerter_subpop->parent_individuals_; @@ -4320,7 +4320,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID InteractionsData &receiver_subpop_data = InteractionsDataForSubpop(data_, receiver_subpop); double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; SLiM_kdNode *kd_root_EXERTERS = EnsureKDTreePresent_EXERTERS(exerter_subpop, exerter_subpop_data); - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); SparseVector *sv = nullptr; // If there are no exerters satisfying constraints, short-circuit @@ -4422,13 +4422,13 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID EIDOS_TERMINATION << "ERROR (InteractionType::ExecuteMethod_drawByStrength): drawByStrength() supports returning a Dictionary of results, with returnDict=T, only in the spatial case." << EidosTerminate(); EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); int receivers_count = receiver_value->Count(); - EidosValue_Object_vector **result_vectors = (EidosValue_Object_vector **)malloc(receivers_count * sizeof(EidosValue_Object_vector *)); + EidosValue_Object **result_vectors = (EidosValue_Object **)malloc(receivers_count * sizeof(EidosValue_Object *)); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - EidosValue_Object_vector *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class); + EidosValue_Object *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class); dictionary->SetKeyValue_IntegerKeys(receiver_index, EidosValue_SP(empty_individuals_vec)); result_vectors[receiver_index] = empty_individuals_vec; @@ -4484,7 +4484,7 @@ EidosValue_SP InteractionType::ExecuteMethod_drawByStrength(EidosGlobalStringID double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; - EidosValue_Object_vector *result_vec = result_vectors[receiver_index]; + EidosValue_Object *result_vec = result_vectors[receiver_index]; SparseVector *sv = nullptr; if (optimize_fixed_interaction_strengths) @@ -5144,7 +5144,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl { // With no receivers, return an empty Dictionary EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->ContentsChanged("InteractionType::ExecuteMethod_nearestInteractingNeighbors()"); @@ -5184,7 +5184,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl { // This is the single-threaded, single-receiver case; it returns a vector of Individual objects if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); @@ -5195,14 +5195,14 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl // Check constraints for the receiver; if the individual is disqualified, there are no interacting neighbors if (!CheckIndividualConstraints(receiver, receiver_constraints_)) // potentially raises - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // Find the neighbors double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; InteractionsData &exerter_subpop_data = InteractionsDataForSubpop(data_, exerter_subpop); SLiM_kdNode *kd_root_EXERTERS = EnsureKDTreePresent_EXERTERS(exerter_subpop, exerter_subpop_data); - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5216,13 +5216,13 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl // This is the multi-threaded, multi-receiver case; it returns a Dictionary object vectors of Individual objects // We start by making a Dictionary with an empty Individual vector for each receiver EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); int receivers_count = receiver_value->Count(); - EidosValue_Object_vector **result_vectors = (EidosValue_Object_vector **)malloc(receivers_count * sizeof(EidosValue_Object_vector *)); + EidosValue_Object **result_vectors = (EidosValue_Object **)malloc(receivers_count * sizeof(EidosValue_Object *)); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - EidosValue_Object_vector *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class); + EidosValue_Object *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class); dictionary->SetKeyValue_IntegerKeys(receiver_index, EidosValue_SP(empty_individuals_vec)); result_vectors[receiver_index] = empty_individuals_vec; @@ -5272,7 +5272,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestInteractingNeighbors(EidosGl double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; - EidosValue_Object_vector *result_vec = result_vectors[receiver_index]; + EidosValue_Object *result_vec = result_vectors[receiver_index]; if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5337,7 +5337,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI { // With no receivers, return an empty Dictionary EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->ContentsChanged("InteractionType::ExecuteMethod_nearestNeighbors()"); @@ -5377,7 +5377,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI { // This is the single-threaded, single-receiver case; it returns a vector of Individual objects if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // receiver_value is guaranteed to be singleton; let's get the info on it Individual *receiver = (Individual *)receiver_value->ObjectElementAtIndex_NOCAST(0, nullptr); @@ -5391,7 +5391,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI InteractionsData &exerter_subpop_data = InteractionsDataForSubpop(data_, exerter_subpop); SLiM_kdNode *kd_root_ALL = EnsureKDTreePresent_ALL(exerter_subpop, exerter_subpop_data); - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5405,13 +5405,13 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI // This is the multi-threaded, multi-receiver case; it returns a Dictionary object vectors of Individual objects // We start by making a Dictionary with an empty Individual vector for each receiver EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); int receivers_count = receiver_value->Count(); - EidosValue_Object_vector **result_vectors = (EidosValue_Object_vector **)malloc(receivers_count * sizeof(EidosValue_Object_vector *)); + EidosValue_Object **result_vectors = (EidosValue_Object **)malloc(receivers_count * sizeof(EidosValue_Object *)); for (int receiver_index = 0; receiver_index < receivers_count; ++receiver_index) { - EidosValue_Object_vector *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class); + EidosValue_Object *empty_individuals_vec = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class); dictionary->SetKeyValue_IntegerKeys(receiver_index, EidosValue_SP(empty_individuals_vec)); result_vectors[receiver_index] = empty_individuals_vec; @@ -5451,7 +5451,7 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighbors(EidosGlobalStringI double *receiver_position = receiver_subpop_data.positions_ + (size_t)receiver_index_in_subpop * SLIM_MAX_DIMENSIONALITY; - EidosValue_Object_vector *result_vec = result_vectors[receiver_index]; + EidosValue_Object *result_vec = result_vectors[receiver_index]; if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -5512,10 +5512,10 @@ EidosValue_SP InteractionType::ExecuteMethod_nearestNeighborsOfPoint(EidosGlobal count = exerter_subpop_data.kd_node_count_ALL_; if (count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // Find the neighbors - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); if (count < exerter_subpop_size) // reserve only if we are finding fewer than every possible neighbor result_vec->reserve((int)count); @@ -6142,7 +6142,7 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID else { if (returnIndividuals) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); else return gStaticEidosValue_LogicalF; } @@ -6154,7 +6154,7 @@ EidosValue_SP InteractionType::ExecuteMethod_testConstraints(EidosGlobalStringID if (returnIndividuals) { - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); for (int index = 0; index < individuals_count; ++index) { diff --git a/core/interaction_type.h b/core/interaction_type.h index 9050ab31..1c5f51af 100644 --- a/core/interaction_type.h +++ b/core/interaction_type.h @@ -280,13 +280,13 @@ class InteractionType : public EidosDictionaryUnretained void FindNeighbors1_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, SLiM_kdNode **best, double *best_dist); void FindNeighbors1_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, SLiM_kdNode **best, double *best_dist, int p_phase); void FindNeighbors1_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, SLiM_kdNode **best, double *best_dist, int p_phase); - void FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals); - void FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase); - void FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object_vector &p_result_vec, std::vector &p_individuals, int p_phase); + void FindNeighborsA_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals); + void FindNeighborsA_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase); + void FindNeighborsA_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, EidosValue_Object &p_result_vec, std::vector &p_individuals, int p_phase); void FindNeighborsN_1(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, int p_count, SLiM_kdNode **best, double *best_dist); void FindNeighborsN_2(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, int p_count, SLiM_kdNode **best, double *best_dist, int p_phase); void FindNeighborsN_3(SLiM_kdNode *root, double *nd, slim_popsize_t p_focal_individual_index, int p_count, SLiM_kdNode **best, double *best_dist, int p_phase); - void FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object_vector &p_result_vec, Individual *p_excluded_individual, bool constraints_active); + void FindNeighbors(Subpopulation *p_subpop, SLiM_kdNode *kd_root, slim_popsize_t kd_node_count, double *p_point, int p_count, EidosValue_Object &p_result_vec, Individual *p_excluded_individual, bool constraints_active); // this is a malloced 1D/2D/3D buffer, depending on our spatiality, that contains clipped integral values // for distances, for a focal individual, from 0 to max_distance_ to the nearest edge in each dimension diff --git a/core/mutation.cpp b/core/mutation.cpp index 0a857236..f7dbd90d 100644 --- a/core/mutation.cpp +++ b/core/mutation.cpp @@ -593,7 +593,7 @@ EidosValue *Mutation::GetProperty_Accelerated_selectionCoeff(EidosObject **p_val EidosValue *Mutation::GetProperty_Accelerated_mutationType(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/core/mutation_type.cpp b/core/mutation_type.cpp index df2cf806..20d46cae 100644 --- a/core/mutation_type.cpp +++ b/core/mutation_type.cpp @@ -60,7 +60,7 @@ MutationType::MutationType(Species &p_species, slim_objectid_t p_mutation_type_i #else MutationType::MutationType(Species &p_species, slim_objectid_t p_mutation_type_id, double p_dominance_coeff, bool p_nuc_based, DFEType p_dfe_type, std::vector p_dfe_parameters, std::vector p_dfe_strings) : #endif -self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('m', p_mutation_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_MutationType_Class))), +self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('m', p_mutation_type_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_MutationType_Class))), species_(p_species), mutation_type_id_(p_mutation_type_id), dominance_coeff_(static_cast(p_dominance_coeff)), haploid_dominance_coeff_(1.0), dfe_type_(p_dfe_type), dfe_parameters_(std::move(p_dfe_parameters)), dfe_strings_(std::move(p_dfe_strings)), nucleotide_based_(p_nuc_based), convert_to_substitution_(false), stack_policy_(MutationStackPolicy::kStack), stack_group_(p_mutation_type_id), cached_dfe_script_(nullptr) #ifdef SLIM_KEEP_MUTTYPE_REGISTRIES , muttype_registry_call_count_(0), keeping_muttype_registry_(false) @@ -469,7 +469,7 @@ EidosValue_SP MutationType::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 diff --git a/core/slim_eidos_block.cpp b/core/slim_eidos_block.cpp index 39a0c675..789cd82c 100644 --- a/core/slim_eidos_block.cpp +++ b/core/slim_eidos_block.cpp @@ -784,8 +784,8 @@ SLiMEidosBlockType SLiMEidosBlock::BlockTypeForRootNode(EidosASTNode *p_root_nod } SLiMEidosBlock::SLiMEidosBlock(EidosASTNode *p_root_node) : - self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), - script_block_symbol_(gEidosID_none, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), + self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), + script_block_symbol_(gEidosID_none, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), root_node_(p_root_node), user_script_line_offset_(p_root_node->token_->token_line_) { // self_symbol_ is always a constant, but can't be marked as such on construction @@ -1118,8 +1118,8 @@ SLiMEidosBlock::SLiMEidosBlock(EidosASTNode *p_root_node) : } SLiMEidosBlock::SLiMEidosBlock(slim_objectid_t p_id, const std::string &p_script_string, int32_t p_user_script_line_offset, SLiMEidosBlockType p_type, slim_tick_t p_start, slim_tick_t p_end, Species *p_species_spec, Species *p_ticks_spec) : - self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), - script_block_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('s', p_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMEidosBlock_Class))), + self_symbol_(gID_self, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), + script_block_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('s', p_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMEidosBlock_Class))), type_(p_type), block_id_(p_id), start_tick_(p_start), end_tick_(p_end), species_spec_(p_species_spec), ticks_spec_(p_ticks_spec), user_script_line_offset_(p_user_script_line_offset) { // self_symbol_ is always a constant, but can't be marked as such on construction @@ -1487,17 +1487,17 @@ EidosValue_SP SLiMEidosBlock::GetProperty(EidosGlobalStringID p_property_id) { // With no species spec, we return an empty object vector of class Species; this is allowed since this is a read-only property if (species_spec_) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(species_spec_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(species_spec_, gSLiM_Species_Class)); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class)); } case gID_ticksSpec: { // With no ticks spec, we return an empty object vector of class Species; this is allowed since this is a read-only property if (ticks_spec_) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(ticks_spec_, gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(ticks_spec_, gSLiM_Species_Class)); else - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Species_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Species_Class)); } // variables diff --git a/core/slim_functions.cpp b/core/slim_functions.cpp index 4317c500..5f73f629 100644 --- a/core/slim_functions.cpp +++ b/core/slim_functions.cpp @@ -1415,7 +1415,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectordata(); + individuals_buffer = (Individual **)((EidosValue_Object *)individuals_value)->data(); } // This very weird code tests that the layout of ivars inside Individual is what we expect it to be below @@ -1663,7 +1663,7 @@ EidosValue_SP SLiM_ExecuteFunction_summarizeIndividuals(const std::vectorAllocateChunk()) EidosValue_Object_vector(gEidosDictionaryRetained_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosDictionaryRetained_Class)); } std::string metadata_schema_string(temp_tables.metadata_schema, temp_tables.metadata_schema_length); @@ -1894,7 +1894,7 @@ EidosValue_SP SLiM_ExecuteFunction_treeSeqMetadata(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); objectElement->AddJSONFrom(metadata); objectElement->ContentsChanged("treeSeqMetadata()"); diff --git a/core/spatial_map.cpp b/core/spatial_map.cpp index e7e71b2a..07f11cd0 100644 --- a/core/spatial_map.cpp +++ b/core/spatial_map.cpp @@ -1224,7 +1224,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_add(EidosGlobalStringID p_method_id, con _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)blend(ifo x, float$ xFraction) @@ -1275,7 +1275,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_blend(EidosGlobalStringID p_method_id, c _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)multiply(ifo x) @@ -1319,7 +1319,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_multiply(EidosGlobalStringID p_method_id _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)subtract(ifo x) @@ -1363,7 +1363,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_subtract(EidosGlobalStringID p_method_id _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)divide(ifo x) @@ -1407,7 +1407,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_divide(EidosGlobalStringID p_method_id, _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)power(ifo x) @@ -1451,7 +1451,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_power(EidosGlobalStringID p_method_id, c _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (object)exp(void) @@ -1465,7 +1465,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_exp(EidosGlobalStringID p_method_id, con _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (void)changeColors([Nif valueRange = NULL], [Ns color = NULL]) @@ -1842,7 +1842,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_interpolate(EidosGlobalStringID p_method } } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (string)mapColor(numeric value) @@ -1977,7 +1977,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_mapImage(EidosGlobalStringID p_method_id } } - EidosValue_SP result_SP(EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(image, gEidosImage_Class))); + EidosValue_SP result_SP(EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(image, gEidosImage_Class))); // image is now retained by result_SP, so we can release it image->Release(); @@ -2111,7 +2111,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_rescale(EidosGlobalStringID p_method_id, _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } // ********************* - (float)sampleImprovedNearbyPoint(float point, float$ maxDistance, string$ functionType, ...) @@ -2595,7 +2595,7 @@ EidosValue_SP SpatialMap::ExecuteMethod_smooth(EidosGlobalStringID p_method_id, _ValuesChanged(); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SpatialMap_Class)); } @@ -2616,7 +2616,7 @@ EidosValue_SP SpatialMap::_DeriveTemporarySpatialMapWithEidosValue(EidosValue *p // make a duplicate of this SpatialMap SpatialMap *objectElement = new SpatialMap("__tempmap__INTERNAL__", *this); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gSLiM_SpatialMap_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gSLiM_SpatialMap_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -2639,7 +2639,7 @@ static EidosValue_SP SLiM_Instantiate_SpatialMap(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr); SpatialMap *objectElement = new SpatialMap(name, *map); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gSLiM_SpatialMap_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gSLiM_SpatialMap_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); diff --git a/core/species.cpp b/core/species.cpp index 810729db..b94f7722 100644 --- a/core/species.cpp +++ b/core/species.cpp @@ -100,7 +100,7 @@ static const char *SLIM_TREES_FILE_VERSION = "0.8"; // SLiM 4.0.x onward, wit #pragma mark - Species::Species(Community &p_community, slim_objectid_t p_species_id, const std::string &p_name) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(p_name), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Species_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(p_name), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Species_Class))), x_experiments_enabled_(false), model_type_(p_community.model_type_), community_(p_community), population_(*this), name_(p_name), species_id_(p_species_id) { // self_symbol_ is always a constant, but can't be marked as such on construction diff --git a/core/species_eidos.cpp b/core/species_eidos.cpp index 24799b9f..a753c2f9 100644 --- a/core/species_eidos.cpp +++ b/core/species_eidos.cpp @@ -212,7 +212,7 @@ EidosValue_SP Species::ExecuteContextFunction_initializeGenomicElement(const std GenomicElementType *genomic_element_type_ptr_0 = ((type_count == 1) ? SLiM_ExtractGenomicElementTypeFromEidosValue_io(genomicElementType_value, 0, &community_, this, "initializeGenomicElement()") : nullptr); // SPECIES CONSISTENCY CHECK GenomicElementType *genomic_element_type_ptr = nullptr; slim_position_t start_position = 0, end_position = 0; - EidosValue_Object_vector *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_GenomicElement_Class))->resize_no_initialize(element_count); + EidosValue_Object *result_vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_GenomicElement_Class))->resize_no_initialize(element_count); for (int element_index = 0; element_index < element_count; ++element_index) { @@ -1461,7 +1461,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_singleton(avatar_)); } case gID_chromosome: - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(chromosome_, gSLiM_Chromosome_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(chromosome_, gSLiM_Chromosome_Class)); case gID_chromosomeType: { switch (modeled_chromosome_type_) @@ -1540,7 +1540,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_genomicElementTypes: { - 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 ge_type : genomic_element_types_) @@ -1553,7 +1553,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) Mutation *mut_block_ptr = gSLiM_Mutation_Block; int registry_size; const MutationIndex *registry = population_.MutationRegistry(®istry_size); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(registry_size); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(registry_size); EidosValue_SP result_SP = EidosValue_SP(vec); for (int registry_index = 0; registry_index < registry_size; ++registry_index) @@ -1563,7 +1563,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_mutationTypes: { - 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 mutation_type : mutation_types_) @@ -1581,7 +1581,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) } case gID_scriptBlocks: { - 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); const std::vector &script_blocks = community_.AllScriptBlocksForSpecies(this); // this will only be species-specific callbacks @@ -1594,7 +1594,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) return (sex_enabled_ ? gStaticEidosValue_LogicalT : gStaticEidosValue_LogicalF); case gID_subpopulations: { - 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 pop : population_.subpops_) @@ -1606,7 +1606,7 @@ EidosValue_SP Species::GetProperty(EidosGlobalStringID p_property_id) { std::vector &substitutions = population_.substitutions_; int substitution_count = (int)substitutions.size(); - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Substitution_Class))->resize_no_initialize_RR(substitution_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Substitution_Class))->resize_no_initialize_RR(substitution_count); EidosValue_SP result_SP = EidosValue_SP(vec); for (int sub_index = 0; sub_index < substitution_count; ++sub_index) @@ -1853,7 +1853,7 @@ EidosValue_SP Species::ExecuteMethod_individualsWithPedigreeIDs(EidosGlobalStrin int pedigreeIDs_count = pedigreeIDs_value->Count(); if (pedigreeIDs_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // Assemble the result if (pedigreeIDs_count == 1) @@ -1868,18 +1868,18 @@ EidosValue_SP Species::ExecuteMethod_individualsWithPedigreeIDs(EidosGlobalStrin for (Individual *ind : inds) { if (ind->PedigreeID() == pedigree_id) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(ind, gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(ind, gSLiM_Individual_Class)); } } // Didn't find a match, so return an empty result - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); } else { // Non-singleton case: vectorized access to the pedigree IDs const int64_t *pedigree_id_data = pedigreeIDs_value->IntData(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(pedigreeIDs_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(pedigreeIDs_count); // reserve enough space for all results if (pedigreeIDs_count < 30) // crossover point determined by timing tests on macOS with various subpop sizes; 30 seems good, although it will vary across paltforms etc. { @@ -2234,11 +2234,11 @@ EidosValue_SP Species::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_metho if (mutation_count == 1) { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(mut_block_ptr + mutation_registry[0], gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(mut_block_ptr + mutation_registry[0], gSLiM_Mutation_Class)); } else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(mutation_count); EidosValue_SP result_SP = EidosValue_SP(vec); for (int mut_index = 0; mut_index < mutation_count; ++mut_index) @@ -2271,11 +2271,11 @@ EidosValue_SP Species::ExecuteMethod_mutationsOfType(EidosGlobalStringID p_metho // Now allocate the result vector and assemble it if (match_count == 1) { - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(mut_block_ptr + first_match, gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(mut_block_ptr + first_match, gSLiM_Mutation_Class)); } else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class))->resize_no_initialize_RR(match_count); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class))->resize_no_initialize_RR(match_count); EidosValue_SP result_SP = EidosValue_SP(vec); if (match_count != 0) @@ -3116,7 +3116,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho const MutationIndex *registry = population_.MutationRegistry(®istry_size); int match_count = 0, registry_index; Mutation *first_match = nullptr; - EidosValue_Object_vector *vec = nullptr; + EidosValue_Object *vec = nullptr; if (has_id && !exclude && !mutation_type_ptr && (position == -1) && (nucleotide == -1) && !has_tag) { @@ -3136,7 +3136,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } else if (match_count == 2) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); vec->push_object_element_RR(first_match); vec->push_object_element_RR(mut); } @@ -3165,7 +3165,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } else if (match_count == 2) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); vec->push_object_element_RR(first_match); vec->push_object_element_RR(mut); } @@ -3197,7 +3197,7 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } else if (match_count == 2) { - vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); vec->push_object_element_RR(first_match); vec->push_object_element_RR(mut); } @@ -3209,9 +3209,9 @@ EidosValue_SP Species::ExecuteMethod_subsetMutations(EidosGlobalStringID p_metho } if (match_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Mutation_Class)); else if (match_count == 1) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(first_match, gSLiM_Mutation_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(first_match, gSLiM_Mutation_Class)); else return EidosValue_SP(vec); } diff --git a/core/subpopulation.cpp b/core/subpopulation.cpp index 13bcf5e1..338a1960 100644 --- a/core/subpopulation.cpp +++ b/core/subpopulation.cpp @@ -834,7 +834,7 @@ void Subpopulation::CheckIndividualIntegrity(void) } Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopulation_id, slim_popsize_t p_subpop_size, bool p_record_in_treeseq, bool p_haploid) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Subpopulation_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Subpopulation_Class))), community_(p_population.species_.community_), species_(p_population.species_), population_(p_population), model_type_(p_population.model_type_), subpopulation_id_(p_subpopulation_id), name_(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), genome_pool_(p_population.species_genome_pool_), individual_pool_(p_population.species_individual_pool_), genome_junkyard_nonnull(p_population.species_genome_junkyard_nonnull), genome_junkyard_null(p_population.species_genome_junkyard_null), parent_subpop_size_(p_subpop_size), child_subpop_size_(p_subpop_size) #if defined(SLIMGUI) @@ -876,7 +876,7 @@ Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopu // SEX ONLY Subpopulation::Subpopulation(Population &p_population, slim_objectid_t p_subpopulation_id, slim_popsize_t p_subpop_size, bool p_record_in_treeseq, double p_sex_ratio, GenomeType p_modeled_chromosome_type, bool p_haploid) : - self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_Subpopulation_Class))), + self_symbol_(EidosStringRegistry::GlobalStringIDForString(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_Subpopulation_Class))), community_(p_population.species_.community_), species_(p_population.species_), population_(p_population), model_type_(p_population.model_type_), subpopulation_id_(p_subpopulation_id), name_(SLiMEidosScript::IDStringWithPrefix('p', p_subpopulation_id)), genome_pool_(p_population.species_genome_pool_), individual_pool_(p_population.species_individual_pool_), genome_junkyard_nonnull(p_population.species_genome_junkyard_nonnull), genome_junkyard_null(p_population.species_genome_junkyard_null), parent_subpop_size_(p_subpop_size), parent_sex_ratio_(p_sex_ratio), child_subpop_size_(p_subpop_size), child_sex_ratio_(p_sex_ratio), sex_enabled_(true), modeled_chromosome_type_(p_modeled_chromosome_type) @@ -2200,7 +2200,7 @@ double Subpopulation::ApplyMutationEffectCallbacks(MutationIndex p_mutation, int else { // local variables for the callback parameters that we might need to allocate here, and thus need to free below - EidosValue_Object_singleton local_mut(gSLiM_Mutation_Block + p_mutation, gSLiM_Mutation_Class); + EidosValue_Object local_mut(gSLiM_Mutation_Block + p_mutation, gSLiM_Mutation_Class); EidosValue_Float local_effect(p_computed_fitness); // We need to actually execute the script; we start a block here to manage the lifetime of the symbol table @@ -3893,7 +3893,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) { if (!cached_child_genomes_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(child_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(child_genomes_.size()); cached_child_genomes_value_ = EidosValue_SP(vec); for (auto genome_iter : child_genomes_) @@ -3923,7 +3923,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) { if (!cached_parent_genomes_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); cached_parent_genomes_value_ = EidosValue_SP(vec); for (auto genome_iter : parent_genomes_) @@ -3954,7 +3954,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) { if (child_generation_valid_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(child_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(child_genomes_.size()); for (auto genome_iter : child_genomes_) if (!genome_iter->IsNull()) @@ -3964,7 +3964,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) } else { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Genome_Class))->reserve(parent_genomes_.size()); for (auto genome_iter : parent_genomes_) if (!genome_iter->IsNull()) @@ -3983,10 +3983,10 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (cached_child_individuals_value_ && (cached_child_individuals_value_->Count() != subpop_size)) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): (internal error) cached_child_individuals_value_ out of date." << EidosTerminate(); - // Build and return an EidosValue_Object_vector with the current set of individuals in it + // Build and return an EidosValue_Object with the current set of individuals in it if (!cached_child_individuals_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(subpop_size); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(subpop_size); cached_child_individuals_value_ = EidosValue_SP(vec); for (slim_popsize_t individual_index = 0; individual_index < subpop_size; individual_index++) @@ -4003,10 +4003,10 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) if (cached_parent_individuals_value_ && (cached_parent_individuals_value_->Count() != subpop_size)) EIDOS_TERMINATION << "ERROR (Subpopulation::GetProperty): (internal error) cached_parent_individuals_value_ out of date." << EidosTerminate(); - // Build and return an EidosValue_Object_vector with the current set of individuals in it + // Build and return an EidosValue_Object with the current set of individuals in it if (!cached_parent_individuals_value_) { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(subpop_size); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(subpop_size); cached_parent_individuals_value_ = EidosValue_SP(vec); for (slim_popsize_t individual_index = 0; individual_index < subpop_size; individual_index++) @@ -4139,7 +4139,7 @@ EidosValue_SP Subpopulation::GetProperty(EidosGlobalStringID p_property_id) } case gID_spatialMaps: { - EidosValue_Object_vector *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_SpatialMap_Class))->reserve(spatial_maps_.size()); + EidosValue_Object *vec = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_SpatialMap_Class))->reserve(spatial_maps_.size()); for (const auto &spatialMapIter : spatial_maps_) vec->push_object_element_no_check_RR(spatialMapIter.second); @@ -4148,7 +4148,7 @@ EidosValue_SP Subpopulation::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)); } case gID_individualCount: // ACCELERATED return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(CurrentSubpopSize())); @@ -4493,7 +4493,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCloned(EidosGlobalStringID p_metho if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCloned): addCloned() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -4643,7 +4643,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addCrossed(EidosGlobalStringID p_meth if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addCrossed): addCrossed() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -4776,7 +4776,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addEmpty(EidosGlobalStringID p_method if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addEmpty): addEmpty() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -4932,7 +4932,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addRecombinant(EidosGlobalStringID p_ if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addRecombinant): addRecombinant() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -5519,7 +5519,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_addSelfed(EidosGlobalStringID p_metho if ((child_count < 0) || (child_count > SLIM_MAX_SUBPOP_SIZE)) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_addSelfed): addSelfed() requires an offspring count >= 0 and <= 1000000000." << EidosTerminate(); - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class))->reserve(child_count); // reserve enough space for all results if (child_count == 0) return EidosValue_SP(result); @@ -7076,7 +7076,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID if (sample_size < 0) EIDOS_TERMINATION << "ERROR (Subpopulation::ExecuteMethod_sampleIndividuals): sampleIndividuals() requires a sample size >= 0 (" << sample_size << " supplied)." << EidosTerminate(nullptr); if ((sample_size == 0) || (x_count == 0)) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // a specific individual may be excluded EidosValue *exclude_value = p_arguments[2].get(); @@ -7185,7 +7185,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID { // we're in the simple case of no specifed tag/ageMin/ageMax/migrant/tagL, so maybe we can handle it quickly if (candidate_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); else if (!replace && (candidate_count < sample_size)) sample_size = candidate_count; @@ -7198,13 +7198,13 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID if ((excluded_index != -1) && (sample_index >= excluded_index)) sample_index++; - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(parent_individuals_[sample_index], gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(parent_individuals_[sample_index], gSLiM_Individual_Class)); } else if (replace) { // with replacement, we can just do a series of independent draws - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get())->resize_no_initialize(sample_size); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get())->resize_no_initialize(sample_size); EidosObject **object_result_data = result->data(); EIDOS_THREAD_COUNT(gEidos_OMP_threads_SAMPLE_INDIVIDUALS_1); @@ -7241,8 +7241,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID { // a sample size of two without replacement is expected to be common (interacting pairs) so optimize for it // note that the code above guarantees that here there are at least two candidates to draw - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get())->resize_no_initialize(sample_size); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get())->resize_no_initialize(sample_size); gsl_rng *rng = EIDOS_GSL_RNG(omp_get_thread_num()); int sample_index1 = (int)Eidos_rng_uniform_int(rng, candidate_count) + first_candidate_index; @@ -7346,7 +7346,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID } } - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(parent_individuals_[sample_index], gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(parent_individuals_[sample_index], gSLiM_Individual_Class)); } } @@ -7455,13 +7455,13 @@ EidosValue_SP Subpopulation::ExecuteMethod_sampleIndividuals(EidosGlobalStringID } if (candidate_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); else if (!replace && (candidate_count < sample_size)) sample_size = candidate_count; // do the sampling - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get())->resize_no_initialize(sample_size); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get())->resize_no_initialize(sample_size); EidosObject **object_result_data = result->data(); if (replace) @@ -7528,7 +7528,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID int x_count = parent_subpop_size_; if (x_count == 0) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); // a specific individual may be excluded EidosValue *exclude_value = p_arguments[0].get(); @@ -7633,8 +7633,8 @@ EidosValue_SP Subpopulation::ExecuteMethod_subsetIndividuals(EidosGlobalStringID else excluded_index = -1; - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_Individual_Class)); - EidosValue_Object_vector *result = ((EidosValue_Object_vector *)result_SP.get()); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_Individual_Class)); + EidosValue_Object *result = ((EidosValue_Object *)result_SP.get()); if (!tag_specified && !ageMin_specified && !ageMax_specified && !migrant_specified && !any_tagL_specified) { @@ -7771,7 +7771,7 @@ EidosValue_SP Subpopulation::ExecuteMethod_defineSpatialMap(EidosGlobalStringID spatial_maps_.emplace(map_name, spatial_map); // already retained by new SpatialMap(); that is the retain for spatial_maps_ - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(spatial_map, gSLiM_SpatialMap_Class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(spatial_map, gSLiM_SpatialMap_Class)); } // ********************* – (void)addSpatialMap(object$ map) diff --git a/core/subpopulation.h b/core/subpopulation.h index 14ac2755..0d3f2c78 100644 --- a/core/subpopulation.h +++ b/core/subpopulation.h @@ -377,7 +377,7 @@ class Subpopulation : public EidosDictionaryUnretained void ViabilitySurvival(std::vector &p_survival_callbacks); void IncrementIndividualAges(void); IndividualSex _GenomeConfigurationForSex(EidosValue *p_sex_value, GenomeType &p_genome1_type, GenomeType &p_genome2_type, bool &p_genome1_null, bool &p_genome2_null); - inline __attribute__((always_inline)) void _ProcessNewOffspring(bool p_proposed_child_accepted, Individual *p_individual, Genome *p_genome1, Genome *p_genome2, EidosValue_Object_vector *p_result) + inline __attribute__((always_inline)) void _ProcessNewOffspring(bool p_proposed_child_accepted, Individual *p_individual, Genome *p_genome1, Genome *p_genome2, EidosValue_Object *p_result) { if (p_proposed_child_accepted) { diff --git a/core/substitution.cpp b/core/substitution.cpp index 2cc0b5e2..1dbfe9cb 100644 --- a/core/substitution.cpp +++ b/core/substitution.cpp @@ -290,7 +290,7 @@ EidosValue *Substitution::GetProperty_Accelerated_selectionCoeff(EidosObject **p EidosValue *Substitution::GetProperty_Accelerated_mutationType(EidosObject **p_values, size_t p_values_size) { - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gSLiM_MutationType_Class))->resize_no_initialize(p_values_size); for (size_t value_index = 0; value_index < p_values_size; ++value_index) { diff --git a/eidos/eidos_class_DataFrame.cpp b/eidos/eidos_class_DataFrame.cpp index 3d88ff38..2dafc6a8 100644 --- a/eidos/eidos_class_DataFrame.cpp +++ b/eidos/eidos_class_DataFrame.cpp @@ -634,7 +634,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_subset(EidosGlobalStringID p_method_ else { // Note that this retains cols_subset, before the call to Release below - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(cols_subset, gEidosDataFrame_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(cols_subset, gEidosDataFrame_Class)); } rows_subset->Release(); @@ -658,7 +658,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_subsetColumns(EidosGlobalStringID p_ EidosDataFrame *objectElement = SubsetColumns(index_value); objectElement->ContentsChanged("subsetColumns()"); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -678,7 +678,7 @@ EidosValue_SP EidosDataFrame::ExecuteMethod_subsetRows(EidosGlobalStringID p_met EidosDataFrame *objectElement = SubsetRows(index_value, drop_value->LogicalAtIndex_NOCAST(0, nullptr)); objectElement->ContentsChanged("subsetRows()"); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -700,7 +700,7 @@ static EidosValue_SP Eidos_Instantiate_EidosDataFrame(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -1132,7 +1132,7 @@ static EidosValue_SP Eidos_ExecuteFunction_readCSV(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDataFrame_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDataFrame_Class)); objectElement->Release(); // objectElement is now retained by result_SP, so we can release it diff --git a/eidos/eidos_class_Dictionary.cpp b/eidos/eidos_class_Dictionary.cpp index 87aef121..b1079a3b 100644 --- a/eidos/eidos_class_Dictionary.cpp +++ b/eidos/eidos_class_Dictionary.cpp @@ -862,7 +862,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) if (value.is_null()) { EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); - state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->Release(); // now retained by state_ptr->dictionary_symbols_ } else if (value.is_boolean()) @@ -889,7 +889,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) { EidosDictionaryRetained *dictionary = new EidosDictionaryRetained(); dictionary->AddJSONFrom(value); - state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(dictionary, gEidosDictionaryRetained_Class)); + state_ptr->dictionary_symbols_[key] = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(dictionary, gEidosDictionaryRetained_Class)); dictionary->Release(); // now retained by state_ptr->dictionary_symbols_ } else if (value.is_array()) @@ -975,7 +975,7 @@ void EidosDictionaryUnretained::AddJSONFrom(nlohmann::json &json) } else if (array_type == nlohmann::json::value_t::object) { - EidosValue_Object_vector *object_value = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosDictionaryRetained_Class); + EidosValue_Object *object_value = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosDictionaryRetained_Class); for (size_t element_index = 0; element_index < array_count; ++element_index) { @@ -1218,7 +1218,7 @@ EidosValue_SP EidosDictionaryUnretained::ExecuteMethod_getRowValues(EidosGlobalS EidosValue_SP result_SP(nullptr); EidosDictionaryRetained *objectElement = new EidosDictionaryRetained(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); // With no columns, the indices don't matter, and the result is a new empty dictionary if (KeyCount() == 0) @@ -1648,7 +1648,7 @@ static EidosValue_SP Eidos_Instantiate_EidosDictionaryRetained(const std::vector EidosValue_SP result_SP(nullptr); EidosDictionaryRetained *objectElement = new EidosDictionaryRetained(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); diff --git a/eidos/eidos_class_Image.cpp b/eidos/eidos_class_Image.cpp index de6b5b9c..b0dae9e1 100644 --- a/eidos/eidos_class_Image.cpp +++ b/eidos/eidos_class_Image.cpp @@ -366,7 +366,7 @@ static EidosValue_SP Eidos_Instantiate_EidosImage(const std::vectorAllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosImage_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosImage_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); diff --git a/eidos/eidos_class_TestElement.cpp b/eidos/eidos_class_TestElement.cpp index ce304172..f2758a6d 100644 --- a/eidos/eidos_class_TestElement.cpp +++ b/eidos/eidos_class_TestElement.cpp @@ -67,7 +67,7 @@ EidosValue_SP EidosTestElement::GetProperty(EidosGlobalStringID p_property_id) else if (p_property_id == gEidosID__increment) { EidosTestElement *inc_element = new EidosTestElement(yolk_ + 1); - EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(inc_element, gEidosTestElement_Class)); + EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(inc_element, gEidosTestElement_Class)); inc_element->Release(); // retval now owns it; release the retain from new return retval; @@ -153,7 +153,7 @@ EidosValue_SP EidosTestElement::ExecuteMethod_squareTest(EidosGlobalStringID p_m { #pragma unused (p_method_id, p_arguments, p_interpreter) EidosTestElement *sq_element = new EidosTestElement(yolk_ * yolk_); - EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(sq_element, gEidosTestElement_Class)); + EidosValue_SP retval(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(sq_element, gEidosTestElement_Class)); sq_element->Release(); // retval now owns it; release the retain from new return retval; @@ -176,7 +176,7 @@ static EidosValue_SP Eidos_Instantiate_EidosTestElement(const std::vectorIntAtIndex_NOCAST(0, nullptr)); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosTestElement_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosTestElement_Class)); // objectElement is now retained by result_SP, so we can release it objectElement->Release(); @@ -319,7 +319,7 @@ static EidosValue_SP Eidos_Instantiate_EidosTestElementNRR(const std::vectorIntAtIndex_NOCAST(0, nullptr)); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosTestElementNRR_Class)); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosTestElementNRR_Class)); // Note that since these are not under retain/release, and Eidos has no logic to keep track of them and release them, they just leak // This is probably what EidosTestElement::FreeThunks() used to do before EidosTestElement was put under retain/release, so that diff --git a/eidos/eidos_functions.cpp b/eidos/eidos_functions.cpp index 5d9c8142..4b33f1ac 100644 --- a/eidos/eidos_functions.cpp +++ b/eidos/eidos_functions.cpp @@ -729,8 +729,8 @@ EidosValue_SP ConcatenateEidosValues(const std::vector &p_argumen } else if (has_object_type) { - EidosValue_Object_vector *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(element_class))->resize_no_initialize_RR(reserve_size); - EidosValue_Object_vector_SP result_SP = EidosValue_Object_vector_SP(result); + EidosValue_Object *result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(element_class))->resize_no_initialize_RR(reserve_size); + EidosValue_Object_SP result_SP = EidosValue_Object_SP(result); int result_set_index = 0; for (int arg_index = 0; arg_index < argument_count; ++arg_index) @@ -971,7 +971,7 @@ EidosValue_SP UniqueEidosValue(const EidosValue *p_x_value, bool p_force_new_vec { // We have x_count != 1, so the type of x_value must be EidosValue_Object_vector; we can use the fast API EidosObject * const *object_data = x_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); if (p_preserve_order) @@ -1115,8 +1115,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa else if (original_value_type == EidosValueType::kValueObject) { EidosObject * const *first_child_vec = p_original_value->ObjectData(); - EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); - EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); + EidosValue_Object_SP obj_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)p_original_value)->Class())); + EidosValue_Object *obj_result = obj_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) if (logical_index_data[value_idx]) @@ -1197,8 +1197,8 @@ EidosValue_SP SubsetEidosValue(const EidosValue *p_original_value, const EidosVa { // result type is object; optimize for that EidosObject * const *first_child_vec = p_original_value->ObjectData(); - EidosValue_Object_vector_SP obj_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)p_original_value)->Class())); - EidosValue_Object_vector *obj_result = obj_result_SP->reserve(indices_count); + EidosValue_Object_SP obj_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)p_original_value)->Class())); + EidosValue_Object *obj_result = obj_result_SP->reserve(indices_count); for (int value_idx = 0; value_idx < indices_count; value_idx++) { diff --git a/eidos/eidos_functions_math.cpp b/eidos/eidos_functions_math.cpp index 568ddbd1..283cece3 100644 --- a/eidos/eidos_functions_math.cpp +++ b/eidos/eidos_functions_math.cpp @@ -1170,7 +1170,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorNewMatchingType(); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); } } else if (x_count == 1) @@ -1222,7 +1222,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorNewMatchingType(); - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); } } else if (y_count == 1) @@ -1278,7 +1278,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr); - EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + EidosValue_Object *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); for (int value_index = 0; value_index < result_count; ++value_index) @@ -1397,7 +1397,7 @@ EidosValue_SP Eidos_ExecuteFunction_setDifference(const std::vectorObjectData(); EidosObject * const *object_vec1 = y_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1572,7 +1572,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); else result_SP = x_value->NewMatchingType(); } @@ -1750,7 +1750,7 @@ EidosValue_SP Eidos_ExecuteFunction_setIntersection(const std::vectorObjectData(); EidosObject * const *object_vec1 = y_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); for (int value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -1941,7 +1941,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorNewMatchingType(); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); } } else if ((x_count == 1) || (y_count == 1)) @@ -2016,7 +2016,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectElementAtIndex_NOCAST(0, nullptr); - EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + EidosValue_Object *object_element_vec = dynamic_cast(result_SP.get()); EidosObject * const *object_element_data = object_element_vec->data(); int value_index; @@ -2203,7 +2203,7 @@ EidosValue_SP Eidos_ExecuteFunction_setSymmetricDifference(const std::vectorObjectData(); EidosObject * const *object_vec1 = y_value->ObjectData(); - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()); result_SP = EidosValue_SP(object_result); for (value_index0 = 0; value_index0 < x_count; ++value_index0) @@ -2408,9 +2408,9 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p EidosObject *obj0 = x_value->ObjectElementAtIndex_NOCAST(0, nullptr), *obj1 = y_value->ObjectElementAtIndex_NOCAST(0, nullptr); if (obj0 == obj1) - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(obj0, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(obj0, ((EidosValue_Object *)x_value)->Class())); else - result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); + result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object({obj0, obj1}, ((EidosValue_Object *)x_value)->Class())); } } else if ((x_count == 1) || (y_count == 1)) @@ -2503,7 +2503,7 @@ EidosValue_SP Eidos_ExecuteFunction_setUnion(const std::vector &p if (scan_index == result_count) { - EidosValue_Object_vector *object_element_vec = dynamic_cast(result_SP.get()); + EidosValue_Object *object_element_vec = dynamic_cast(result_SP.get()); object_element_vec->push_object_element_CRR(value); } diff --git a/eidos/eidos_functions_matrices.cpp b/eidos/eidos_functions_matrices.cpp index e49f0869..e8a3a8b2 100644 --- a/eidos/eidos_functions_matrices.cpp +++ b/eidos/eidos_functions_matrices.cpp @@ -397,7 +397,7 @@ EidosValue_SP Eidos_ExecuteFunction_cbind(const std::vector &p_ar case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; - case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; + case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(result_class))->reserve(result_length)); break; } EidosValue *result = result_SP.get(); @@ -915,7 +915,7 @@ EidosValue_SP Eidos_ExecuteFunction_rbind(const std::vector &p_ar case EidosValueType::kValueInt: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Int())->reserve(result_length)); break; case EidosValueType::kValueFloat: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Float())->reserve(result_length)); break; case EidosValueType::kValueString: result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_String_vector()); break; - case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(result_class))->reserve(result_length)); break; + case EidosValueType::kValueObject: result_SP = EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(result_class))->reserve(result_length)); break; } EidosValue *result = result_SP.get(); diff --git a/eidos/eidos_functions_other.cpp b/eidos/eidos_functions_other.cpp index 784bd7a2..0b8475ca 100644 --- a/eidos/eidos_functions_other.cpp +++ b/eidos/eidos_functions_other.cpp @@ -725,7 +725,7 @@ EidosValue_SP Eidos_ExecuteFunction_parallelGetMaxThreads(__attribute__((unused) EidosValue_SP Eidos_ExecuteFunction_parallelGetTaskThreadCounts(__attribute__((unused)) const std::vector &p_arguments, __attribute__((unused)) EidosInterpreter &p_interpreter) { EidosDictionaryRetained *objectElement = new EidosDictionaryRetained(); - EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(objectElement, gEidosDictionaryRetained_Class)); + EidosValue_SP result_SP = EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(objectElement, gEidosDictionaryRetained_Class)); #ifdef _OPENMP objectElement->SetKeyValue_StringKeys("ABS_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(gEidos_OMP_threads_ABS_FLOAT))); diff --git a/eidos/eidos_functions_values.cpp b/eidos/eidos_functions_values.cpp index 758c73b9..b21c1131 100644 --- a/eidos/eidos_functions_values.cpp +++ b/eidos/eidos_functions_values.cpp @@ -505,7 +505,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a { EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); result_SP = EidosValue_SP(object_result); @@ -820,7 +820,7 @@ EidosValue_SP Eidos_ExecuteFunction_sample(const std::vector &p_a { EidosObject * const *object_data = x_value->ObjectData(); const EidosClass *object_class = ((EidosValue_Object *)x_value)->Class(); - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(object_class))->resize_no_initialize(sample_size); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(object_class))->resize_no_initialize(sample_size); EidosObject **object_result_data = object_result->data(); result_SP = EidosValue_SP(object_result); @@ -1558,8 +1558,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a EidosObject * const *true_vec = trueValues_value->ObjectData(); EidosObject * const *false_vec = falseValues_value->ObjectData(); - EidosValue_Object_vector_SP object_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(trueValues_class)); - EidosValue_Object_vector *object_result = object_result_SP->resize_no_initialize_RR(test_count); + EidosValue_Object_SP object_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(trueValues_class)); + EidosValue_Object *object_result = object_result_SP->resize_no_initialize_RR(test_count); if (object_result->UsesRetainRelease()) { @@ -1655,8 +1655,8 @@ EidosValue_SP Eidos_ExecuteFunction_ifelse(const std::vector &p_a EidosObject *true_value = trueValues_value->ObjectElementAtIndex_NOCAST(0, nullptr); EidosObject *false_value = falseValues_value->ObjectElementAtIndex_NOCAST(0, nullptr); - EidosValue_Object_vector_SP object_result_SP = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(trueValues_class)); - EidosValue_Object_vector *object_result = object_result_SP->resize_no_initialize_RR(test_count); + EidosValue_Object_SP object_result_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(trueValues_class)); + EidosValue_Object *object_result = object_result_SP->resize_no_initialize_RR(test_count); if (object_result->UsesRetainRelease()) { @@ -2560,7 +2560,7 @@ EidosValue_SP Eidos_ExecuteFunction_sortBy(const std::vector &p_a EidosValue *x_value = p_arguments[0].get(); int x_count = x_value->Count(); - EidosValue_Object_vector *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(((EidosValue_Object *)x_value)->Class()))->resize_no_initialize_RR(x_count); + EidosValue_Object *object_result = (new (gEidosValuePool->AllocateChunk()) EidosValue_Object(((EidosValue_Object *)x_value)->Class()))->resize_no_initialize_RR(x_count); result_SP = EidosValue_SP(object_result); if (object_result->UsesRetainRelease()) diff --git a/eidos/eidos_globals.cpp b/eidos/eidos_globals.cpp index f39bcf6d..049d09fb 100644 --- a/eidos/eidos_globals.cpp +++ b/eidos/eidos_globals.cpp @@ -1086,8 +1086,6 @@ void Eidos_WarmUp(void) maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Int)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Float)); maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object_vector)); - maxEidosValueSize = std::max(maxEidosValueSize, sizeof(EidosValue_Object_singleton)); // std::cout << "sizeof(EidosValue) == " << sizeof(EidosValue) << std::endl; // std::cout << "sizeof(EidosValue_NULL) == " << sizeof(EidosValue_NULL) << std::endl; @@ -1098,8 +1096,6 @@ void Eidos_WarmUp(void) // std::cout << "sizeof(EidosValue_Int) == " << sizeof(EidosValue_Int) << std::endl; // std::cout << "sizeof(EidosValue_Float) == " << sizeof(EidosValue_Float) << std::endl; // std::cout << "sizeof(EidosValue_Object) == " << sizeof(EidosValue_Object) << std::endl; -// std::cout << "sizeof(EidosValue_Object_vector) == " << sizeof(EidosValue_Object_vector) << std::endl; -// std::cout << "sizeof(EidosValue_Object_singleton) == " << sizeof(EidosValue_Object_singleton) << std::endl; // std::cout << "maxEidosValueSize == " << maxEidosValueSize << std::endl; gEidosValuePool = new EidosObjectPool("EidosObjectPool(EidosValue)", maxEidosValueSize); @@ -1216,7 +1212,7 @@ void Eidos_WarmUp(void) // This has to be allocated after gEidosObject_Class has been initialized above; the other global permanents must be initialized // before that point, however, since properties and method signatures may use some of those global permanent values - gStaticEidosValue_Object_ZeroVec = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosObject_Class)); + gStaticEidosValue_Object_ZeroVec = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosObject_Class)); gStaticEidosValue_Object_ZeroVec->MarkAsConstant(); // Set up the built-in function map, which is immutable diff --git a/eidos/eidos_globals.h b/eidos/eidos_globals.h index 2e1b4751..f2a3b093 100644 --- a/eidos/eidos_globals.h +++ b/eidos/eidos_globals.h @@ -1192,8 +1192,6 @@ class EidosValue_String; class EidosValue_String_singleton; class EidosValue_String_vector; class EidosValue_Object; -class EidosValue_Object_singleton; -class EidosValue_Object_vector; class EidosObjectPool; class EidosPropertySignature; @@ -1229,8 +1227,6 @@ typedef Eidos_intrusive_ptr EidosValue_String_SP; typedef Eidos_intrusive_ptr EidosValue_String_singleton_SP; typedef Eidos_intrusive_ptr EidosValue_String_vector_SP; typedef Eidos_intrusive_ptr EidosValue_Object_SP; -typedef Eidos_intrusive_ptr EidosValue_Object_singleton_SP; -typedef Eidos_intrusive_ptr EidosValue_Object_vector_SP; // EidosValueType is an enum of the possible types for EidosValue objects. Note that all of these types are vectors of the stated diff --git a/eidos/eidos_interpreter.cpp b/eidos/eidos_interpreter.cpp index 8f0a1b61..04eb0375 100644 --- a/eidos/eidos_interpreter.cpp +++ b/eidos/eidos_interpreter.cpp @@ -752,7 +752,7 @@ void EidosInterpreter::_AssignRValueToLValue(EidosValue_SP p_rvalue, const Eidos } case EidosValueType::kValueObject: { - EidosValue_Object_vector *base_object_vector = dynamic_cast(base_value.get()); + EidosValue_Object *base_object_vector = dynamic_cast(base_value.get()); if (base_object_vector) { @@ -773,7 +773,7 @@ void EidosInterpreter::_AssignRValueToLValue(EidosValue_SP p_rvalue, const Eidos { // true singleton case; we can't use set_object_element_no_check_CRR() to set the element // note (rvalue_count == 1) must be true here, so there is only one case to handle - EidosValue_Object_singleton *base_object_singleton = dynamic_cast(base_value.get()); + EidosValue_Object *base_object_singleton = dynamic_cast(base_value.get()); EidosObject *rvalue = p_rvalue->ObjectElementAtIndex_CAST(0, nullptr); base_object_singleton->set_object_element_no_check_CRR(rvalue, 0); @@ -5954,14 +5954,14 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node) else if (range_type == EidosValueType::kValueObject) { EidosObject * const *range_vec = range_value->ObjectData(); - EidosValue_Object_singleton_SP index_value_SP = EidosValue_Object_singleton_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(nullptr, ((EidosValue_Object *)range_value.get())->Class())); - EidosValue_Object_singleton *index_value = index_value_SP.get(); + EidosValue_Object_SP index_value_SP = EidosValue_Object_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(nullptr, ((EidosValue_Object *)range_value.get())->Class())); + EidosValue_Object *index_value = index_value_SP.get(); global_symbols_->SetValueForSymbolNoCopy(identifier_name, index_value_SP); for (int range_index = 0; range_index < range_count; ++range_index) { - index_value->SetValue(range_vec[range_index]); + index_value->set_object_element_no_check_CRR(range_vec[range_index], 0); EidosASTNode *statement_node = p_node->children_[2]; diff --git a/eidos/eidos_test_functions_vector.cpp b/eidos/eidos_test_functions_vector.cpp index 1e7bac1c..8f0434a3 100644 --- a/eidos/eidos_test_functions_vector.cpp +++ b/eidos/eidos_test_functions_vector.cpp @@ -67,9 +67,9 @@ void _RunFunctionVectorConstructionTests_a_through_r(void) EidosAssertScriptSuccess_I("c(object(), _Test(7))._yolk;", 7); EidosAssertScriptSuccess_I("c(_Test(7), object())._yolk;", 7); EidosAssertScriptSuccess("c(object(), object());", gStaticEidosValue_Object_ZeroVec); - //EidosAssertScriptSuccess("c(object(), object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); // should fail - EidosAssertScriptSuccess("c(object(), _Test(7)[F]);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); - EidosAssertScriptSuccess("c(_Test(7)[F], object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); + //EidosAssertScriptSuccess("c(object(), object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); // should fail + EidosAssertScriptSuccess("c(object(), _Test(7)[F]);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); + EidosAssertScriptSuccess("c(_Test(7)[F], object());", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); // float() EidosAssertScriptSuccess("float(0);", gStaticEidosValue_Float_ZeroVec); @@ -129,7 +129,7 @@ void _RunFunctionVectorConstructionTests_a_through_r(void) EidosAssertScriptSuccess("rep(3, 0);", gStaticEidosValue_Integer_ZeroVec); EidosAssertScriptSuccess("rep(3.5, 0);", gStaticEidosValue_Float_ZeroVec); EidosAssertScriptSuccess("rep('foo', 0);", gStaticEidosValue_String_ZeroVec); - EidosAssertScriptSuccess("rep(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); + EidosAssertScriptSuccess("rep(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); EidosAssertScriptSuccess_NULL("rep(NULL, 2);"); EidosAssertScriptSuccess_LV("rep(T, 2);", {true, true}); EidosAssertScriptSuccess_IV("rep(3, 2);", {3, 3}); @@ -161,7 +161,7 @@ void _RunFunctionVectorConstructionTests_a_through_r(void) EidosAssertScriptSuccess("repEach(3, 0);", gStaticEidosValue_Integer_ZeroVec); EidosAssertScriptSuccess("repEach(3.5, 0);", gStaticEidosValue_Float_ZeroVec); EidosAssertScriptSuccess("repEach('foo', 0);", gStaticEidosValue_String_ZeroVec); - EidosAssertScriptSuccess("repEach(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(gEidosTestElement_Class))); + EidosAssertScriptSuccess("repEach(_Test(7), 0);", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(gEidosTestElement_Class))); EidosAssertScriptSuccess_NULL("repEach(NULL, 2);"); EidosAssertScriptSuccess_LV("repEach(T, 2);", {true, true}); EidosAssertScriptSuccess_IV("repEach(3, 2);", {3, 3}); diff --git a/eidos/eidos_value.cpp b/eidos/eidos_value.cpp index 5ee1203e..cce2547f 100644 --- a/eidos/eidos_value.cpp +++ b/eidos/eidos_value.cpp @@ -1874,9 +1874,11 @@ void EidosValue_Float::erase_index(size_t p_index) // See comments on EidosValue_Object::EidosValue_Object() below. Note this is shared by all species. std::vector gEidosValue_Object_Mutation_Registry; -EidosValue_Object::EidosValue_Object(bool p_singleton, const EidosClass *p_class) : EidosValue(EidosValueType::kValueObject, p_singleton), class_(p_class), - class_uses_retain_release_(p_class == gEidosObject_Class ? true : p_class->UsesRetainRelease()) +EidosValue_Object::EidosValue_Object(const EidosClass *p_class) : EidosValue(EidosValueType::kValueObject, false), + class_(p_class), values_(&singleton_value_), count_(0), capacity_(1) { + class_uses_retain_release_ = (class_ == gEidosObject_Class ? true : class_->UsesRetainRelease()); + // BCH 7 May 2017: OK, so, this is a hack of breathtaking disgustingness. Here is the problem. In SLiM we // need to reallocate the block in which all Mutation objects live, which invalidates all their pointers. // SLiM can mostly handle that for itself, but there is a big problem when it comes to EidosValue_Object @@ -1904,110 +1906,24 @@ EidosValue_Object::EidosValue_Object(bool p_singleton, const EidosClass *p_class } } -EidosValue_Object::~EidosValue_Object(void) +EidosValue_Object::EidosValue_Object(EidosObject *p_element1, const EidosClass *p_class) : EidosValue_Object(p_class) { - // See comment on EidosValue_Object::EidosValue_Object() above - if (registered_for_patching_) - { - THREAD_SAFETY_IN_ACTIVE_PARALLEL("EidosValue_Object::~EidosValue_Object(): gEidosValue_Object_Mutation_Registry change"); - - auto erase_iter = std::find(gEidosValue_Object_Mutation_Registry.begin(), gEidosValue_Object_Mutation_Registry.end(), this); - - if (erase_iter != gEidosValue_Object_Mutation_Registry.end()) - gEidosValue_Object_Mutation_Registry.erase(erase_iter); - else - EIDOS_TERMINATION << "ERROR (EidosValue_Object::~EidosValue_Object): (internal error) unregistered EidosValue_Object of class Mutation." << EidosTerminate(nullptr); - - //std::cout << "popped Mutation EidosValue_Object, count == " << gEidosValue_Object_Mutation_Registry.size() << std::endl; - } -} - -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_vector::PatchPointersByAdding(std::uintptr_t p_pointer_difference) -{ - for (size_t i = 0; i < count_; ++i) - { - std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); - std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; - - values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) - } -} - -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_vector::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) -{ - for (size_t i = 0; i < count_; ++i) + // we want to allow nullptr as a momentary placeholder, although in general a value should exist + // this is a bit gross; I think it is only in EidosInterpreter::Evaluate_For(), which wants to + // set up the loop index variable and *then* put the first value into it; could probably be cleaned up. + if (p_element1) + push_object_element_CRR(p_element1); + else { - std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); - std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; + // this puts nullptr into singleton_value_, but does it following the standard procedure + if (count_ == capacity_) + expand(); - values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) + values_[count_++] = nullptr; } } -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_singleton::PatchPointersByAdding(std::uintptr_t p_pointer_difference) -{ - std::uintptr_t old_element_ptr = reinterpret_cast(value_); - std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; - - value_ = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) -} - -// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments -void EidosValue_Object_singleton::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) -{ - std::uintptr_t old_element_ptr = reinterpret_cast(value_); - std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; - - value_ = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) -} - -void EidosValue_Object::RaiseForClassMismatch(void) const -{ - EIDOS_TERMINATION << "ERROR (EidosValue_Object::RaiseForClassMismatch): the type of an object cannot be changed." << EidosTerminate(nullptr); -} - -const std::string &EidosValue_Object::ElementType(void) const -{ - return Class()->ClassName(); -} - -EidosValue_SP EidosValue_Object::NewMatchingType(void) const -{ - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(Class())); -} - -void EidosValue_Object::Sort(bool p_ascending) -{ -#pragma unused(p_ascending) - EIDOS_TERMINATION << "ERROR (EidosValue_Object::Sort): Sort() is not defined for type object." << EidosTerminate(nullptr); -} - -void EidosValue_Object::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const -{ - EidosObject *value = ObjectElementAtIndex_NOCAST(p_idx, nullptr); - - p_ostream << *value; -} - -nlohmann::json EidosValue_Object::JSONRepresentation(void) const -{ - nlohmann::json json_object = nlohmann::json::array(); // always write as an array, for consistency; makes automated parsing easier - int count = Count(); - - for (int i = 0; i < count; ++i) - json_object.emplace_back(ObjectElementAtIndex_NOCAST(i, nullptr)->JSONRepresentation()); - - return json_object; -} - - -// EidosValue_Object_vector -#pragma mark EidosValue_Object_vector - -EidosValue_Object_vector::EidosValue_Object_vector(const EidosValue_Object_vector &p_original) : EidosValue_Object(false, p_original.Class()) +EidosValue_Object::EidosValue_Object(const EidosValue_Object &p_original) : EidosValue_Object(p_original.Class()) { size_t count = p_original.Count(); EidosObject * const *values = p_original.data(); @@ -2026,7 +1942,7 @@ EidosValue_Object_vector::EidosValue_Object_vector(const EidosValue_Object_vecto } } -EidosValue_Object_vector::EidosValue_Object_vector(const std::vector &p_elementvec, const EidosClass *p_class) : EidosValue_Object(false, p_class) +EidosValue_Object::EidosValue_Object(const std::vector &p_elementvec, const EidosClass *p_class) : EidosValue_Object(p_class) { size_t count = p_elementvec.size(); EidosObject * const *values = p_elementvec.data(); @@ -2045,7 +1961,7 @@ EidosValue_Object_vector::EidosValue_Object_vector(const std::vector p_init_list, const EidosClass *p_class) : EidosValue_Object(false, p_class) +EidosValue_Object::EidosValue_Object(std::initializer_list p_init_list, const EidosClass *p_class) : EidosValue_Object(p_class) { reserve(p_init_list.size()); @@ -2061,7 +1977,7 @@ EidosValue_Object_vector::EidosValue_Object_vector(std::initializer_list(values_[i]); + std::uintptr_t new_element_ptr = old_element_ptr + p_pointer_difference; + + values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) + } +} + +// Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments +void EidosValue_Object::PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) +{ + for (size_t i = 0; i < count_; ++i) + { + std::uintptr_t old_element_ptr = reinterpret_cast(values_[i]); + std::uintptr_t new_element_ptr = old_element_ptr - p_pointer_difference; + + values_[i] = reinterpret_cast(new_element_ptr); // NOLINT(*-no-int-to-ptr) + } +} + +void EidosValue_Object::RaiseForClassMismatch(void) const +{ + EIDOS_TERMINATION << "ERROR (EidosValue_Object::RaiseForClassMismatch): the type of an object cannot be changed." << EidosTerminate(nullptr); +} + +const std::string &EidosValue_Object::ElementType(void) const +{ + return Class()->ClassName(); +} + +EidosValue_SP EidosValue_Object::NewMatchingType(void) const +{ + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(Class())); +} + +void EidosValue_Object::PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const +{ + EidosObject *value = ObjectElementAtIndex_NOCAST(p_idx, nullptr); + + p_ostream << *value; +} + +nlohmann::json EidosValue_Object::JSONRepresentation(void) const +{ + nlohmann::json json_object = nlohmann::json::array(); // always write as an array, for consistency; makes automated parsing easier + int count = Count(); + + for (int i = 0; i < count; ++i) + json_object.emplace_back(ObjectElementAtIndex_NOCAST(i, nullptr)->JSONRepresentation()); + + return json_object; } -EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const +EidosObject *EidosValue_Object::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -EidosObject *EidosValue_Object_vector::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const +EidosObject *EidosValue_Object::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); return values_[p_idx]; } -EidosValue_SP EidosValue_Object_vector::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const +EidosValue_SP EidosValue_Object::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const { if ((p_idx < 0) || (p_idx >= (int)count_)) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(values_[p_idx], Class())); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(values_[p_idx], Class())); } -EidosValue_SP EidosValue_Object_vector::CopyValues(void) const +EidosValue_SP EidosValue_Object::CopyValues(void) const { // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(*this))->CopyDimensionsFromValue(this)); + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(*this))->CopyDimensionsFromValue(this)); } -void EidosValue_Object_vector::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) +EidosValue_SP EidosValue_Object::VectorBasedCopy(void) const +{ + // same as CopyValues() now; slated for removal + return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object(*this))->CopyDimensionsFromValue(this)); +} + +void EidosValue_Object::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) { WILL_MODIFY(this); if (p_source_script_value.Type() == EidosValueType::kValueObject) push_object_element_CRR(p_source_script_value.ObjectElementAtIndex_NOCAST(p_idx, p_blame_token)); else - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::PushValueFromIndexOfEidosValue): type mismatch." << EidosTerminate(p_blame_token); +} + +void EidosValue_Object::Sort(bool p_ascending) +{ +#pragma unused(p_ascending) + EIDOS_TERMINATION << "ERROR (EidosValue_Object::Sort): Sort() is not defined for type object." << EidosTerminate(nullptr); } static bool CompareLogicalObjectSortPairsAscending(std::pair i, std::pair j) { return (i.first < j.first); } @@ -2145,15 +2146,15 @@ static bool CompareFloatObjectSortPairsDescending(std::pair &i, const std::pair &j) { return (i.first < j.first); } static bool CompareStringObjectSortPairsDescending(const std::pair &i, const std::pair &j) { return (i.first > j.first); } -void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_ascending) +void EidosValue_Object::SortBy(const std::string &p_property, bool p_ascending) { WILL_MODIFY(this); // At present this is called only by the sortBy() Eidos function, so we do not need a // blame token; all errors will be attributed to that function automatically. - // length 0 is already sorted - if (count_ == 0) + // length 0 or 1 is already sorted + if (count_ <= 1) return; // figure out what type the property returns @@ -2167,7 +2168,7 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce case EidosValueType::kValueVOID: case EidosValueType::kValueNULL: case EidosValueType::kValueObject: - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " returned " << property_type << "; a property that evaluates to logical, int, float, or string is required." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " returned " << property_type << "; a property that evaluates to logical, int, float, or string is required." << EidosTerminate(nullptr); break; case EidosValueType::kValueLogical: @@ -2181,9 +2182,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->LogicalAtIndex_NOCAST(0, nullptr), value); } @@ -2214,9 +2215,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->IntAtIndex_NOCAST(0, nullptr), value); } @@ -2247,9 +2248,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->FloatAtIndex_NOCAST(0, nullptr), value); } @@ -2280,9 +2281,9 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce EidosValue_SP temp_result = value->GetProperty(property_string_id); if (temp_result->Count() != 1) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " produced " << temp_result->Count() << " values for a single element; a property that produces one value per element is required for sorting." << EidosTerminate(nullptr); if (temp_result->Type() != property_type) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SortBy): sorting property " << p_property << " did not produce a consistent result type; a single type is required for a sorting key." << EidosTerminate(nullptr); sortable_pairs.emplace_back(temp_result->StringAtIndex_NOCAST(0, nullptr), value); } @@ -2304,13 +2305,13 @@ void EidosValue_Object_vector::SortBy(const std::string &p_property, bool p_asce } } -EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringID p_property_id) const +EidosValue_SP EidosValue_Object::GetPropertyOfElements(EidosGlobalStringID p_property_id) const { size_t values_size = count_; const EidosPropertySignature *signature = class_->SignatureForProperty(p_property_id); if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(nullptr); if (values_size == 0) { @@ -2333,18 +2334,16 @@ EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringI const EidosClass *value_class = signature->value_class_; if (value_class) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(value_class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(value_class)); else return gStaticEidosValue_Object_ZeroVec; } - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " does not specify an unambiguous value type, and thus cannot be accessed on a zero-length vector." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " does not specify an unambiguous value type, and thus cannot be accessed on a zero-length vector." << EidosTerminate(nullptr); } else if (values_size == 1) { - // the singleton case is very common, so it should be special-cased for speed - // accelerated property is not used for singletons because we want to generate a singleton-class result - // of course the accelerated getters could be smart enough to do that, but that makes them more complex; not a clear win + // The singleton case is very common, so it should be special-cased for speed EidosObject *value = values_[0]; EidosValue_SP result = value->GetProperty(p_property_id); @@ -2361,6 +2360,7 @@ EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringI else if (signature->accelerated_get_) { // Accelerated property access is enabled for this property, so the class will do all the work for us + // We put this case below the (values_size == 1) case so the accelerated getter can focus on the vectorized case EidosValue_SP result = EidosValue_SP(signature->accelerated_getter(values_, values_size)); // Access of singleton properties retains the matrix/array structure of the target @@ -2428,14 +2428,14 @@ EidosValue_SP EidosValue_Object_vector::GetPropertyOfElements(EidosGlobalStringI } } -void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) +void EidosValue_Object::SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) { const EidosPropertySignature *signature = Class()->SignatureForProperty(p_property_id); // BCH 9 Sept. 2022: if the property does not exist, raise an error on the token for the property name. // Note that other errors stemming from this call will refer to whatever the current error range is. if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); signature->CheckAssignedValue(p_value); // will raise if the type being assigned in is not an exact match @@ -2446,6 +2446,7 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope if (p_value_count == 1) { // we have a multiplex assignment of one value to (maybe) more than one element: x.foo = 10 + // Here (unlike the accelerated getter), the accelerated version is probably a win so we always use it if (signature->accelerated_set_) { // Accelerated property writing is enabled for this property, so we call the setter directly @@ -2479,10 +2480,10 @@ void EidosValue_Object_vector::SetPropertyOfElements(EidosGlobalStringID p_prope } } else - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::SetPropertyOfElements): assignment to a property requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::SetPropertyOfElements): assignment to a property requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); } -EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) +EidosValue_SP EidosValue_Object::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) { // This is an instance method, so it gets dispatched to all of our elements auto values_size = count_; @@ -2508,12 +2509,12 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ const EidosClass *return_class = p_method_signature->return_class_; if (return_class) - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(return_class)); + return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(return_class)); else return gStaticEidosValue_Object_ZeroVec; } - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::ExecuteMethodCall): method " << EidosStringRegistry::StringForGlobalStringID(p_method_id) << " does not specify an unambiguous return type, and thus cannot be called on a zero-length vector." << EidosTerminate(nullptr); + EIDOS_TERMINATION << "ERROR (EidosValue_Object::ExecuteMethodCall): method " << EidosStringRegistry::StringForGlobalStringID(p_method_id) << " does not specify an unambiguous return type, and thus cannot be called on a zero-length vector." << EidosTerminate(nullptr); } else if (p_method_signature->accelerated_imp_) { @@ -2729,7 +2730,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ else if (sig_mask == kEidosValueMaskObject && p_method_signature->return_class_) { const EidosClass *return_class = p_method_signature->return_class_; - EidosValue_Object_vector *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(return_class); + EidosValue_Object *object_result = new (gEidosValuePool->AllocateChunk()) EidosValue_Object(return_class); if (return_is_singleton) { @@ -2810,7 +2811,7 @@ EidosValue_SP EidosValue_Object_vector::ExecuteMethodCall(EidosGlobalStringID p_ } } -void EidosValue_Object_vector::clear(void) +void EidosValue_Object::clear(void) { WILL_MODIFY(this); @@ -2828,15 +2829,29 @@ void EidosValue_Object_vector::clear(void) count_ = 0; } -EidosValue_Object_vector *EidosValue_Object_vector::reserve(size_t p_reserved_size) +EidosValue_Object *EidosValue_Object::reserve(size_t p_reserved_size) { WILL_MODIFY(this); if (p_reserved_size > capacity_) { - values_ = (EidosObject **)realloc(values_, p_reserved_size * sizeof(EidosObject *)); - if (!values_) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_vector::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + // this is a reservation for an explicit size, so we give that size exactly, to avoid wasting space + + if (values_ == &singleton_value_) + { + values_ = (EidosObject **)malloc(p_reserved_size * sizeof(EidosObject *)); + + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Object::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + + values_[0] = singleton_value_; + } + else + { + values_ = (EidosObject **)realloc(values_, p_reserved_size * sizeof(EidosObject *)); + if (!values_) + EIDOS_TERMINATION << "ERROR (EidosValue_Object::reserve): allocation failed; you may need to raise the memory limit for SLiM." << EidosTerminate(nullptr); + } capacity_ = p_reserved_size; } @@ -2844,7 +2859,7 @@ EidosValue_Object_vector *EidosValue_Object_vector::reserve(size_t p_reserved_si return this; } -EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize(size_t p_new_size) +EidosValue_Object *EidosValue_Object::resize_no_initialize(size_t p_new_size) { WILL_MODIFY(this); @@ -2877,7 +2892,7 @@ EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize(size_t return this; } -EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize_RR(size_t p_new_size) +EidosValue_Object *EidosValue_Object::resize_no_initialize_RR(size_t p_new_size) { WILL_MODIFY(this); @@ -2888,7 +2903,7 @@ EidosValue_Object_vector *EidosValue_Object_vector::resize_no_initialize_RR(size return this; } -void EidosValue_Object_vector::expand(void) +void EidosValue_Object::expand(void) { WILL_MODIFY(this); @@ -2898,7 +2913,7 @@ void EidosValue_Object_vector::expand(void) reserve(capacity_ << 1); } -void EidosValue_Object_vector::erase_index(size_t p_index) +void EidosValue_Object::erase_index(size_t p_index) { WILL_MODIFY(this); @@ -2925,157 +2940,6 @@ void EidosValue_Object_vector::erase_index(size_t p_index) } -// EidosValue_Object_singleton -#pragma mark EidosValue_Object_singleton - -EidosValue_Object_singleton::EidosValue_Object_singleton(EidosObject *p_element1, const EidosClass *p_class) : EidosValue_Object(true, p_class), value_(p_element1) -{ - // we want to allow nullptr as a momentary placeholder, although in general a value should exist - if (p_element1) - { - DeclareClassFromElement(p_element1); - - if (class_uses_retain_release_) - static_cast(p_element1)->Retain(); // unsafe cast to avoid virtual function overhead - } -} - -EidosValue_Object_singleton::~EidosValue_Object_singleton(void) -{ - if (class_uses_retain_release_) - if (value_) - static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead -} - -EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex_NOCAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -EidosObject *EidosValue_Object_singleton::ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::ObjectElementAtIndex_CAST): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return value_; -} - -EidosValue_SP EidosValue_Object_singleton::GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const -{ - if (p_idx != 0) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::GetValueAtIndex): subscript " << p_idx << " out of range." << EidosTerminate(p_blame_token); - - return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(value_, Class())); -} - -void EidosValue_Object_singleton::SetValue(EidosObject *p_element) -{ - WILL_MODIFY(this); - - DeclareClassFromElement(p_element); - - if (class_uses_retain_release_) - { - static_cast(p_element)->Retain(); // unsafe cast to avoid virtual function overhead - - // we might have been initialized with nullptr with the aim of setting a value here - if (value_) - static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead - } - - value_ = p_element; -} - -EidosValue_SP EidosValue_Object_singleton::CopyValues(void) const -{ - // note that constness, invisibility, etc. do not get copied - return EidosValue_SP((new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(value_, Class()))->CopyDimensionsFromValue(this)); -} - -EidosValue_SP EidosValue_Object_singleton::VectorBasedCopy(void) const -{ - // We intentionally don't reserve a size of 1 here, on the assumption that further values are likely to be added - // note that constness, invisibility, etc. do not get copied - EidosValue_Object_vector_SP new_vec = EidosValue_Object_vector_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_vector(Class())); - - new_vec->push_object_element_CRR(value_); - new_vec->CopyDimensionsFromValue(this); - - return new_vec; -} - -void EidosValue_Object_singleton::PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) -{ -#pragma unused(p_idx, p_source_script_value) - WILL_MODIFY(this); - - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::PushValueFromIndexOfEidosValue): (internal error) EidosValue_Object_singleton is not modifiable." << EidosTerminate(p_blame_token); -} - -EidosValue_SP EidosValue_Object_singleton::GetPropertyOfElements(EidosGlobalStringID p_property_id) const -{ - const EidosPropertySignature *signature = value_->Class()->SignatureForProperty(p_property_id); - - if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::GetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(nullptr); - - EidosValue_SP result = value_->GetProperty(p_property_id); - - // Access of singleton properties retains the matrix/array structure of the target - if (signature->value_mask_ & kEidosValueMaskSingleton) - result->CopyDimensionsFromValue(this); - -#if DEBUG - // This is time-consuming, and will fail only due to internal bugs, so we should do it only in DEBUG - signature->CheckResultValue(*result); -#endif - - return result; -} - -void EidosValue_Object_singleton::SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) -{ - const EidosPropertySignature *signature = value_->Class()->SignatureForProperty(p_property_id); - - // BCH 9 Sept. 2022: if the property does not exist, raise an error on the token for the property name. - // Note that other errors stemming from this call will refer to whatever the current error range is. - if (!signature) - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::SetPropertyOfElements): property " << EidosStringRegistry::StringForGlobalStringID(p_property_id) << " is not defined for object element type " << ElementType() << "." << EidosTerminate(p_property_token); - - signature->CheckAssignedValue(p_value); // will raise if the type being assigned in is not an exact match - - // We have to check the count ourselves; the signature does not do that for us - if (p_value.Count() == 1) - { - value_->SetProperty(p_property_id, p_value); - } - else - EIDOS_TERMINATION << "ERROR (EidosValue_Object_singleton::SetPropertyOfElements): assignment to a property requires an rvalue that is a singleton (multiplex assignment) or that has a .size() matching the .size of the lvalue." << EidosTerminate(nullptr); -} - -EidosValue_SP EidosValue_Object_singleton::ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_method_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) -{ - // This is an instance method, so it gets dispatched to our element - if (p_method_signature->accelerated_imp_) - { - // the method is accelerated, so call through its accelerated imp - EidosValue_SP result = p_method_signature->accelerated_imper_(&value_, 1, p_method_id, p_arguments, p_interpreter); - - p_method_signature->CheckReturn(*result); - return result; - } - else - { - // not accelerated, so ExecuteInstanceMethod() handles it - EidosValue_SP result = value_->ExecuteInstanceMethod(p_method_id, p_arguments, p_interpreter); - - p_method_signature->CheckReturn(*result); - return result; - } -} diff --git a/eidos/eidos_value.h b/eidos/eidos_value.h index faa6772e..4ddd3638 100644 --- a/eidos/eidos_value.h +++ b/eidos/eidos_value.h @@ -184,6 +184,7 @@ class EidosValue unsigned int invisible_ : 1; // as in R; if true, the value will not normally be printed to the console unsigned int is_singleton_ : 1; // allows Count() and IsSingleton() to be inline; cached at construction unsigned int registered_for_patching_ : 1; // used by EidosValue_Object, otherwise UNINITIALIZED; declared here for reasons of memory packing + unsigned int class_uses_retain_release_ : 1; // used by EidosValue_Object, otherwise UNINITIALIZED; cached from UsesRetainRelease() of class_; true until class_ is set int64_t *dim_; // nullptr for vectors; points to a malloced, OWNED array of dimensions for matrices and arrays // when allocated, the first value in the buffer is a count of the dimensions that follow @@ -460,7 +461,7 @@ class EidosValue_NULL final : public EidosValue // those should be used for singleton values when possible. // -class EidosValue_Logical : public EidosValue +class EidosValue_Logical final : public EidosValue { private: typedef EidosValue super; @@ -682,7 +683,7 @@ class EidosValue_String_singleton final : public EidosValue_String // EidosValue_Int represents integer (C++ int64_t) values in Eidos. // -class EidosValue_Int : public EidosValue +class EidosValue_Int final : public EidosValue { private: typedef EidosValue super; @@ -793,7 +794,7 @@ class EidosValue_Int : public EidosValue // EidosValue_Float represents floating-point (C++ double) values in Eidos. // -class EidosValue_Float : public EidosValue +class EidosValue_Float final : public EidosValue { private: typedef EidosValue super; @@ -900,8 +901,7 @@ class EidosValue_Float : public EidosValue // ********************************************************************************************************* // // EidosValue_Object represents objects in Eidos: entities that have properties and can respond to -// methods. The subclass EidosValue_Object_vector is the standard instance class, used to hold vectors -// of objects. EidosValue_Object_singleton is used for speed, to represent single values. +// methods. The value type for it is EidosObject (or a subclass thereof). // // EidosObject supports a retain/release mechanism that disposes of objects when no longer @@ -912,24 +912,25 @@ class EidosValue_Float : public EidosValue // script. Note that if you inherit from EidosDictionaryRetained you *must* subclass from // EidosDictionaryRetained_Class, and vice versa; each is considered a guarantee of the other. -class EidosValue_Object : public EidosValue +class EidosValue_Object final : public EidosValue { private: typedef EidosValue super; protected: - const EidosClass *class_; // can be gEidosObject_Class if the vector is empty - bool class_uses_retain_release_; // cached from UsesRetainRelease() of class_; true until class_ is set, to catch errors + // singleton/vector design: values_ will either point to singleton_value_, or to a malloced buffer; it will never be nullptr + // in the case of a zero-length vector, note that values_ will point to singleton_value_ with count_ == 0 but capacity_ == 1 + EidosObject *singleton_value_; + EidosObject **values_; // these may use a retain/release system of ownership; see below + size_t count_, capacity_; - EidosValue_Object(bool p_singleton, const EidosClass *p_class); + const EidosClass *class_; // can be gEidosObject_Class if the vector is empty - virtual int Count_Virtual(void) const override = 0; + // declared by EidosValue for our benefit, to pack bytes + //unsigned int registered_for_patching_ : 1; // for mutation pointer patching; see EidosValue_Object::EidosValue_Object() + //unsigned int class_uses_retain_release_ : 1; // cached from UsesRetainRelease() of class_; true until class_ is set -public: - EidosValue_Object(const EidosValue_Object &p_original) = delete; // no copy-construct - EidosValue_Object(void) = delete; // no default constructor - EidosValue_Object& operator=(const EidosValue_Object&) = delete; // no copying - virtual ~EidosValue_Object(void) override; + virtual int Count_Virtual(void) const override { return (int)count_; } // check the type of a new element being added to an EidosValue_Object, and update class_uses_retain_release_ inline __attribute__((always_inline)) void DeclareClassFromElement(const EidosObject *p_element, bool p_undeclared_is_error = false) @@ -952,85 +953,57 @@ class EidosValue_Object : public EidosValue } } void RaiseForClassMismatch(void) const; - - virtual const std::string &ElementType(void) const override; - inline __attribute__((always_inline)) const EidosClass *Class(void) const { return class_; } - inline __attribute__((always_inline)) bool UsesRetainRelease(void) const { return class_uses_retain_release_; } - virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; - virtual nlohmann::json JSONRepresentation(void) const override; - - virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override = 0; - virtual EidosValue_SP CopyValues(void) const override = 0; - virtual EidosValue_SP NewMatchingType(void) const override; - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override = 0; - virtual void Sort(bool p_ascending) override; - - // Property and method support; defined only on EidosValue_Object, not EidosValue. The methods that a - // EidosValue_Object instance defines depend upon the type of the EidosObject objects it contains. - virtual EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const = 0; - virtual void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) = 0; + // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments + void PatchPointersByAdding(std::uintptr_t p_pointer_difference); + void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference); - virtual EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) = 0; +public: + EidosValue_Object(void) = delete; // no default constructor + EidosValue_Object& operator=(const EidosValue_Object&) = delete; // no copying + explicit EidosValue_Object(const EidosClass *p_class); // funnel initializer; allows gEidosObject_Class - // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments - virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) = 0; - virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) = 0; -}; - -class EidosValue_Object_vector final : public EidosValue_Object -{ -private: - typedef EidosValue_Object super; - -protected: - EidosObject **values_ = nullptr; // these may use a retain/release system of ownership; see below - size_t count_ = 0, capacity_ = 0; + explicit EidosValue_Object(EidosObject *p_element1, const EidosClass *p_class); + explicit EidosValue_Object(const EidosValue_Object &p_original); + explicit EidosValue_Object(const std::vector &p_elementvec, const EidosClass *p_class); + explicit EidosValue_Object(std::initializer_list p_init_list, const EidosClass *p_class); + explicit EidosValue_Object(EidosObject **p_values, size_t p_count, const EidosClass *p_class); + virtual ~EidosValue_Object(void) override; - virtual int Count_Virtual(void) const override { return (int)count_; } + virtual EidosObject * const *ObjectData(void) const override { return values_; } + virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return values_; } -public: - EidosValue_Object_vector(const EidosValue_Object_vector &p_original); // can copy-construct - EidosValue_Object_vector& operator=(const EidosValue_Object_vector&) = delete; // no copying + inline __attribute__((always_inline)) const EidosClass *Class(void) const { return class_; } + inline __attribute__((always_inline)) bool UsesRetainRelease(void) const { return class_uses_retain_release_; } - explicit inline EidosValue_Object_vector(const EidosClass *p_class) : EidosValue_Object(false, p_class) { } // can be gEidosObject_Class - explicit EidosValue_Object_vector(const std::vector &p_elementvec, const EidosClass *p_class); - //explicit EidosValue_Object_vector(EidosObject *p_element1); // disabled to encourage use of EidosValue_Object_singleton for this case - explicit EidosValue_Object_vector(std::initializer_list p_init_list, const EidosClass *p_class); - explicit EidosValue_Object_vector(EidosObject **p_values, size_t p_count, const EidosClass *p_class); - virtual ~EidosValue_Object_vector(void) override; + virtual const std::string &ElementType(void) const override; + virtual EidosValue_SP NewMatchingType(void) const override; + virtual void PrintValueAtIndex(const int p_idx, std::ostream &p_ostream) const override; + virtual nlohmann::json JSONRepresentation(void) const override; virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosObject * const *ObjectData(void) const override { return values_; } - virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return values_; } - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; + virtual EidosValue_SP VectorBasedCopy(void) const override; virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; + virtual void Sort(bool p_ascending) override; void SortBy(const std::string &p_property, bool p_ascending); // Property and method support; defined only on EidosValue_Object, not EidosValue. The methods that a // EidosValue_Object instance defines depend upon the type of the EidosObject objects it contains. - virtual EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const override; - virtual void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) override; + EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const; + void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token); - virtual EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) override; - - // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments - virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) override; - virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) override; + EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter); - // vector lookalike methods; not virtual, only for clients with a EidosValue_Object_vector* + // vector lookalike methods for speed; not virtual, only for clients with a EidosValue_Object* void clear(void); // as in std::vector - EidosValue_Object_vector *reserve(size_t p_reserved_size); // as in std::vector - EidosValue_Object_vector *resize_no_initialize(size_t p_new_size); // does not zero-initialize, unlike std::vector! - EidosValue_Object_vector *resize_no_initialize_RR(size_t p_new_size); // doesn't zero-initialize even for the RR case (set_object_element_no_check_RR may not be used, use set_object_element_no_check_no_previous_RR) + EidosValue_Object *reserve(size_t p_reserved_size); // as in std::vector + EidosValue_Object *resize_no_initialize(size_t p_new_size); // does not zero-initialize, unlike std::vector! + EidosValue_Object *resize_no_initialize_RR(size_t p_new_size); // doesn't zero-initialize even for the RR case (set_object_element_no_check_RR may not be used, use set_object_element_no_check_no_previous_RR) void expand(void); // expand to fit (at least) one new value void erase_index(size_t p_index); // a weak substitute for erase() @@ -1055,9 +1028,11 @@ class EidosValue_Object_vector final : public EidosValue_Object void set_object_element_no_check_RR(EidosObject *p_object, size_t p_index); // specifies retain/release void set_object_element_no_check_no_previous_RR(EidosObject *p_object, size_t p_index); // specifies retain/release, previous value assumed invalid from resize_no_initialize_RR void set_object_element_no_check_NORR(EidosObject *p_object, size_t p_index); // specifies no retain/release + + friend void SLiM_IncreaseMutationBlockCapacity(void); // for PatchPointersByAdding() / PatchPointersBySubtracting() }; -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_CRR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_CRR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1072,7 +1047,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_RR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_RR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1091,7 +1066,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_NORR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_NORR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1108,7 +1083,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_capcheck_NORR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_capcheck_NORR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1124,7 +1099,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_CRR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_CRR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1140,7 +1115,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_RR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_RR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1156,7 +1131,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_NORR(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_NORR(EidosObject *p_object) { WILL_MODIFY(this); @@ -1170,7 +1145,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object_element_no_check_already_retained(EidosObject *p_object) +inline __attribute__((always_inline)) void EidosValue_Object::push_object_element_no_check_already_retained(EidosObject *p_object) { WILL_MODIFY(this); @@ -1184,7 +1159,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::push_object values_[count_++] = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1205,7 +1180,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_RR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_RR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1224,7 +1199,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_no_previous_RR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_no_previous_RR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1241,7 +1216,7 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_element_no_check_NORR(EidosObject *p_object, size_t p_index) +inline __attribute__((always_inline)) void EidosValue_Object::set_object_element_no_check_NORR(EidosObject *p_object, size_t p_index) { WILL_MODIFY(this); @@ -1256,74 +1231,6 @@ inline __attribute__((always_inline)) void EidosValue_Object_vector::set_object_ value_slot_to_replace = p_object; } -class EidosValue_Object_singleton final : public EidosValue_Object -{ -private: - typedef EidosValue_Object super; - -protected: - EidosObject *value_; // these may use a retain/release system of ownership; see below - - virtual int Count_Virtual(void) const override { return 1; } - -public: - EidosValue_Object_singleton(const EidosValue_Object_singleton &p_original) = delete; // no copy-construct - EidosValue_Object_singleton& operator=(const EidosValue_Object_singleton&) = delete; // no copying - EidosValue_Object_singleton(void) = delete; - explicit EidosValue_Object_singleton(EidosObject *p_element1, const EidosClass *p_class); - explicit EidosValue_Object_singleton(EidosObject *p_element1, const EidosClass *p_class, bool p_register_for_patching); // a variant for self-pointer EidosValues; not for general use - virtual ~EidosValue_Object_singleton(void) override; - - virtual EidosObject *ObjectElementAtIndex_NOCAST(int p_idx, const EidosToken *p_blame_token) const override; - - virtual EidosObject *ObjectElementAtIndex_CAST(int p_idx, const EidosToken *p_blame_token) const override; - - virtual EidosObject * const *ObjectData(void) const override { return &value_; } - virtual EidosObject **ObjectData_Mutable(void) override { WILL_MODIFY(this); return &value_; } // very dangerous; do not use - void SetValue(EidosObject *p_element); // very dangerous; used only in Evaluate_For() - - virtual EidosValue_SP GetValueAtIndex(const int p_idx, const EidosToken *p_blame_token) const override; - virtual EidosValue_SP CopyValues(void) const override; - - virtual EidosValue_SP VectorBasedCopy(void) const override; - - // prohibited actions because there is no backing vector - virtual void PushValueFromIndexOfEidosValue(int p_idx, const EidosValue &p_source_script_value, const EidosToken *p_blame_token) override; - - // Property and method support; defined only on EidosValue_Object, not EidosValue. The methods that a - // EidosValue_Object instance defines depend upon the type of the EidosObject objects it contains. - virtual EidosValue_SP GetPropertyOfElements(EidosGlobalStringID p_property_id) const override; - virtual void SetPropertyOfElements(EidosGlobalStringID p_property_id, const EidosValue &p_value, EidosToken *p_property_token) override; - - virtual EidosValue_SP ExecuteMethodCall(EidosGlobalStringID p_method_id, const EidosInstanceMethodSignature *p_call_signature, const std::vector &p_arguments, EidosInterpreter &p_interpreter) override; - - // Provided to SLiM for the Mutation-pointer hack; see EidosValue_Object::EidosValue_Object() for comments - virtual void PatchPointersByAdding(std::uintptr_t p_pointer_difference) override; - virtual void PatchPointersBySubtracting(std::uintptr_t p_pointer_difference) override; - - // We support just this method, from EidosValue_Object_vector's suite of setters, for now - void set_object_element_no_check_CRR(EidosObject *p_object, size_t p_index); // checks for retain/release -}; - -inline __attribute__((always_inline)) void EidosValue_Object_singleton::set_object_element_no_check_CRR(EidosObject *p_object, __attribute__((unused)) size_t p_index) -{ - WILL_MODIFY(this); - -#if DEBUG - // do checks only in DEBUG mode, for speed; the user should never be able to trigger these errors - if (p_index >= 1) RaiseForRangeViolation(); - DeclareClassFromElement(p_object, true); // require a prior matching declaration -#endif - if (class_uses_retain_release_) - { - static_cast(p_object)->Retain(); // unsafe cast to avoid virtual function overhead - if (value_) - static_cast(value_)->Release(); // unsafe cast to avoid virtual function overhead - } - - value_ = p_object; -} - #endif /* defined(__Eidos__eidos_value__) */