Commit Graph

47 Commits

Author SHA1 Message Date
Peter Johnson
90ce262bb3 C++ NetworkTable: Provide SetPort() method.
This was previously only available in Java.
2015-09-19 11:44:14 -07:00
Peter Johnson
23448c8277 NetworkTable interface: Provide method to set persistent filename. 2015-09-19 11:40:31 -07:00
Peter Johnson
c5d456f3a6 Add ITable/NetworkTable GetKeys and GetSubTables accessors. 2015-09-16 00:51:05 -07:00
Peter Johnson
6cbc219427 Add ITable/NetworkTable accessors for new features. 2015-09-15 23:43:42 -07:00
Peter Johnson
51eb96903c Java: Improve robustness against JVM crashes on exit.
The JVM doesn't always do a good job of telling JNI modules that the JVM
is going away, which results in a crash in the JavaGlobal and/or
JavaWeakGlobal destructors as they try to delete the associated references
after the JVM has already gone away.

To protect against this, the Notifier now has a static variable that's set
when the Notifier instance (a singleton) is destroyed.  This is used by
JavaGlobal and JavaWeakGlobal to detect when a process exit is in process.
2015-09-14 22:00:22 -07:00
Thad House
46e0ac1258 Added documentation to the C interface
Client/Server functions.
2015-08-31 19:12:45 -07:00
Thad House
22d984a6bd Comments the interop functions in the C interface.
Properly space the comments.
2015-08-31 18:56:05 -07:00
Peter Johnson
8d6f96adb9 Add NT_FreeCharArray. 2015-08-29 08:58:53 -07:00
Peter Johnson
1f431754a9 Simplify C entry point function names.
Rename GetEntry*FromValue to GetValue*.
Rename a couple of NTStringArray to simply StringArray.
2015-08-29 08:48:36 -07:00
Peter Johnson
9b9b41f40e Reformat to match coding style. No functional changes. 2015-08-29 08:30:40 -07:00
Peter Johnson
a451fd3f04 Make string/raw getters/setters use char*+len instead of NT_String.
Also remove NT_AllocateString.

This avoids passing and returning struct NT_String by value.

Also make GetEntry*FromValue take a const NT_Value*.
2015-08-29 08:25:48 -07:00
Thad House
4b7dfc0254 Implements individual getters and setters for the C interface.
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
2015-08-28 13:37:49 -07:00
Peter Johnson
b488cdd6ff Support immediate notify of connection listener.
Also only perform immediate notification to the callback actually
requesting the notification, not all existing callbacks.

Offset returned uids by 1 so uid=0 can be used to indicate immediate
notification.
2015-08-28 00:13:56 -07:00
Peter Johnson
302cc064c6 ConnectionListener: Use bool instead of int for connected parameter. 2015-08-27 23:48:40 -07:00
Peter Johnson
6e4d7ca933 NetworkTable: Protect listeners with mutex. 2015-08-27 23:39:52 -07:00
Peter Johnson
86445b6670 Import llvm::SmallPtrSet. 2015-08-27 22:16:56 -07:00
Peter Johnson
a8836b7665 Value: Use variant of enable_if to fix MakeString/MakeRaw in GCC.
Tested on GCC 4.8, GCC 4.9, and clang 3.6.
2015-08-22 14:01:33 -07:00
Peter Johnson
c41341c7e3 Clean up trailing whitespace. 2015-08-19 20:41:59 -07:00
Peter Johnson
8d7cdeabbf Implement remote procedure calls. 2015-08-13 21:32:16 -07:00
Peter Johnson
0cbcfbc3f0 Import llvm::DenseMap.
Bring in (most of) MathExtras.h as well, as it's shared by SmallVector and
DenseMap.
2015-08-12 17:08:45 -07:00
Peter Johnson
00feb67064 Only use enable_if template on Windows.
This isn't required and doesn't compile on older GCC versions.
2015-08-04 19:59:45 -07:00
Peter Johnson
4146db6fc8 Visual Studio 2013 compilation fixes.
- Missing header file callouts in some cases (library deltas)
- Lack of support for auto parameters in lambdas
- Defining of ERROR by windows.h
- Dispatcher::Connection needs a move constructor (default not generated)
- Need explicit enable_if on std::string move template in Value to avoid trying to move const char[] (string literal)
- Compile flags
2015-08-03 01:27:02 -07:00
Peter Johnson
06e8d835dd Provide ostream output for StringRef. 2015-07-31 23:20:59 -07:00
Peter Johnson
4356e313ec Add logging framework.
DEBUG messages are completely optimized out if NDEBUG is defined.
2015-07-31 22:41:26 -07:00
Peter Johnson
ae070aca70 Value: Add type check functions. 2015-07-24 22:11:57 -07:00
Peter Johnson
3f24b86875 ITable: Add Persist function to make a key persistent. 2015-07-23 21:53:33 -07:00
Peter Johnson
196fcf791b ITable: Const'ify getter functions. 2015-07-23 21:46:30 -07:00
Peter Johnson
6bccf528d7 ITableListener.h: Forward declare ITable. 2015-07-23 21:41:30 -07:00
Peter Johnson
1fc03803cd ITableListener::ValueChanged: Don't make key const. 2015-07-23 21:40:24 -07:00
Peter Johnson
8fa0e6c914 Add shims for old NetworkTable interface.
This provides classes for virtual subtables using path delimiters within
the global NetworkTable namespace.
2015-07-23 01:23:09 -07:00
Peter Johnson
6f940bcaaf Add immediate_notify and is_new to entry listener.
On the callback function, is_new indicates the value is newly added.

