Skip to content
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

1DS C++ SDK bindings for Unity C# layer #1099

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7fd5bef
Initial commit of changes to simplify creation of shared library
maxgolov Jan 8, 2020
7a99957
Add netcore30 wrapper example on top of shared lib
maxgolov Jan 8, 2020
4abaff9
Clean-up the wrapper a little bit
maxgolov Jan 8, 2020
bde1f87
Merge branch 'master' into maxgolov/shared_library
maxgolov Jan 9, 2020
c73b4ef
Add more APIs to netcore implementation
maxgolov Jan 18, 2020
2ddf49d
Merge branch 'master' into maxgolov/shared_library
maxgolov Jan 18, 2020
30b7fe0
Working implementation of C# .NET Core 3.1 wrapper on top of C API (t…
maxgolov Jan 19, 2020
5a3059c
Add some support for GUID type (not the final impl)
maxgolov Jan 19, 2020
9f638ea
Merge branch 'master' into maxgolov/shared_library
maxgolov Mar 31, 2020
72cec82
Merge branch 'master' of https://github.com/microsoft/cpp_client_tele…
maxgolov Apr 12, 2020
d0a1bf5
Merge branch 'maxgolov/shared_library' of https://github.com/microsof…
maxgolov Apr 12, 2020
1d87d06
Merge branch 'master' into maxgolov/shared_library
maxgolov Apr 16, 2020
3702210
Merge branch 'master' into maxgolov/shared_library
maxgolov May 2, 2020
f05f1f6
Merge branch 'master' into maxgolov/shared_library
maxgolov May 21, 2020
dd687da
Merge branch 'master' of https://github.com/microsoft/cpp_client_tele…
maxgolov Sep 25, 2020
0b54436
Merge branch 'master' of https://github.com/microsoft/cpp_client_tele…
maxgolov Sep 25, 2020
3e0c9a6
Verify that the .NET Core wrapper sample works on Windows
maxgolov Sep 25, 2020
cf47c90
Merge branch 'master' into maxgolov/shared_library
maxgolov Sep 25, 2020
214f3ba
Merge branch 'master' into maxgolov/shared_library
maxgolov Sep 27, 2020
489e2e2
Merge branch 'master' into maxgolov/shared_library
maxgolov Oct 2, 2020
e607fa4
Merge branch 'master' into maxgolov/shared_library
maxgolov Oct 6, 2020
acadc08
Merge branch 'maxgolov/shared_library' of https://github.com/microsof…
maxgolov Feb 12, 2023
ef6ccbd
Move packing behavior where it would fit better - ctmacros.hpp
maxgolov Feb 12, 2023
2faa5c1
There really is 8 of them, not 7
maxgolov Feb 12, 2023
d2bbc61
Clean-up C# side
maxgolov Feb 13, 2023
3266cd9
Allow C API to decide what token to use: LogManager primaryToken or i…
maxgolov Feb 13, 2023
515e059
Since packing is a potentially ABI-breaking change, need to update th…
maxgolov Feb 13, 2023
7f525d9
Minor bugfix
maxgolov Feb 13, 2023
9de1d48
Use debug library in the sample
maxgolov Feb 13, 2023
b9b8fc0
Add helper method and use Newtonsoft for now
maxgolov Feb 13, 2023
eb7fa34
Merge branch 'main' into maxgolov/shared_library
lalitb Mar 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/cpp/SampleCppMini/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void test_cpp_api(const char * token, int ticketType, const char *ticket)

