-
Notifications
You must be signed in to change notification settings - Fork 308
Expand file tree
/
Copy pathflcore_native.h
More file actions
60 lines (51 loc) · 1.92 KB
/
flcore_native.h
File metadata and controls
60 lines (51 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <cstdint>
#include <type_traits>
#ifndef FL_CDECL
#ifdef _WIN32
#define FL_CDECL __cdecl
#else
#define FL_CDECL
#endif
#endif
extern "C"
{
// Layout must match C# structs exactly
#pragma pack(push, 8)
struct RequestBuffer {
const void* Command;
int32_t CommandLength;
const void* Data;
int32_t DataLength;
};
struct ResponseBuffer {
void* Data;
int32_t DataLength;
void* Error;
int32_t ErrorLength;
};
// Callback signature: int32_t(*)(const void* data, int length, void* userData)
// Return 0 to continue, 1 to cancel.
using UserCallbackFn = int32_t(FL_CDECL*)(const void*, int32_t, void*);
struct StreamingRequestBuffer {
const void* Command;
int32_t CommandLength;
const void* Data;
int32_t DataLength;
const void* BinaryData;
int32_t BinaryDataLength;
};
// Exported function pointer types
using execute_command_fn = void(FL_CDECL*)(RequestBuffer*, ResponseBuffer*);
using execute_command_with_callback_fn = void(FL_CDECL*)(RequestBuffer*, ResponseBuffer*,
UserCallbackFn /*callback*/,
void* /*userData*/);
using execute_command_with_binary_fn = void(FL_CDECL*)(StreamingRequestBuffer*, ResponseBuffer*);
using free_response_fn = void(FL_CDECL*)(ResponseBuffer*);
static_assert(std::is_standard_layout<RequestBuffer>::value, "RequestBuffer must be standard layout");
static_assert(std::is_standard_layout<ResponseBuffer>::value, "ResponseBuffer must be standard layout");
static_assert(std::is_standard_layout<StreamingRequestBuffer>::value, "StreamingRequestBuffer must be standard layout");
#pragma pack(pop)
}