Browse Source

Autogenerate the `operator_api.h` header file

tags/v0.0.0-test.4
Philipp Oppermann 3 years ago
parent
commit
a2fd5b0ebd
Failed to extract signature
8 changed files with 212 additions and 18 deletions
  1. +41
    -0
      Cargo.lock
  2. +1
    -1
      Cargo.toml
  3. +9
    -0
      apis/c/operator/Cargo.toml
  4. +6
    -0
      apis/c/operator/build.rs
  5. +148
    -16
      apis/c/operator/operator_api.h
  6. +0
    -0
      apis/c/operator/src/lib.rs
  7. +1
    -1
      apis/rust/operator/types/Cargo.toml
  8. +6
    -0
      apis/rust/operator/types/src/lib.rs

+ 41
- 0
Cargo.lock View File

@@ -835,6 +835,13 @@ dependencies = [
"dora-operator-api-types",
]

[[package]]
name = "dora-operator-api-c"
version = "0.1.0"
dependencies = [
"dora-operator-api-types",
]

[[package]]
name = "dora-operator-api-macros"
version = "0.1.0"
@@ -1156,6 +1163,17 @@ dependencies = [
"wasm-bindgen",
]

[[package]]
name = "ghost"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb19fe8de3ea0920d282f7b77dd4227aea6b8b999b42cdf0ca41b2472b14443a"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

[[package]]
name = "git-version"
version = "0.3.5"
@@ -1397,6 +1415,28 @@ version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e85a1509a128c855368e135cffcde7eac17d8e1083f41e2b98c58bc1a5074be"

[[package]]
name = "inventory"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0eb5160c60ba1e809707918ee329adb99d222888155835c6feedba19f6c3fd4"
dependencies = [
"ctor",
"ghost",
"inventory-impl",
]

[[package]]
name = "inventory-impl"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e41b53715c6f0c4be49510bb82dee2c1e51c8586d885abe65396e82ed518548"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