if (ticket != nullptr)
{
const char *ticketNames[7] =
const char *ticketNames[8] =
{
"TicketType_MSA_Device",
"TicketType_MSA_User",
Expand All @@ -40,7 +40,7 @@ void test_cpp_api(const char * token, int ticketType, const char *ticket)
"TicketType_AAD",
"TicketType_AAD_User",
"TicketType_AAD_JWT",
"TicketType_AAD_Device",
"TicketType_AAD_Device"
};
printf("\nSet ticket %s=%s\n", ticketNames[ticketType], ticket);
auto tc = LogManager::GetAuthTokensController();
Expand Down
20 changes: 17 additions & 3 deletions lib/api/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,24 @@ evt_status_t mat_log(evt_context_t *ctx)
EventProperties props;
props.unpack(evt, ctx->size);

// Determine ingestion token to use for this record.
std::string token;

// Use LogManager configuration primary token if available.
if (config.HasConfig(CFG_STR_PRIMARY_TOKEN))
{
token = static_cast<const char*>(config[CFG_STR_PRIMARY_TOKEN]);
}

// Allow to override iKey per event via property.
// C API client maintains one handle for different tenants.
auto m = props.GetProperties();
EventProperty &prop = m[COMMONFIELDS_IKEY];
std::string token = prop.as_string;
props.erase(COMMONFIELDS_IKEY);
if (m.count(COMMONFIELDS_IKEY))
{
EventProperty& prop = m[COMMONFIELDS_IKEY];
token = prop.as_string;
props.erase(COMMONFIELDS_IKEY);
}

// Privacy feature for OTEL C API client:
//
Expand Down
20 changes: 20 additions & 0 deletions lib/include/public/ctmacros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,24 @@
#define EVTSDK_LIBABI_CDECL MATSDK_LIBABI_CDECL
#define EVTSDK_SPEC MATSDK_SPEC

/* Implement struct packing for stable FFI C API */
#ifdef __clang__
# define MATSDK_PACKED_STRUCT __attribute__((packed))
# define MATSDK_PACK_PUSH
# define MATSDK_PACK_POP
#elif __GNUC__
# define MATSDK_PACKED_STRUCT __attribute__((packed))
# define MATSDK_PACK_PUSH
# define MATSDK_PACK_POP
#elif _MSC_VER
# define MATSDK_PACKED_STRUCT
# define MATSDK_PACK_PUSH __pragma(pack(push, 1))
# define MATSDK_PACK_POP __pragma(pack(pop))
#else
/* No packing behavior on unknown compilers */
# define MATSDK_PACKED_STRUCT
# define MATSDK_PACK_PUSH
# define MATSDK_PACK_POP
#endif

#endif
20 changes: 14 additions & 6 deletions lib/include/public/mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* For version handshake check there is no mandatory requirement to update the $PATCH level.
* Ref. https://semver.org/ for Semantic Versioning documentation.
*/
#define TELEMETRY_EVENTS_VERSION "3.1.0"
#define TELEMETRY_EVENTS_VERSION "3.7.0"

#include "ctmacros.hpp"

Expand Down Expand Up @@ -59,7 +59,8 @@ extern "C" {
EVT_OP_FLUSH = 0x0000000A,
EVT_OP_VERSION = 0x0000000B,
EVT_OP_OPEN_WITH_PARAMS = 0x0000000C,
EVT_OP_MAX = EVT_OP_OPEN_WITH_PARAMS + 1
EVT_OP_MAX = EVT_OP_OPEN_WITH_PARAMS + 1,
EVT_OP_MAXINT = 0xFFFFFFFF
} evt_call_t;

typedef enum evt_prop_t
Expand All @@ -79,11 +80,13 @@ extern "C" {
TYPE_BOOL_ARRAY,
TYPE_GUID_ARRAY,
/* NULL-type */
TYPE_NULL
TYPE_NULL,
TYPE_MAXINT = 0xFFFFFFFF
} evt_prop_t;

typedef struct evt_guid_t
typedef struct MATSDK_PACKED_STRUCT evt_guid_t
{
MATSDK_PACK_PUSH
/**
* <summary>
* Specifies the first eight hexadecimal digits of the GUID.
Expand Down Expand Up @@ -111,19 +114,22 @@ extern "C" {
* </summary>
*/
uint8_t Data4[8];
MATSDK_PACK_POP
} evt_guid_t;

typedef int64_t evt_handle_t;
typedef int32_t evt_status_t;
typedef struct evt_event evt_event;

typedef struct evt_context_t
typedef struct MATSDK_PACKED_STRUCT evt_context_t
{
MATSDK_PACK_PUSH
evt_call_t call; /* In */
evt_handle_t handle; /* In / Out */
void* data; /* In / Out */
evt_status_t result; /* Out */
uint32_t size; /* In / Out */
MATSDK_PACK_POP
} evt_context_t;

/**
Expand Down Expand Up @@ -183,12 +189,14 @@ extern "C" {
uint64_t** as_arr_time;
} evt_prop_v;

typedef struct evt_prop
typedef struct MATSDK_PACKED_STRUCT evt_prop
{
MATSDK_PACK_PUSH
const char* name;
evt_prop_t type;
evt_prop_v value;
uint32_t piiKind;
MATSDK_PACK_POP
} evt_prop;

/**
Expand Down
Loading