On adding a callback function, immediate_notify indicates the callback
should be called once (with is_new=true) for each matching entry that
already exists.
2015-07-23 01:02:53 -07:00
Peter Johnson
79f732f239 Import llvm::SmallString and dependencies.
Update StringRef and StringExtras with SmallVector functions.
2015-07-22 22:29:46 -07:00
Peter Johnson
593bc28446 Move StringMap.h and StringExtras.h to public includes.
While these aren't required by the public interface, they are generally
useful classes for users of the library.
2015-07-22 22:10:56 -07:00
Peter Johnson
9c204533e8 Value: Disambiguate std::string&& and StringRef.
Making the former a template causes the compiler to prefer the latter
when given a bare C string.
2015-07-22 22:08:13 -07:00
Peter Johnson
4c14f7823a ntcore_cpp.h: Comment cleanup. 2015-07-22 21:41:25 -07:00
Peter Johnson
8bbe5f9fdb ArrayRef: Add portability checks for constexpr. 2015-07-20 20:49:49 -07:00
Peter Johnson
98d45777c6 Remove unnecessary llvm qualifier. 2015-07-20 00:19:20 -07:00
Peter Johnson
1cc148848b StartServer: Take persist_filename as a StringRef. 2015-07-19 16:11:56 -07:00
Peter Johnson
c4a7f6ec9b SavePersistent: Safely save through temp file.
Also change SavePersistent and LoadPersistent to take StringRef.
2015-07-18 00:39:08 -07:00
Peter Johnson
3025a7e51e Finish C wrappers. 2015-07-17 08:47:25 -07:00
Peter Johnson
fcbd2751ba Provide C++ API. Move all classes to "nt" namespace.
The C API is now just simple wrappers around the C++ API.
2015-07-17 07:21:07 -07:00
Peter Johnson
05e084364a Start implementing LoadPersistent.
Switch to using fstream instead of stdio.

Change-Id: I600a8748a0b3dcf24740d63cc296df000abc388d
2015-07-11 09:33:33 -07:00
Peter Johnson
2a1ccaff1e Add timestamp function NT_Now().
Change-Id: I797a220308cd64ca0545222b433a18aa2294bac5
2015-07-11 09:33:33 -07:00
Peter Johnson
1a48e75d43 Implement SavePersistent.
Change-Id: I0b635b3e17dcfb6f238f57f2bff5575538ab7743
2015-07-11 09:33:32 -07:00
Peter Johnson
a896a3ade5 Import LLVM StringMap et al.
Change-Id: Ic48c722c2856c7aa36001935adbcf31b986ac1f3
2015-07-11 09:33:32 -07:00
Peter Johnson
047cccda89 Refactor WireEncoder.
Change-Id: I50106755ce5571821d6e36767b16d08b91f054de
2015-07-11 09:33:32 -07:00
Peter Johnson
842fb957a6 ntcore: Initial commit.
Change-Id: Id8df275a34aaa628581b18e39014b880c29bf9b2
2015-07-11 09:33:32 -07:00