-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vireo EggShell Refactor for Supporting More Types #471
Conversation
8cca327
to
2ef6124
Compare
source/core/module_typeHelpers.js
Outdated
var i = 0, | ||
typeHandler; | ||
|
||
for (i = 0; typeHandlers.length; i += 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be i < typeHandlers.length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😮 you are right. dunno how that slipped through. I'll fix it later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this code exercised by one of the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it couldn't have, it would be an infinite loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we are missing a test for a type that we cannot handle. I'll add that as well as fixing this.
source/core/module_typeHelpers.js
Outdated
|
||
var dispatchVisitCluster = function (typeVisitor, valueRef, data) { | ||
validateVisitMethod(typeVisitor.visitCluster, 'visitCluster'); | ||
return typeVisitor.visitCluster(typeVisitor, valueRef, data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be typeVisitor.visitCluster(valueRef, data);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'lll fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still reviewing
source/core/CEntryPoints.cpp
Outdated
} | ||
//------------------------------------------------------------ | ||
//! Read a symbol's value as a string. Value will be formatted according to the format designated. | ||
VIREO_EXPORT const char* EggShell_ReadValueString(TypeManagerRef tm, | ||
const char* viName, const char* eltName, const char* format) | ||
VIREO_EXPORT EggShellResult EggShell_ReadValueString(TypeManagerRef tm, const TypeRef typeRef, void* data, const char* format, UInt8** valueString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keep valueString char **?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Begin() returns a UInt8*. Might as well avoid the cast.
source/core/CEntryPoints.cpp
Outdated
//! Returns -1 if the symbols is not found, -2 if was not possible to resize the array and 0 if resizing was successful. | ||
VIREO_EXPORT Int32 EggShell_ResizeArray(TypeManagerRef tm, const char* viName, const char* eltName, Int32 rank, Int32* newLengths) | ||
VIREO_EXPORT EggShellResult EggShell_ResizeArray(TypeManagerRef tm, const TypeRef typeRef, const void* pData, | ||
Int32 newDimensionsLength, Int32 newDimensions[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newDimensionsLength is quite a misleading name for rank. We should stick to using rank. If newLengths is not clear enough, that can be renamed as newDimensionLengths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm down for renaming the newDimensions[] input to dimensionLengths[] as that is the name used in the rest of vireo.
How do y'all feel about me removing the newDimensionsLength/Rank input?
All it does is take the passed value and check that it is equal to the Rank Vireo already knows.
I would rather add a comment that says dimensionLengths[] should have a number of items equal to the Rank of the array being manipulated. It seems like an unnecessary input since this api is not allowing changing the rank of a Vireo array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, renaming newDimensions -> dimensionLengths
and
newDimensionsLength -> rank
is fine. @gleonoliva might be tackling this in a bit
source/core/CEntryPoints.cpp
Outdated
//------------------------------------------------------------ | ||
//! Get the values for dimensions of the array. Assumes dimensions target is of length equal to rank | ||
//! Caller is expected to allocate an array dimensions of size array rank for the duration of function invocation. | ||
VIREO_EXPORT void Data_GetArrayDimensions(const void* pData, IntIndex dimensions[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Dimensions" as a name by itself is ambiguous. What about Dimensions? Number of Dimensions or Length of each dimension? I would be consistent with Vireo's terminology: Use Rank for number of Dimensions which is an integer; use DimensionLengths for lengths of each dimension which is an integer array.
e.g.:
Data_GetArrayDimensionLengths(...., Int dimensionLengthts[])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change to the dimensionLengths name used in the rest of Vireo
} | ||
//------------------------------------------------------------ | ||
//! Get the total length for an array | ||
VIREO_EXPORT Int32 Data_GetArrayLength(const void* pData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name ArrayLength is good 👍
source/core/CEntryPoints.cpp
Outdated
STACK_VAR(String, tempReturn); | ||
returnBuffer = tempReturn.DetachValue(); | ||
} else { | ||
returnBuffer->Resize1D(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resize1D(0);
Instead of resizing it to a size of 0 and then appending immediately, Resize1D can be called with name.Length()+1 and then name can be copied to instead of getting appended and will be more efficient.
Also, in other places in this PR.
source/core/CEntryPoints.cpp
Outdated
|
||
if (returnBuffer) { | ||
returnBuffer->AppendSubString(&name); | ||
// Add an explicit nullptr terminator so it looks like a C string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullptr terminator --> null terminator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When applying this change, don't forget to update other functions with the same comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I took care of that
source/core/TypeAndDataManager.cpp
Outdated
TypeRef t = this; | ||
while (t) { | ||
SubString typeName = t->Name(); | ||
SubString analogTypess(TypeAnalogWaveform); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SubString analogTypess(TypeAnalogWaveform);
this temporary is misspelled but not likely even needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change the name
@@ -546,6 +651,66 @@ VIREO_EXPORT TypeRef TypeRef_GetSubElementByIndex(TypeRef typeRef, Int32 index) | |||
return typeRef->GetSubElement(index); | |||
} | |||
//------------------------------------------------------------ | |||
VIREO_EXPORT Boolean TypeRef_IsCluster(TypeRef typeRef) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have the prefix of EggShell for all the new APIs that start with TypeRef as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are not exposing these functions to eggShell, I don't think they should be prefixed as eggshell. That's why we added the typeHelpers module.
source/io/module_eggShell.js
Outdated
return valueRef; | ||
}; | ||
|
||
Module.eggShell.findSubValueRef = publicAPI.eggShell.findSubValueRef = function (valueRef, path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path should be renamed to subPath to reflect it is not the full path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work. This was an ambitious refactor.
@@ -10,6 +10,7 @@ define(ArrayDemo dv(.VirtualInstrument ( | |||
|
|||
e(a(.Int32 * *) variableArray2d) | |||
e(a(.Int32 2 3) fixedArray2d) | |||
e(a(.Int32 0 0) fixedArray2dEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add comments to via tests with items that appear to be unused like this one to note that they are read programmatically by a karma test.
source/include/CEntryPoints.h
Outdated
@@ -21,6 +21,9 @@ typedef enum { | |||
kEggShellResult_UnexpectedObjectType = 2, | |||
kEggShellResult_InvalidResultPointer = 3, | |||
kEggShellResult_UnableToCreateReturnBuffer = 4, | |||
kEggShellResult_InvalidTypeRef = 5, | |||
kEggShellResult_MismatchedArrayRank = 6, | |||
kEggSehllResult_UnableToParseData = 7, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this one. I'll fix it 👍
|
||
Module.typeHelpers.findTypeDispatcher = function (typeRef) { | ||
var i = 0, | ||
typeHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the spacing issue? Linter did not complain with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some comments so far.
source/core/CEntryPoints.cpp
Outdated
{ | ||
void *pData = nullptr; | ||
|
||
SubString objectName(viName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TypeManagerScope (tm), before this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I'll change it.
source/core/CEntryPoints.cpp
Outdated
} | ||
//------------------------------------------------------------ | ||
// Write a string value to a symbol. Value will be parsed according to format designated. | ||
VIREO_EXPORT EggShellResult EggShell_WriteValueString(TypeManagerRef tm, const TypeRef typeRef, void* data, const char* format, const char* value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this and other functions use pData instead of data to keep the naming consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it.
return kEggShellResult_Success; | ||
} | ||
//------------------------------------------------------------ | ||
// Write a string value to a symbol. Value will be parsed according to format designated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to designated format" instead of "to format designated"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it
source/core/CEntryPoints.cpp
Outdated
|
||
if (returnBuffer) { | ||
returnBuffer->AppendSubString(&name); | ||
// Add an explicit nullptr terminator so it looks like a C string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When applying this change, don't forget to update other functions with the same comment.
Also addressed feedback from the PR.
Also added a test for unssported Enums of 64 bits.
Standardized on call for dispatchers and fixed loop condition.
Timestamps are 2 UInt64 therefore their JSON representation are strings. Updating expected values to match this.
Also added tests that verify this behavior.
fix for findSubValueRef. I added tests that effectively fail before the fix and pass after making it. Included is the renaming of TypeWaveform.test.js to TypeWaveform.Test.js which were not being executed because of the regex used in karma.conf to include tests. I also fixed those.
* Adressed feedback from PR * Renamed subpathstackPointer * Fixing typo, variable names and TypeManagerScope for FindValue. * Renamed pData in header
730a861
to
1eef26c
Compare
@gleonoliva rebased on top of master at 581798e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address minor feedback, other than that, good to go from my part.
source/core/TypeAndDataManager.cpp
Outdated
{ | ||
TypeRef t = this; | ||
while (t) { | ||
if (t->Name().Compare(&TypeInt8) || t->Name().Compare(&TypeInt16) || t->Name().Compare(&TypeInt32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment for readability, keep all signed checks on one line and the unsigned checks in another line.
))) | ||
|
||
enqueue (MyVI) | ||
// Finished! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line at the end of the file to remove the "red marker"
expect(readDouble('enum64releases')).toBe(5); | ||
}); | ||
|
||
it('to read different boolean types from memory', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change "boolean types" to "boolean values"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other tests use the word 'types' in them do you want me to change those too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see the inconsistency, I'll change all of them to be values.
testWriteDouble('enum64releases', 5, 4); | ||
}); | ||
|
||
it('to write different boolean types to memory', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, "boolean types" to "boolean values".
expect(readDouble('dataItem_ArrayOfTimestamp', '0')).toMatchIEEE754Number(3564057536.423476); | ||
}); | ||
|
||
it('to read different double values from N-dimensional arrays', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a 3D case on this list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a 3D case on line 41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
* Changed test names to from types to values to keep them consistent * Added an extra line at the end to remove red marker * Improving readibility by having signed type checks in same line
Use decoded field names in readValueRefObject
Implementation of "Vireo API Changes for Supporting More Types Design Doc" - NITalk - PDF
This change encapsulates the breaking API changes associated with the Vireo API refactor. There is still additional work to be done out of master after the change is merged consisting of:
Making error checks and error handling consistent across all of the new api functions: JS API Refactor Acceptance Conditions #466
Migrating the following JavaScript users of the now deprecated API functions to the new API functions: HttpClient, JavaScriptInvoke, Core (FPSync, LV Error Handling), Events.
Removing the deprecated API functionality
LVjs Build: Still in-progress testing changes in Bajor/Main