Skip to content

Commit

Permalink
Merge pull request #2253 from AllenInstitute/feature/2253-update_JSON…
Browse files Browse the repository at this point in the history
…_XOP

Update JSON XOP
  • Loading branch information
t-b authored Sep 6, 2024
2 parents 398baea + ce026fa commit 99f2c0e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_CheckInstallation.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// MIES installation

static StrConstant CHI_NIDAQ_XOP_64_HASH = "b13267a080053c07b80302212b7f73ac199e1f001d9a1b4303e2d7dce1aeb39e"
static StrConstant CHI_JSON_XOP_VERSION = "version-882-gad839a0"
static StrConstant CHI_JSON_XOP_VERSION = "version-892-g9251933"
static StrConstant CHI_TUF_XOP_VERSION = "version-163-g686effb"
static StrConstant CHI_ITC_XOP_VERSION = "latest-174-gb9915a9"

Expand Down
90 changes: 46 additions & 44 deletions Packages/MIES/json_functions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,32 @@ static Constant JSON_QFLAG_DEFAULT = 1
#endif

/// @addtogroup JSON_TYPES
///@{
/// @{
Constant JSON_INVALID = -1
Constant JSON_OBJECT = 0
Constant JSON_ARRAY = 1
Constant JSON_NUMERIC = 2
Constant JSON_STRING = 3
Constant JSON_BOOL = 4
Constant JSON_NULL = 5
///@}
/// @}

/// @addtogroup JSON_SYNC_OPTIONS
///@{
/// @{
// if element in source exists, but not in target, then add element in target
Constant JSON_SYNC_ADD_TO_TARGET = 0x0
// if element in target exists, but not in source, then remove element in target
Constant JSON_SYNC_REMOVE_IN_TARGET = 0x1
// if element in source exists and in target, then overwrite element in target
Constant JSON_SYNC_OVERWRITE_IN_TARGET = 0x2
///@}
/// @}

static Constant IGOR_STRING_MAX_SIZE = 2147483647
static Constant INT64_MAX_IN_DOUBLE = 9223372036854774784
static Constant INT64_MIN_IN_DOUBLE = -9223372036854775808

/// @addtogroup JSONXOP_Parse
///@{
/// @{
/// @brief Parse a JSON string with the XOP
///
/// @param jsonStr string representation of the JSON object
Expand All @@ -93,10 +95,10 @@ threadsafe Function JSON_Parse(jsonStr, [ignoreErr])

return V_Value
End
///@}
/// @}

/// @addtogroup JSONXOP_Dump
///@{
/// @{

/// @brief Dump a JSON id to its string representation
///
Expand All @@ -123,10 +125,10 @@ threadsafe Function/S JSON_Dump(jsonID, [indent, ignoreErr])

return S_Value
End
///@}
/// @}

/// @addtogroup JSONXOP_New
///@{
/// @{
/// @brief register a new object
///
/// @param ignoreErr [optional, default 0] set to ignore runtime errors
Expand All @@ -147,10 +149,10 @@ threadsafe Function JSON_New([ignoreErr])

return V_Value
End
///@}
/// @}

/// @addtogroup JSONXOP_Release
///@{
/// @{
/// @brief Release a JSON id from memory
///
/// @param jsonID numeric identifier of the main object
Expand All @@ -173,10 +175,10 @@ threadsafe Function JSON_Release(jsonID, [ignoreErr])

return 0
End
///@}
/// @}

/// @addtogroup JSONXOP_Remove
///@{
/// @{
/// @brief Remove a path element from a JSON string representation
///
/// @param jsonID numeric identifier of the main object
Expand All @@ -201,10 +203,10 @@ threadsafe Function JSON_Remove(jsonID, jsonPath, [ignoreErr])

return 0
End
///@}
/// @}

/// @addtogroup JSONXOP_AddTree
///@{
/// @{

/// @brief Recursively add new objects to the tree
///
Expand Down Expand Up @@ -258,9 +260,9 @@ threadsafe static Function JSON_AddTree(jsonID, jsonPath, type, ignoreErr)
return 0
End

