You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.2 KiB
92 lines
2.2 KiB
// We are testing wrappers for the c-datatypes:
|
|
// * integral e.g (int) here
|
|
// * enum
|
|
// * c-string
|
|
// * struct
|
|
// Those are all considered POD-types
|
|
#ifndef LIBPEPDATATYPES_LIBC99_H
|
|
#define LIBPEPDATATYPES_LIBC99_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
typedef enum
|
|
{
|
|
OK,
|
|
ERROR
|
|
} C99_Status;
|
|
|
|
typedef enum
|
|
{
|
|
ONE,
|
|
TWO,
|
|
THREE
|
|
} C99_Enum;
|
|
|
|
|
|
typedef struct {
|
|
int i;
|
|
int* pi;
|
|
} C99_C;
|
|
C99_C* c99_C_new();
|
|
void c99_C_free(C99_C* c);
|
|
|
|
typedef struct {
|
|
C99_C* c;
|
|
} C99_B;
|
|
C99_B* c99_B_new();
|
|
void c99_B_free(C99_B* b);
|
|
|
|
|
|
typedef struct {
|
|
C99_B* b;
|
|
} C99_A;
|
|
C99_A* c99_A_new();
|
|
void c99_A_free(C99_A* a);
|
|
|
|
|
|
// calling conventions
|
|
// -------------------
|
|
// use
|
|
// readonly in parm, ownership remains with caller
|
|
// create/own a full instance -> operator const T*()
|
|
// const T* / T
|
|
C99_Status c99_use_basic(int basic);
|
|
C99_Status c99_use_struct(const C99_A* a);
|
|
C99_Status c99_use_string(const char* c_str);
|
|
|
|
// supply
|
|
// inout parm, ownership remains with caller
|
|
// the function changes the value of the object, but not the object itself
|
|
// create/own a full instance -> operator T*
|
|
// T*
|
|
C99_Status c99_supply_basic(int* basic);
|
|
C99_Status c99_supply_struct(C99_A* a);
|
|
C99_Status c99_supply_string(char** c_str);
|
|
|
|
// provide
|
|
// in parm, ownership goes to callee
|
|
// same as 'use', but ownership goes to callee
|
|
// create/own a full instance -> release ownership -> operator T*
|
|
// T / T* (release ownership)
|
|
C99_Status c99_provide_basic(int basic);
|
|
C99_Status c99_provide_struct(C99_A* a);
|
|
C99_Status c99_provide_string(char* c_str);
|
|
|
|
// return
|
|
// out parm, ownership goes to caller
|
|
// T** will not be freed by the function,
|
|
// create/own an empty instance -> operator T**
|
|
// T** (must not point to mem which has to be freed first)
|
|
C99_Status c99_return_basic(int** basic);
|
|
C99_Status c99_return_struct(C99_A** a);
|
|
C99_Status c99_return_string(char** c_str);
|
|
|
|
// create
|
|
// factory delivers this, ownership goes to caller
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|