Skip to content

Commit

Permalink
Update the example headers according to the new reliable order
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhenrymantilla committed Oct 14, 2021
1 parent 7c4e94b commit 5f46194
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 103 deletions.
102 changes: 51 additions & 51 deletions ffi_tests/generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,29 @@ namespace FfiTests {
public unsafe partial class Ffi {
private const string RustLib = "ffi_tests";
}
public struct foo_t {
#pragma warning disable 0169
private byte OPAQUE;
#pragma warning restore 0169
}

public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
Int32 read_foo (
foo_t /*const*/ * foo);
Int32 async_get_ft ();
}

public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
foo_t * new_foo ();
public enum SomeReprCEnum_t {
SomeVariant,
}

public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
void free_foo (
foo_t * foo);
void check_SomeReprCEnum (
SomeReprCEnum_t _baz);
}

[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public unsafe /* static */ delegate
void
void_foo_ptr_fptr (
foo_t * _0);
public enum Bar_t : byte {
A,
}

public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
void with_foo (
[MarshalAs(UnmanagedType.FunctionPtr)]
void_foo_ptr_fptr cb);
void check_bar (
Bar_t _bar);
}

/** \brief
Expand All @@ -79,30 +68,16 @@ void free_char_p (
byte * _string);
}

[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public unsafe /* static */ delegate
void
void_void_ptr_char_const_ptr_fptr (
void * _0,
byte /*const*/ * _1);

[StructLayout(LayoutKind.Sequential, Size = 16)]
public unsafe struct RefDynFnMut1_void_char_const_ptr_t {
public void * env_ptr;
[MarshalAs(UnmanagedType.FunctionPtr)]
public void_void_ptr_char_const_ptr_fptr call;
public struct foo_t {
#pragma warning disable 0169
private byte OPAQUE;
#pragma warning restore 0169
}

/** \brief
* Same as `concat`, but with a callback-based API to auto-free the created
* string.
*/
public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
void with_concat (
byte /*const*/ * fst,
byte /*const*/ * snd,
RefDynFnMut1_void_char_const_ptr_t cb);
void free_foo (
foo_t * foo);
}

[StructLayout(LayoutKind.Sequential, Size = 16)]
Expand All @@ -123,27 +98,52 @@ public unsafe partial class Ffi {

public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
Int32 async_get_ft ();
foo_t * new_foo ();
}

public enum SomeReprCEnum_t {
SomeVariant,
public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
Int32 read_foo (
foo_t /*const*/ * foo);
}

[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public unsafe /* static */ delegate
void
void_void_ptr_char_const_ptr_fptr (
void * _0,
byte /*const*/ * _1);

[StructLayout(LayoutKind.Sequential, Size = 16)]
public unsafe struct RefDynFnMut1_void_char_const_ptr_t {
public void * env_ptr;
[MarshalAs(UnmanagedType.FunctionPtr)]
public void_void_ptr_char_const_ptr_fptr call;
}

/** \brief
* Same as `concat`, but with a callback-based API to auto-free the created
* string.
*/
public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
void check_SomeReprCEnum (
SomeReprCEnum_t _baz);
void with_concat (
byte /*const*/ * fst,
byte /*const*/ * snd,
RefDynFnMut1_void_char_const_ptr_t cb);
}

public enum Bar_t : byte {
A,
}
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public unsafe /* static */ delegate
void
void_foo_ptr_fptr (
foo_t * _0);

public unsafe partial class Ffi {
[DllImport(RustLib, ExactSpelling = true)] public static unsafe extern
void check_bar (
Bar_t _bar);
void with_foo (
[MarshalAs(UnmanagedType.FunctionPtr)]
void_foo_ptr_fptr cb);
}


Expand Down
104 changes: 52 additions & 52 deletions ffi_tests/generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,42 @@
#ifdef __cplusplus
extern "C" {
#endif
typedef struct foo foo_t;


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

int32_t read_foo (
foo_t const * foo);
int32_t async_get_ft (void);

foo_t * new_foo (void);
/** \brief
* This is a `#[repr(C)]` enum, which leads to a classic enum def.
*/
typedef enum SomeReprCEnum {
/** \brief
* This is some variant.
*/
SOME_REPR_C_ENUM_SOME_VARIANT,
} SomeReprCEnum_t;

void free_foo (
foo_t * foo);
void check_SomeReprCEnum (
SomeReprCEnum_t _baz);

void with_foo (
void (*cb)(foo_t *));
/** \remark Has the same ABI as `uint8_t` **/
#ifdef DOXYGEN
typedef enum Bar
#else
typedef uint8_t Bar_t; enum
#endif
{
/** . */
BAR_A,
}
#ifdef DOXYGEN
Bar_t
#endif
;

void check_bar (
Bar_t _bar);

/** \brief
* Concatenate the two input strings into a new one.
Expand All @@ -44,22 +64,10 @@ char * concat (
void free_char_p (
char * _string);

typedef struct {

void * env_ptr;

void (*call)(void *, char const *);

} RefDynFnMut1_void_char_const_ptr_t;
typedef struct foo foo_t;

/** \brief
* Same as `concat`, but with a callback-based API to auto-free the created
* string.
*/
void with_concat (
char const * fst,
char const * snd,
RefDynFnMut1_void_char_const_ptr_t cb);
void free_foo (
foo_t * foo);

/** \brief
* `&'lt [T]` but with a guaranteed `#[repr(C)]` layout.
Expand Down Expand Up @@ -95,38 +103,30 @@ typedef struct {
int32_t const * max (
slice_ref_int32_t xs);

int32_t async_get_ft (void);
foo_t * new_foo (void);

/** \brief
* This is a `#[repr(C)]` enum, which leads to a classic enum def.
*/
typedef enum SomeReprCEnum {
/** \brief
* This is some variant.
*/
SOME_REPR_C_ENUM_SOME_VARIANT,
} SomeReprCEnum_t;
int32_t read_foo (
foo_t const * foo);

void check_SomeReprCEnum (
SomeReprCEnum_t _baz);
typedef struct {

/** \remark Has the same ABI as `uint8_t` **/
#ifdef DOXYGEN
typedef enum Bar
#else
typedef uint8_t Bar_t; enum
#endif
{
/** . */
BAR_A,
}
#ifdef DOXYGEN
Bar_t
#endif
;
void * env_ptr;

void check_bar (
Bar_t _bar);
void (*call)(void *, char const *);

} RefDynFnMut1_void_char_const_ptr_t;

/** \brief
* Same as `concat`, but with a callback-based API to auto-free the created
* string.
*/
void with_concat (
char const * fst,
char const * snd,
RefDynFnMut1_void_char_const_ptr_t cb);

void with_foo (
void (*cb)(foo_t *));


#ifdef __cplusplus
Expand Down

0 comments on commit 5f46194

Please sign in to comment.