///@}
/// @}
/// @addtogroup JSONXOP_GetKeys
///@{
/// @{
/// @brief Get the name of all object members of the specified path
///
/// @param jsonID numeric identifier of the JSON object
Expand Down Expand Up @@ -292,10 +294,10 @@ threadsafe Function/WAVE JSON_GetKeys(jsonID, jsonPath, [esc, ignoreErr])

return result
End
///@}
/// @}

/// @addtogroup JSONXOP_GetType
///@{
/// @{
/// @brief get the JSON Type for an element at the given path.
///
/// @param jsonID numeric identifier of the JSON object
Expand All @@ -321,10 +323,10 @@ threadsafe Function JSON_GetType(jsonID, jsonPath, [ignoreErr])

return V_Value
End
///@}
/// @}

/// @addtogroup JSONXOP_GetArraySize
///@{
/// @{
/// @brief Get the number of elements in an array.
///
/// @param jsonID numeric identifier of the JSON object
Expand All @@ -349,10 +351,10 @@ threadsafe Function JSON_GetArraySize(jsonID, jsonPath, [ignoreErr])

return V_Value
End
///@}
/// @}

/// @addtogroup JSONXOP_GetMaxArraySize
///@{
/// @{
/// @brief Get the maximum element size for each dimension in an array
///
/// @param jsonID numeric identifier of the JSON object
Expand All @@ -377,10 +379,10 @@ threadsafe Function/WAVE JSON_GetMaxArraySize(jsonID, jsonPath, [ignoreErr])

return w
End
///@}
/// @}

/// @addtogroup JSONXOP_GetValue
///@{
/// @{

