mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Starting to add Getters, Setters, and Allocators to the C interface Because of the union in the NT_Value structure, some languages would have a difficult time with the interop. This commit adds individual getters and setters to the C interface to make interop easier. In addition, some languages cannot allocate native memory in the same heap that the C code would use. This adds allocation functions to make sure that all our memory is allocated and can be freed properly from the same heap. The reason the getters are not individual get functions are because that would require the calling code to first get the type, and then call the specific getter for that type. Doing combined get functions causes interop code to only have to cross interop boundaries once to get the value instead of twice, for a light performance increase. However, this could be changed without much work. NT getters and setters round 2 Fixed some of the code based on the comments in the pull request. Creates individual getters. Should work better then 1 single getter. Fixes end of file new line, and fixes function nameing SetNTValue... made less sense then SetEntry... Matches the getter naming. Fixed methods to be less leaky. Fixed Formatting, Fixed return values on Bool and Double. Added Contains Key Changed ContainsKey to GetType. Also renamed Arr to Array In public functions, I think I like Array better then Arr. Also, make the getters that use value check for a null value, which should prevent segfaults. Fixes C++ Type functions to work properly NTString Set functions still do not work properly though. I need some help on there. Error message is in the pull request. Changes Get functions to return status and have pointer to data passed in to be set. Fixes NT_Strings Added new functions to ntcore.def Fixes NT_PostRpcResponse in the def file Was NT_PostRpcRepsonse, which was failing the build. Removed unused parameter from setters Since we were forcing exports in the cmake build, they were seen in windows, but since the header didnt match the implementation they wouldn't export on linux. So fixed that. Linux builds now work properly, tested on a physical RIO. Added a DisposeEntryInfoArray method. There was no way to free the array returned from GetEntryInfo Adds NT_DisposeEntryInfoArray to the def file. Implement automatic persistent saves. Also loads persistent file on server start. Update TODO. raw_istream and kin: a few cleanups. anchor() doesn't seem to change compiler output in current compilers, so remove it. Use default where appropriate rather than empty bodies. Clean up trailing whitespace. Dispatcher: Move several fixed initial values to header. Uninline constructors to reduce GetInstance() inlined code size. Logger: Move m_min_level init to header. Replaced time.h with std::chrono This implementation returns the same values as the previous one on both a Linux machine and the roboRIO. Value: Use variant of enable_if to fix MakeString/MakeRaw in GCC. Tested on GCC 4.8, GCC 4.9, and clang 3.6. Don't dispose in ConvertToC for NT_String and NT_Value. Fixes #16. Fixed Gradle build to actually export proper functions Finishes fixes in pull request Changes array setters to be const To build RPC, needed a way to allocate a Char Array Since after the callback, the C code explicitly frees, a way to make sure to allocate the callback return string from the same heap was needed. Adds const to NTString setters. Removes Const from NTString setters