Skip to content

Commit

Permalink
Merge pull request #421 from MesserLab/eidosvalue_overhaul
Browse files Browse the repository at this point in the history
EidosValue design overhaul
  • Loading branch information
bhaller authored Dec 23, 2023
2 parents b7dcd6a + ce167dd commit d7f422d
Show file tree
Hide file tree
Showing 63 changed files with 4,488 additions and 5,359 deletions.
2 changes: 1 addition & 1 deletion QtSLiM/QtSLiMVariableBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void QtSLiMVariableBrowser::itemExpanded(QTreeWidgetItem *item)
// we used to display zero-length property values for zero-length object vectors, but don't any more
int display_index = (element_index != -1) ? element_index : 0;
EidosValue_Object *eidos_object_vector = static_cast<EidosValue_Object *>(eidos_value);
EidosObject *eidos_object = eidos_object_vector->ObjectElementAtIndex(display_index, nullptr);
EidosObject *eidos_object = eidos_object_vector->ObjectElementAtIndex_NOCAST(display_index, nullptr);
const EidosClass *object_class = eidos_object->Class();
const std::vector<EidosPropertySignature_CSP> *properties = object_class->Properties();
size_t propertyCount = properties->size();
Expand Down
6 changes: 3 additions & 3 deletions QtSLiM/QtSLiM_SLiMgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
SLiMgui::SLiMgui(Community &p_community, QtSLiMWindow *p_controller) :
community_(p_community),
controller_(p_controller),
self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMgui_Class)))
self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMgui_Class)))
{
}

Expand Down Expand Up @@ -73,7 +73,7 @@ EidosValue_SP SLiMgui::GetProperty(EidosGlobalStringID p_property_id)
// constants
case gID_pid:
{
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(getpid()));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(getpid()));
}

// variables
Expand Down Expand Up @@ -113,7 +113,7 @@ EidosValue_SP SLiMgui::ExecuteMethod_openDocument(EidosGlobalStringID p_method_i
#pragma unused (p_method_id, p_arguments, p_interpreter)

EidosValue *filePath_value = p_arguments[0].get();
std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex(0, nullptr)));
std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringAtIndex_NOCAST(0, nullptr)));
QString filePath = QString::fromStdString(file_path);

controller_->eidos_openDocument(filePath);
Expand Down
6 changes: 3 additions & 3 deletions SLiMgui/slim_gui.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
SLiMgui::SLiMgui(Community &p_community, SLiMWindowController *p_controller) :
community_(p_community),
controller_(p_controller),
self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object_singleton(this, gSLiM_SLiMgui_Class)))
self_symbol_(gID_slimgui, EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Object(this, gSLiM_SLiMgui_Class)))
{
}

Expand Down Expand Up @@ -69,7 +69,7 @@
// constants
case gID_pid:
{
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(getpid()));
return EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int(getpid()));
}

// variables
Expand Down Expand Up @@ -109,7 +109,7 @@
#pragma unused (p_method_id, p_arguments, p_interpreter)

EidosValue_String *filePath_value = (EidosValue_String *)p_arguments[0].get();
std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringRefAtIndex(0, nullptr)));
std::string file_path = Eidos_ResolvedPath(Eidos_StripTrailingSlash(filePath_value->StringRefAtIndex_NOCAST(0, nullptr)));
NSString *filePath = [NSString stringWithUTF8String:file_path.c_str()];

[controller_ eidos_openDocument:filePath];
Expand Down
4 changes: 3 additions & 1 deletion VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Note that not every commit will be logged here; that is what the Github commit h

development head (in the master branch):
fix for #418, a crash involving null genomes in nonWF (has_null_genomes_ was not set correctly by addCloned() or takeMigrants() when putting a null genome into a subpop that previously had none)

policy change: float indices are no longer legal for subsetting, indices must be integer (or a logical vector, as usual); this was inherited from R and is a bad idea for Eidos
policy change: assignment into object properties must match the type of the property; no more promotion to integer/float from lower types


version 4.1 (Eidos version 3.1):
fix a minor bug with autofix when opening multiple .slim documents at once in SLiMgui
Expand Down
163 changes: 81 additions & 82 deletions core/chromosome.cpp

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions core/community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ 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();

// BCH 3/16/2022: We used to allocate the Species object here, as the first thing we did. In SLiM 4 there can
// be multiple species and they can have names other than "sim", so we delay species creation until parse time.

Expand Down Expand Up @@ -1324,9 +1327,9 @@ Species *Community::SpeciesForIndividuals(EidosValue *value)
EIDOS_TERMINATION << "ERROR (Community::SpeciesForIndividuals): (internal error) value is not of class Individual." << EidosTerminate();

if (value_count == 1)
return &((Individual *)object_value->ObjectElementAtIndex(0, nullptr))->subpopulation_->species_;
return &((Individual *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->subpopulation_->species_;

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

return Community::SpeciesForIndividualsVector(individuals, value_count);
Expand Down Expand Up @@ -1369,9 +1372,9 @@ Species *Community::SpeciesForGenomes(EidosValue *value)
EIDOS_TERMINATION << "ERROR (Community::SpeciesForGenomes): (internal error) value is not of class Genome." << EidosTerminate();

if (value_count == 1)
return &((Genome *)object_value->ObjectElementAtIndex(0, nullptr))->OwningIndividual()->subpopulation_->species_;
return &((Genome *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->OwningIndividual()->subpopulation_->species_;

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

return Community::SpeciesForGenomesVector(genomes, value_count);
Expand Down Expand Up @@ -1414,9 +1417,9 @@ Species *Community::SpeciesForMutations(EidosValue *value)
EIDOS_TERMINATION << "ERROR (Community::SpeciesForMutations): (internal error) value is not of class Mutation." << EidosTerminate();

if (value_count == 1)
return &((Mutation *)object_value->ObjectElementAtIndex(0, nullptr))->mutation_type_ptr_->species_;
return &((Mutation *)object_value->ObjectElementAtIndex_NOCAST(0, nullptr))->mutation_type_ptr_->species_;

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

return Community::SpeciesForMutationsVector(mutations, value_count);
Expand Down
Loading

0 comments on commit d7f422d

Please sign in to comment.