/// @brief Get new JSON object from a json path of an existing JSON object.
/// The original jsonID is not freed and stays valid.
Expand Down Expand Up @@ -564,10 +566,10 @@ threadsafe Function [UInt64 result] JSON_GetUInt64(Variable jsonID, String jsonP
return [result]
End

///@}
/// @}

/// @addtogroup JSONXOP_AddValue
///@{
/// @{

/// @brief Add a string entity to a JSON object
///
Expand Down Expand Up @@ -611,7 +613,7 @@ threadsafe Function JSON_AddVariable(jsonID, jsonPath, value, [significance, ign

ignoreErr = ParamIsDefault(ignoreErr) ? JSON_ZFLAG_DEFAULT : !!ignoreErr

if(trunc(value) == value && !numtype(value))
if(trunc(value) == value && !numtype(value) && value >= INT64_MIN_IN_DOUBLE && value <= INT64_MAX_IN_DOUBLE)
JSONXOP_AddValue/Z=1/Q=(JSON_QFLAG_DEFAULT)/I=(value) jsonID, jsonPath
elseif(ParamIsDefault(significance))
JSONXOP_AddValue/Z=1/Q=(JSON_QFLAG_DEFAULT)/V=(value) jsonID, jsonPath
Expand Down Expand Up @@ -857,7 +859,7 @@ threadsafe Function JSON_SetVariable(jsonID, jsonPath, value, [significance, ign

ignoreErr = ParamIsDefault(ignoreErr) ? JSON_ZFLAG_DEFAULT : !!ignoreErr

if(trunc(value) == value && !numtype(value))
if(trunc(value) == value && !numtype(value) && value >= INT64_MIN_IN_DOUBLE && value <= INT64_MAX_IN_DOUBLE)
JSONXOP_AddValue/Z=1/Q=(JSON_QFLAG_DEFAULT)/O/I=(value) jsonID, jsonPath
elseif(ParamIsDefault(significance))
JSONXOP_AddValue/Z=1/Q=(JSON_QFLAG_DEFAULT)/O/V=(value) jsonID, jsonPath
Expand Down Expand Up @@ -1061,7 +1063,7 @@ threadsafe Function JSON_SetJSON(jsonID, jsonPath, jsonID2, [ignoreErr])
return 0
End

///@}
/// @}

threadsafe static Function JSON_KVPairsToJSON(jsonID, jsonPath, str, ignoreErr)
variable jsonID, ignoreErr
Expand All @@ -1082,7 +1084,7 @@ threadsafe static Function JSON_KVPairsToJSON(jsonID, jsonPath, str, ignoreErr)
End

/// @addtogroup JSON_GetIgorInfo
///@{
/// @{

/// @brief Return JSON with Igor information
///
Expand All @@ -1105,10 +1107,10 @@ threadsafe Function JSON_GetIgorInfo([ignoreErr])
return jsonID
End

///@}
/// @}

/// @addtogroup JSONXOP_Version
///@{
/// @{

/// @brief Output version information useful for issue reports
///
Expand Down Expand Up @@ -1138,10 +1140,10 @@ Function/S JSON_Version([ignoreErr])
return rep
End

///@}
/// @}

/// @addtogroup JSONXOP_Exists
///@{
/// @{

/// @brief Check if the jsonID/jsonPath is valid
///
Expand All @@ -1155,10 +1157,10 @@ threadsafe Function JSON_Exists(jsonID, jsonPath)
return JSON_GetType(jsonID, jsonPath, ignoreErr = 1) != JSON_INVALID
End

///@}
/// @}

/// @addtogroup JSONXOP_Options
///@{
/// @{

/// @brief Disables quiet mode
Function JSON_DisableQuietMode()
Expand All @@ -1184,10 +1186,10 @@ Function JSON_UnsetIgnoreErrors()
Execute/P/Q "COMPILEPROCEDURES "
End

///@}
/// @}

/// @addtogroup JSON_SyncJSON
///@{
/// @{

/// @brief Syncs data from a source json into a target json.
///
Expand Down Expand Up @@ -1298,7 +1300,7 @@ threadsafe Function JSON_SyncJSON(variable srcJsonId, variable tgtJsonId, string
return 0
End

///@}
/// @}

threadsafe static Function JSON_AddArrayElementToParentIfArray(variable jsonId, string jsonPath)

Expand All @@ -1318,7 +1320,7 @@ threadsafe static Function JSON_CopyJSON(variable srcJsonId, variable tgtJsonId,
End

/// @addtogroup JSON_LoadSave
///@{
/// @{

/// @brief Loads a text file and parses it to JSON, then returns jsonId
///
Expand Down Expand Up @@ -1402,10 +1404,10 @@ threadsafe Function JSON_Save(variable jsonId, string fullFilepath, [variable ig
return 0
End

///@}
/// @}

/// @addtogroup JSON_IsValid
///@{
/// @{

/// @brief Check if the given JSON identifier refers to an open JSON document
///
Expand All @@ -1422,4 +1424,4 @@ threadsafe Function JSON_IsValid(variable jsonID)
return !V_flag
End

///@}
/// @}
2 changes: 1 addition & 1 deletion Packages/tests/UTF_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ StrConstant ZSTD_SUFFIX = ".zst"

Constant TP_DURATION_S = 5

Constant PSQ_TEST_VERY_LARGE_FREQUENCY = 1e300
Constant PSQ_TEST_VERY_LARGE_FREQUENCY = 1e350
2 changes: 0 additions & 2 deletions Packages/tests/UTF_HardwareHelperFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,6 @@ static Function CheckRangeOfUserLabnotebookKeys(string device, variable type, va
endif
endif

CHECK(IsFinite(value))

INFO("sweepNo=%g, entry=%s, unit=%s\r", n0 = sweepNo, s0 = entry, s1 = unit)

// do a coarse range check
Expand Down
Binary file modified XOPs-IP9-64bit/JSON-64.xop
Binary file not shown.
Binary file modified XOPs-MacOSX-IP9-64bit/JSON-64.xop/Contents/CodeResources
Binary file not shown.
Binary file modified XOPs-MacOSX-IP9-64bit/JSON-64.xop/Contents/MacOS/JSON-64
Binary file not shown.

0 comments on commit 99f2c0e

Please sign in to comment.