Skip to content

Commit

Permalink
fix issues with using the Dictionary class in method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Jan 17, 2025
1 parent e814477 commit b0a0e53
Show file tree
Hide file tree
Showing 45 changed files with 207 additions and 201 deletions.
2 changes: 1 addition & 1 deletion EidosScribe/EidosCocoaExtra.mm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ + (NSAttributedString *)eidosAttributedStringForCallSignature:(const EidosCallSi

if (arg_obj_class && (stripped_mask & kEidosValueMaskObject))
{
const std::string &obj_type_name = arg_obj_class->ClassName();
const std::string &obj_type_name = arg_obj_class->ClassNameForDisplay();
NSString *objTypeName = [NSString stringWithUTF8String:obj_type_name.c_str()];

[attrStr appendAttributedString:[[[NSAttributedString alloc] initWithString:@"<" attributes:typeAttrs] autorelease]];
Expand Down
10 changes: 5 additions & 5 deletions EidosScribe/EidosHelpClasses.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
\f4\fs20 .\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0

\f3\fs18 \cf2 \'96\'a0(void)cbind(object\'a0source, ...)\
\f3\fs18 \cf2 \'96\'a0(void)cbind(object<Dictionary>\'a0source, ...)\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f4\fs20 \cf2 Adds all of the columns contained by
Expand Down Expand Up @@ -255,7 +255,7 @@ This method is similar to the
\f4\fs20 , which may be used instead if replacement of duplicate columns is desired.\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0

\f3\fs18 \cf2 \'96\'a0(void)rbind(object\'a0source, ...)\
\f3\fs18 \cf2 \'96\'a0(void)rbind(object<Dictionary>\'a0source, ...)\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f4\fs20 \cf2 Appends all of the columns contained by
Expand Down Expand Up @@ -624,7 +624,7 @@ A final alternative is to call
\f1\fs22 methods\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0
\f3\i0\fs18 \cf2 \'96\'a0(void)addKeysAndValuesFrom(object$\'a0source)\
\f3\i0\fs18 \cf2 \'96\'a0(void)addKeysAndValuesFrom(object<Dictionary>$\'a0source)\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f4\fs20 \cf2 Adds all of the key-value pairs contained by
Expand All @@ -644,7 +644,7 @@ A final alternative is to call
\f4\fs20 ).\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0

\f3\fs18 \cf2 \'96\'a0(void)appendKeysAndValuesFrom(object\'a0source)\
\f3\fs18 \cf2 \'96\'a0(void)appendKeysAndValuesFrom(object<Dictionary>\'a0source)\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f4\fs20 \cf2 Appends all of the key-value pairs contained by
Expand Down Expand Up @@ -884,7 +884,7 @@ If the values of
\f4\fs20 if no value has been set.\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0

\f3\fs18 \cf2 \'96\'a0(logical$)identicalContents(object$\'a0x)\
\f3\fs18 \cf2 \'96\'a0(logical$)identicalContents(object<Dictionary>$\'a0x)\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f4\fs20 \cf2 Returns
Expand Down
8 changes: 4 additions & 4 deletions EidosScribe/EidosHelpController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ - (instancetype)init
{
const std::string &element_type = class_object->ClassName();

if (!Eidos_string_hasPrefix(element_type, "_") && (element_type != "DictionaryBase")) // internal classes are undocumented
if (!Eidos_string_hasPrefix(element_type, "_") && (element_type != "DictionaryRetained")) // internal classes are undocumented
[self checkDocumentationOfClass:class_object];
}

Expand Down Expand Up @@ -611,9 +611,9 @@ - (void)checkDocumentationOfClass:(EidosClass *)classObject
{
const EidosClass *superclass = classObject->Superclass();

// We're hiding DictionaryBase, where the Dictionary stuff is actually defined, so we have Dictionary pretend that its superclass is Object, so the Dictionary stuff gets checked
if (classObject == gEidosDictionaryRetained_Class)
superclass = gEidosObject_Class;
// We're hiding DictionaryRetained, so DictionaryRetained subclasses pretend their superclass is Dictionary
if (superclass == gEidosDictionaryRetained_Class)
superclass = gEidosDictionaryUnretained_Class;

const std::string &className = classObject->ClassName();
NSString *classString = [NSString stringWithUTF8String:className.c_str()];
Expand Down
9 changes: 5 additions & 4 deletions EidosScribe/EidosHelpFunctions.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -5137,7 +5137,6 @@ See
\f3\fs20 will be returned; if not,
\f1\fs18 F
\f3\fs20 will be returned (but at present, an error will result instead).\cf0 \
\pard\pardeftab543\li547\ri720\sb60\sa60\partightenfactor0
\cf2 If
\f1\fs18 compress
\f3\fs20 is
Expand Down Expand Up @@ -5255,6 +5254,7 @@ If
\f3\b0 In SLiM 3.5 and later, use
\f1\fs18 colors(n, "cm")
\f3\fs20 instead.\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0
\cf5 Generate colors in a \'93cyan-magenta\'94 color palette.\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0

Expand Down Expand Up @@ -5368,6 +5368,7 @@ This function can also be called with a non-singleton vector of color strings in
\f3\b0 In SLiM 3.5 and later, use
\f1\fs18 colors(n, "heat")
\f3\fs20 instead.\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0
\cf5 Generate colors in a \'93heat map\'94 color palette.\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0

Expand Down Expand Up @@ -5490,6 +5491,7 @@ This function can also be called with a matrix of RGB values, with three columns
\f3\b0 In SLiM 3.5 and later, use
\f1\fs18 colors(n, "terrain")
\f3\fs20 instead.\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0
\cf5 Generate colors in a \'93terrain\'94 color palette.\
\pard\pardeftab397\ri720\sb360\sa60\partightenfactor0

Expand Down Expand Up @@ -6007,7 +6009,7 @@ Note that the number of threads requested here overrides any per-task request se
\f3\fs20 . Also, if the task size is below a certain task-specific threshold the task will not be executed in parallel regardless of these settings.\
\pard\pardeftab397\li720\fi-446\ri720\sb180\sa60\partightenfactor0

\f1\fs18 \cf2 (void)parallelSetTaskThreadCounts(No$\'a0dict)\
\f1\fs18 \cf2 (void)parallelSetTaskThreadCounts(No<Dictionary>$\'a0dict)\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f0\b\fs20 \cf2 Sets the number of threads
Expand Down Expand Up @@ -6265,9 +6267,8 @@ Named
\f1\fs18 c()
\f3\fs20 function (including the possibility of type promotion).\
Since this function can be hard to understand at first, here is an example:\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f1\fs18 \cf2 sapply(1:10, "if (applyValue % 2) applyValue ^ 2; else NULL;");\
\f1\fs18 sapply(1:10, "if (applyValue % 2) applyValue ^ 2; else NULL;");\
\pard\pardeftab397\li547\ri720\sb60\sa60\partightenfactor0

\f3\fs20 \cf2 \kerning1\expnd0\expndtw0 This produces the output
Expand Down
2 changes: 1 addition & 1 deletion QtSLiM/QtSLiMExtras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ void ColorizeCallSignature(const EidosCallSignature *call_signature, double poin

if (arg_obj_class && (stripped_mask & kEidosValueMaskObject))
{
int obj_type_name_len = QString::fromStdString(arg_obj_class->ClassName()).length();
int obj_type_name_len = QString::fromStdString(arg_obj_class->ClassNameForDisplay()).length();

typeLength += (obj_type_name_len + 2); // "<" obj_type_name ">"
}
Expand Down
18 changes: 7 additions & 11 deletions QtSLiM/QtSLiMHelpWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ QtSLiMHelpWindow::QtSLiMHelpWindow(QWidget *p_parent) : QWidget(p_parent, Qt::Wi
{
const std::string &element_type = class_object->ClassName();

if (!Eidos_string_hasPrefix(element_type, "_") && (element_type != "DictionaryBase")) // internal classes are undocumented
if (!Eidos_string_hasPrefix(element_type, "_") && (element_type != "DictionaryRetained")) // internal classes are undocumented
{
checkDocumentationOfClass(class_object);
addSuperclassItemForClass(class_object);
Expand Down Expand Up @@ -920,9 +920,9 @@ void QtSLiMHelpWindow::checkDocumentationOfClass(EidosClass *classObject)
{
const EidosClass *superclassObject = classObject->Superclass();

// We're hiding DictionaryBase, where the Dictionary stuff is actually defined, so we have Dictionary pretend that its superclass is Object, so the Dictionary stuff gets checked
if (classObject == gEidosDictionaryRetained_Class)
superclassObject = gEidosObject_Class;
// We're hiding DictionaryRetained, so DictionaryRetained subclasses pretend their superclass is Dictionary
if (superclassObject == gEidosDictionaryRetained_Class)
superclassObject = gEidosDictionaryUnretained_Class;

const QString className = QString::fromStdString(classObject->ClassName());
const QString classKey = "Class " + className;
Expand Down Expand Up @@ -1029,9 +1029,9 @@ void QtSLiMHelpWindow::addSuperclassItemForClass(EidosClass *classObject)
{
const EidosClass *superclassObject = classObject->Superclass();

// We're hiding DictionaryBase, where the Dictionary stuff is actually defined, so we have Dictionary pretend that its superclass is Object
if (classObject == gEidosDictionaryRetained_Class)
superclassObject = gEidosObject_Class;
// We're hiding DictionaryRetained, so DictionaryRetained subclasses pretend their superclass is Dictionary
if (superclassObject == gEidosDictionaryRetained_Class)
superclassObject = gEidosDictionaryUnretained_Class;

const QString className = QString::fromStdString(classObject->ClassName());
const QString classKey = "Class " + className;
Expand All @@ -1042,10 +1042,6 @@ void QtSLiMHelpWindow::addSuperclassItemForClass(EidosClass *classObject)
{
QString superclassName = superclassObject ? QString::fromStdString(superclassObject->ClassName()) : QString("none");

// Hide DictionaryBase by pretending our superclass is Dictionary
if (superclassName == "DictionaryBase")
superclassName = "Dictionary";

bool inDarkMode = QtSLiMInDarkMode();
QtSLiMHelpItem *superclassItem = new QtSLiMHelpItem((QTreeWidgetItem *)nullptr);

Expand Down
2 changes: 1 addition & 1 deletion QtSLiM/QtSLiM_Plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const EidosClass *Plot::Class(void) const

void Plot::Print(std::ostream &p_ostream) const
{
p_ostream << Class()->ClassName(); // standard EidosObject behavior (not Dictionary behavior)
p_ostream << Class()->ClassNameForDisplay(); // standard EidosObject behavior (not Dictionary behavior)
}

EidosValue_SP Plot::GetProperty(EidosGlobalStringID p_property_id)
Expand Down
2 changes: 1 addition & 1 deletion QtSLiM/QtSLiM_SLiMgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const EidosClass *SLiMgui::Class(void) const

void SLiMgui::Print(std::ostream &p_ostream) const
{
p_ostream << Class()->ClassName(); // standard EidosObject behavior (not Dictionary behavior)
p_ostream << Class()->ClassNameForDisplay(); // standard EidosObject behavior (not Dictionary behavior)
}

EidosValue_SP SLiMgui::GetProperty(EidosGlobalStringID p_property_id)
Expand Down
12 changes: 6 additions & 6 deletions QtSLiM/help/EidosHelpClasses.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="2299.5">
<meta name="CocoaVersion" content="2299.77">
<style type="text/css">
p.p1 {margin: 18.0px 0.0px 3.0px 0.0px; font: 11.0px Optima; color: #000000}
p.p2 {margin: 6.0px 0.0px 3.0px 0.0px; font: 11.0px Optima; color: #000000}
Expand Down Expand Up @@ -46,11 +46,11 @@
<p class="p2"><i>5.2.2<span class="Apple-converted-space">  </span></i><span class="s1"><i>DataFrame</i></span><i> methods</i></p>
<p class="p3">– (*)asMatrix(void)</p>
<p class="p4">Returns a matrix representation of the <span class="s1">DataFrame</span>.<span class="Apple-converted-space">  </span>The matrix will have the same type as the elements of the <span class="s1">DataFrame</span>; if the <span class="s1">DataFrame</span> contains more than one type of element, an error will be raised.<span class="Apple-converted-space">  </span>The order of the columns of the <span class="s1">DataFrame</span> will be preserved.<span class="Apple-converted-space">  </span>This method is useful, for example, if you wish to read in a text file as a matrix; you can use <span class="s1">readCSV()</span> to read the file as a <span class="s1">DataFrame</span>, and then convert it to a matrix with <span class="s1">asMatrix()</span>.</p>
<p class="p3">– (void)cbind(object source, ...)</p>
<p class="p3">– (void)cbind(object&lt;Dictionary&gt; source, ...)</p>
<p class="p4">Adds all of the columns contained by <span class="s1">source</span> (which must be a <span class="s1">Dictionary</span> or a subclass of <span class="s1">Dictionary</span> such as <span class="s1">DataFrame</span>) to the receiver.<span class="Apple-converted-space">  </span>This method makes the target <span class="s1">DataFrame</span> wider, by adding new columns.<span class="Apple-converted-space">  </span>If <span class="s1">source</span> contains a column name that is already defined in the target, an error will result.<span class="Apple-converted-space">  </span>As always for <span class="s1">DataFrame</span>, the columns of the resulting <span class="s1">DataFrame</span> must all be the same length.</p>
<p class="p4">The <span class="s1">source</span> parameter may be a non-singleton vector containing multiple <span class="s1">Dictionary</span> objects, and additional <span class="s1">Dictionary</span> vectors may be supplied (thus the ellipsis in the signature).<span class="Apple-converted-space">  </span>Each <span class="s1">Dictionary</span> supplied will be added to the target, in the order supplied.</p>
<p class="p4">This method is similar to the <span class="s1">Dictionary</span> method <span class="s1">addKeysAndValuesFrom()</span>, which may be used instead if replacement of duplicate columns is desired.</p>
<p class="p3">– (void)rbind(object source, ...)</p>
<p class="p3">– (void)rbind(object&lt;Dictionary&gt; source, ...)</p>
<p class="p4">Appends all of the columns contained by <span class="s1">source</span> (which must be a <span class="s1">Dictionary</span> or a subclass of <span class="s1">Dictionary</span> such as <span class="s1">DataFrame</span>) to the receiver.<span class="Apple-converted-space">  </span>This method makes the <span class="s1">DataFrame</span> taller, by adding new rows.<span class="Apple-converted-space">  </span>If the source and target do not contain the same column names in the same order, an error will result.<span class="Apple-converted-space">  </span>As always for <span class="s1">DataFrame</span>, the columns of the resulting <span class="s1">DataFrame</span> must all be the same length.</p>
<p class="p4">The <span class="s1">source</span> parameter may be a non-singleton vector containing multiple <span class="s1">Dictionary</span> objects, and additional <span class="s1">Dictionary</span> vectors may be supplied (thus the ellipsis in the signature).<span class="Apple-converted-space">  </span>Each <span class="s1">Dictionary</span> supplied will be appended to the target, in the order supplied.</p>
<p class="p4">This method is similar to the <span class="s1">Dictionary</span> method <span class="s1">appendKeysAndValuesFrom()</span>, which may be used instead if one wishes the append to work even when the columns are in different orders, or other such situations.</p>
Expand All @@ -77,9 +77,9 @@
<p class="p3">allKeys =&gt; (is)</p>
<p class="p4">A vector containing all of the <span class="s1">string</span> or <span class="s1">integer</span> keys that have been assigned values using <span class="s1">setValue()</span>, in sorted (ascending alphabetic or numeric) order.</p>
<p class="p2"><i>5.3.2<span class="Apple-converted-space">  </span></i><span class="s1"><i>Dictionary</i></span><i> methods</i></p>
<p class="p3">– (void)addKeysAndValuesFrom(object$ source)</p>
<p class="p3">– (void)addKeysAndValuesFrom(object&lt;Dictionary&gt;$ source)</p>
<p class="p4">Adds all of the key-value pairs contained by <span class="s1">source</span> (which must be a <span class="s1">Dictionary</span> or a subclass of <span class="s1">Dictionary</span>) to the receiver.<span class="Apple-converted-space">  </span>If the target already contains a key that is defined in <span class="s1">source</span>, the target’s value for that key will be <i>replaced</i> by the value in <span class="s1">source</span> (contrast this with <span class="s1">appendKeysAndValuesFrom()</span>).</p>
<p class="p3">– (void)appendKeysAndValuesFrom(object source)</p>
<p class="p3">– (void)appendKeysAndValuesFrom(object&lt;Dictionary&gt; source)</p>
<p class="p4">Appends all of the key-value pairs contained by <span class="s1">source</span> (which must be a <span class="s1">Dictionary</span> or a subclass of <span class="s1">Dictionary</span>) to the receiver.<span class="Apple-converted-space">  </span>If the target already contains a key that is defined in source, the value from source will be <i>appended</i> to the target’s existing value, which must be of the same type (contrast this with <span class="s1">addKeysAndValuesFrom()</span>); if the target does not already contain a key that is defined in source, that key-value pair will simply be added to the target.</p>
<p class="p4">In the current implementation, it is an error for either of the values involved in an append to be a matrix or array; values in these <span class="s1">Dictionary</span> objects should be simple vectors.<span class="Apple-converted-space">  </span>This limitation preserves the future option to expand this method’s functionality to do smart things with matrices and arrays.</p>
<p class="p3">– (void)clearKeysAndValues(void)</p>
Expand All @@ -95,7 +95,7 @@
<p class="p4">If the values of <span class="s1">index</span> are such that <i>no</i> value for a given key is selected, the <span class="s1">drop</span> parameter controls the resulting behavior.<span class="Apple-converted-space">  </span>If <span class="s1">drop</span> is <span class="s1">F</span> (the default), the key will be included in the returned dictionary with a zero-length value of matching type, such as <span class="s1">integer(0)</span> or <span class="s1">string(0)</span>.<span class="Apple-converted-space">  </span>If <span class="s1">drop</span> is <span class="s1">T</span>, the key will be omitted from the returned dictionary.</p>
<p class="p3">– (*)getValue(is$ key)</p>
<p class="p4">Returns the value previously set for the dictionary entry identifier <span class="s1">key</span> using <span class="s1">setValue()</span>, or <span class="s1">NULL</span> if no value has been set.</p>
<p class="p3">– (logical$)identicalContents(object$ x)</p>
<p class="p3">– (logical$)identicalContents(object&lt;Dictionary&gt;$ x)</p>
<p class="p4">Returns <span class="s1">T</span> if the target <span class="s1">Dictionary</span> is equal to <span class="s1">x</span> in all respects – containing the same keys, with values that are identical in the sense defined by the <span class="s1">identical()</span> function in Eidos – or returns <span class="s1">F</span> otherwise.</p>
<p class="p4">Note that if <span class="s1">Dictionary</span> objects are contained, as values, by the dictionaries being tested for equality, they will be compared according to the standards of <span class="s1">identical()</span>, and must therefore actually be the <i>same</i> <span class="s1">Dictionary</span> object, shared by both dictionaries, for <span class="s1">isEqual()</span> to return <span class="s1">T</span>.</p>
<p class="p3">– (string)serialize([string$ format = "slim"])</p>
Expand Down
Loading

0 comments on commit b0a0e53

Please sign in to comment.