Skip to content

Commit

Permalink
[ntcore] Clean up ntcore_test.h (#4804)
Browse files Browse the repository at this point in the history
The RPC functions are no longer implemented.

Also make header C-safe.
  • Loading branch information
PeterJohnson authored Dec 12, 2022
1 parent 7e84ea8 commit f8d4e98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
8 changes: 4 additions & 4 deletions ntcore/src/main/native/cpp/ntcore_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
#include "Value_internal.h"

extern "C" {
struct NT_String* NT_GetStringForTesting(const char* string, int* struct_size) {
struct NT_String* str =
struct NT_String* NT_GetStringForTesting(const char* str, int* struct_size) {
struct NT_String* strout =
static_cast<NT_String*>(wpi::safe_calloc(1, sizeof(NT_String)));
nt::ConvertToC(string, str);
nt::ConvertToC(str, strout);
*struct_size = sizeof(NT_String);
return str;
return strout;
}

struct NT_TopicInfo* NT_GetTopicInfoForTesting(const char* name,
Expand Down
31 changes: 6 additions & 25 deletions ntcore/src/main/native/include/ntcore_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

#include <stdint.h>

#include <string>

#include "ntcore.h"

// Functions in this header are to be used only for testing

#ifdef __cplusplus
extern "C" {
struct NT_String* NT_GetStringForTesting(const char* string, int* struct_size);
#endif

struct NT_String* NT_GetStringForTesting(const char* str, int* struct_size);
// No need for free as one already exists in main library

struct NT_EntryInfo* NT_GetEntryInfoForTesting(const char* name,
Expand Down Expand Up @@ -58,26 +59,6 @@ struct NT_Value* NT_GetValueStringArrayForTesting(uint64_t last_change,
int* struct_size);
// No need for free as one already exists in the main library

struct NT_RpcParamDef* NT_GetRpcParamDefForTesting(const char* name,
const struct NT_Value* val,
int* struct_size);

void NT_FreeRpcParamDefForTesting(struct NT_RpcParamDef* def);

struct NT_RpcResultDef* NT_GetRpcResultsDefForTesting(const char* name,
enum NT_Type type,
int* struct_size);

void NT_FreeRpcResultsDefForTesting(struct NT_RpcResultDef* def);

struct NT_RpcDefinition* NT_GetRpcDefinitionForTesting(
unsigned int version, const char* name, size_t num_params,
const struct NT_RpcParamDef* params, size_t num_results,
const struct NT_RpcResultDef* results, int* struct_size);
// No need for free as one already exists in the main library

struct NT_RpcCallInfo* NT_GetRpcCallInfoForTesting(
unsigned int rpc_id, unsigned int call_uid, const char* name,
const char* params, size_t params_len, int* struct_size);
// No need for free as one already exists in the main library
#ifdef __cplusplus
} // extern "C"
#endif

0 comments on commit f8d4e98

Please sign in to comment.