[[package]]
name = "ipnetwork"
version = "0.18.0"
@@ -2699,6 +2739,7 @@ name = "safer-ffi"
version = "0.1.0"
source = "git+https://github.com/getditto/safer_ffi.git#f69aeb1727bc2f2d68ea5de6bc887411bad12b0a"
dependencies = [
"inventory",
"libc",
"macro_rules_attribute",
"mini_paste",


+ 1
- 1
Cargo.toml View File

@@ -1,6 +1,6 @@
[workspace]
members = [
"apis/c/node",
"apis/c/*",
"apis/python/node",
"apis/rust/*",
"apis/rust/operator/macros",


+ 9
- 0
apis/c/operator/Cargo.toml View File

@@ -0,0 +1,9 @@
[package]
name = "dora-operator-api-c"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
description = "C API implemetation for Dora Operator"

[build-dependencies]
dora-operator-api-types = { path = "../../rust/operator/types" }

+ 6
- 0
apis/c/operator/build.rs View File

@@ -0,0 +1,6 @@
use std::path::Path;

fn main() {
dora_operator_api_types::generate_headers(Path::new("operator_api.h"))
.expect("failed to create operator_api.h");
}

+ 148
- 16
apis/c/operator/operator_api.h View File

@@ -1,18 +1,150 @@
/*! \file */
/*******************************************
* *
* File auto-generated by `::safer_ffi`. *
* *
* Do not manually edit this file. *
* *
*******************************************/

#ifndef __RUST_DORA_OPERATOR_API_C__
#define __RUST_DORA_OPERATOR_API_C__
#ifdef __cplusplus
extern "C" {
#endif


#include <stddef.h>
#include <stdint.h>

/** \brief
* Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
*/
typedef struct Vec_uint8 {
/** <No documentation available> */
uint8_t * ptr;

/** <No documentation available> */
size_t len;

/** <No documentation available> */
size_t cap;
} Vec_uint8_t;

/** <No documentation available> */
typedef struct DoraResult {
/** <No documentation available> */
Vec_uint8_t error;
} DoraResult_t;

/** <No documentation available> */
typedef struct DoraDropOperator {
/** <No documentation available> */
DoraResult_t (*drop_operator)(void *);
} DoraDropOperator_t;

/** <No documentation available> */
typedef struct InitResult {
/** <No documentation available> */
DoraResult_t result;

/** <No documentation available> */
void * operator_context;
} InitResult_t;

/** <No documentation available> */
typedef struct DoraInitOperator {
/** <No documentation available> */
InitResult_t (*init_operator)(void);
} DoraInitOperator_t;

/** <No documentation available> */
/** \remark Has the same ABI as `uint8_t` **/
#ifdef DOXYGEN
typedef
#endif
enum DoraStatus {
/** <No documentation available> */
DORA_STATUS_CONTINUE = 0,
/** <No documentation available> */
DORA_STATUS_STOP = 1,
}
#ifndef DOXYGEN
; typedef uint8_t
#endif
DoraStatus_t;

/** <No documentation available> */
typedef struct OnInputResult {
/** <No documentation available> */
DoraResult_t result;

/** <No documentation available> */
DoraStatus_t status;
} OnInputResult_t;

/** <No documentation available> */
typedef struct Metadata {
/** <No documentation available> */
Vec_uint8_t open_telemetry_context;
} Metadata_t;

/** <No documentation available> */
typedef struct Input {
/** <No documentation available> */
Vec_uint8_t id;

/** <No documentation available> */
Vec_uint8_t data;

/** <No documentation available> */
Metadata_t metadata;
} Input_t;

/** <No documentation available> */
typedef struct Output {
/** <No documentation available> */
Vec_uint8_t id;

/** <No documentation available> */
Vec_uint8_t data;

/** <No documentation available> */
Metadata_t metadata;
} Output_t;

/** \brief
* `Arc<dyn Send + Sync + Fn(A1) -> Ret>`
*/
typedef struct ArcDynFn1_DoraResult_Output {
/** <No documentation available> */
void * env_ptr;

/** <No documentation available> */
DoraResult_t (*call)(void *, Output_t);

/** <No documentation available> */
void (*release)(void *);

/** <No documentation available> */
void (*retain)(void *);
} ArcDynFn1_DoraResult_Output_t;

/** <No documentation available> */
typedef struct SendOutput {
/** <No documentation available> */
ArcDynFn1_DoraResult_Output_t send_output;
} SendOutput_t;

/** <No documentation available> */
typedef struct DoraOnInput {
/** <No documentation available> */
OnInputResult_t (*on_input)(Input_t const *, SendOutput_t, void *);
} DoraOnInput_t;


#ifdef __cplusplus
} /* extern \"C\" */
#endif

int dora_init_operator(void **operator_context);

void dora_drop_operator(void *operator_context);

int dora_on_input(
const char *id_start,
size_t id_len,
const char *data_start,
size_t data_len,
const int (*output_fn_raw)(const char *id_start,
size_t id_len,
const char *data_start,
size_t data_len,
const void *output_context),
void *output_context,
const void *operator_context);
#endif /* __RUST_DORA_OPERATOR_API_C__ */

+ 0
- 0
apis/c/operator/src/lib.rs View File


+ 1
- 1
apis/rust/operator/types/Cargo.toml View File

@@ -7,4 +7,4 @@ edition = "2021"

[dependencies.safer-ffi]
git = "https://github.com/getditto/safer_ffi.git"
features = ["proc_macros"]
features = ["proc_macros", "headers"]

+ 6
- 0
apis/rust/operator/types/src/lib.rs View File

@@ -104,3 +104,9 @@ pub enum DoraStatus {
Continue = 0,
Stop = 1,
}

pub fn generate_headers(target_file: &Path) -> ::std::io::Result<()> {
::safer_ffi::headers::builder()
.to_file(target_file)?
.generate()
}

Loading…
Cancel
Save