ir: Handle NonZero and simplify Option<NonZero> like we simplify Option<NonNull>.
Fixes #646
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct Option_Option_NonZeroI64 Option_Option_NonZeroI64;
|
||||
|
||||
typedef struct NonZeroTest {
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const struct Option_Option_NonZeroI64 *j;
|
||||
} NonZeroTest;
|
||||
|
||||
void root(struct NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const struct Option_Option_NonZeroI64 *j);
|
||||
@@ -0,0 +1,52 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct Option_Option_NonZeroI64 Option_Option_NonZeroI64;
|
||||
|
||||
typedef struct NonZeroTest {
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const struct Option_Option_NonZeroI64 *j;
|
||||
} NonZeroTest;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(struct NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const struct Option_Option_NonZeroI64 *j);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,44 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct Option_Option_NonZeroI64 Option_Option_NonZeroI64;
|
||||
|
||||
typedef struct {
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const Option_Option_NonZeroI64 *j;
|
||||
} NonZeroTest;
|
||||
|
||||
void root(NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const Option_Option_NonZeroI64 *j);
|
||||
@@ -0,0 +1,52 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct Option_Option_NonZeroI64 Option_Option_NonZeroI64;
|
||||
|
||||
typedef struct {
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const Option_Option_NonZeroI64 *j;
|
||||
} NonZeroTest;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const Option_Option_NonZeroI64 *j);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,50 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
template<typename T = void>
|
||||
struct Option;
|
||||
|
||||
struct NonZeroTest {
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const Option<Option<NonZeroI64>> *j;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
void root(NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const Option<Option<NonZeroI64>> *j);
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,47 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
|
||||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
|
||||
cdef extern from *:
|
||||
ctypedef bint bool
|
||||
ctypedef struct va_list
|
||||
|
||||
cdef extern from *:
|
||||
|
||||
ctypedef struct Option_Option_NonZeroI64:
|
||||
pass
|
||||
|
||||
ctypedef struct NonZeroTest:
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const Option_Option_NonZeroI64 *j;
|
||||
|
||||
void root(NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const Option_Option_NonZeroI64 *j);
|
||||
@@ -0,0 +1,44 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Option_Option_NonZeroI64;
|
||||
|
||||
struct NonZeroTest {
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const struct Option_Option_NonZeroI64 *j;
|
||||
};
|
||||
|
||||
void root(struct NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const struct Option_Option_NonZeroI64 *j);
|
||||
@@ -0,0 +1,52 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct Option_Option_NonZeroI64;
|
||||
|
||||
struct NonZeroTest {
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const struct Option_Option_NonZeroI64 *j;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(struct NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const struct Option_Option_NonZeroI64 *j);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,47 @@
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
|
||||
|
||||
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
|
||||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
|
||||
cdef extern from *:
|
||||
ctypedef bint bool
|
||||
ctypedef struct va_list
|
||||
|
||||
cdef extern from *:
|
||||
|
||||
cdef struct Option_Option_NonZeroI64:
|
||||
pass
|
||||
|
||||
cdef struct NonZeroTest:
|
||||
uint8_t a;
|
||||
uint16_t b;
|
||||
uint32_t c;
|
||||
uint64_t d;
|
||||
int8_t e;
|
||||
int16_t f;
|
||||
int32_t g;
|
||||
int64_t h;
|
||||
int64_t i;
|
||||
const Option_Option_NonZeroI64 *j;
|
||||
|
||||
void root(NonZeroTest test,
|
||||
uint8_t a,
|
||||
uint16_t b,
|
||||
uint32_t c,
|
||||
uint64_t d,
|
||||
int8_t e,
|
||||
int16_t f,
|
||||
int32_t g,
|
||||
int64_t h,
|
||||
int64_t i,
|
||||
const Option_Option_NonZeroI64 *j);
|
||||
@@ -0,0 +1,30 @@
|
||||
use std::num::*;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct NonZeroTest {
|
||||
pub a: NonZeroU8,
|
||||
pub b: NonZeroU16,
|
||||
pub c: NonZeroU32,
|
||||
pub d: NonZeroU64,
|
||||
pub e: NonZeroI8,
|
||||
pub f: NonZeroI16,
|
||||
pub g: NonZeroI32,
|
||||
pub h: NonZeroI64,
|
||||
pub i: Option<NonZeroI64>,
|
||||
pub j: *const Option<Option<NonZeroI64>>,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root(
|
||||
test: NonZeroTest,
|
||||
a: NonZeroU8,
|
||||
b: NonZeroU16,
|
||||
c: NonZeroU32,
|
||||
d: NonZeroU64,
|
||||
e: NonZeroI8,
|
||||
f: NonZeroI16,
|
||||
g: NonZeroI32,
|
||||
h: NonZeroI64,
|
||||
i: Option<NonZeroI64>,
|
||||
j: *const Option<Option<NonZeroI64>>,
|
||||
) {}
|
||||
@@ -0,0 +1,13 @@
|
||||
header = """
|
||||
#if 0
|
||||
''' '
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct NonZeroI64;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
' '''
|
||||
#endif
|
||||
"""
|
||||
Reference in New Issue
Block a user