eĿlipsis
a language independent preprocessor
 
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Loading...
Searching...
No Matches
ellipsis-str8.h File Reference
#include <uchar.h>
#include <stdio.h>
#include <string.h>
#include "ellipsis-error.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
Include dependency graph for ellipsis-str8.h:

Go to the source code of this file.

Data Structures

struct  ellipsis‿str8
 A structure with a flexible array member of base type ellipsis‿str8‿base. More...
 

Macros

#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...)
 
#define ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR, ...)
 
#define ELLIPSIS_CONTRACT_ICE_OR_TRUE(...)
 
#define ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...)
 
#define ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR, ...)
 
#define ELLIPSIS_STR8_CONSTRUCT(S)
 Construct a ellipsis‿str8 from a string literal and return a pointer to it.
 
#define ELLIPSIS_STR8_LITERAL   ELLIPSIS_STR8_LITERAL_LOCAL
 
#define ELLIPSIS_STR8_LITERAL_GLOBAL(N, ...)
 
#define ELLIPSIS_STR8_LITERAL_LOCAL(N, ...)
 Create a literal of type ellipsis‿str8, where the array component is initialized with the arguments.
 
#define ELLIPSIS_STR8_OVERLAY(N)
 
#define ELLIPSIS_STR8_STATIC(N, ...)
 
#define ELLIPSIS_STR8_STRING_LITERAL(S)
 Construct a ellipsis‿str8 const from a string literal.
 
#define ELLIPSIS_TEST_ICE(...)   (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr)
 
#define ELLIPSIS_TO_VOIDS(...)   ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__))))
 
#define STRINGIFY(...)   STRINGIFY_(__VA_ARGS__)
 
#define STRINGIFY_(...)   #__VA_ARGS__
 

Typedefs

typedef struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice
 

Variables

thread_local bool volatile ellipsis‿contracts‿ignore‿dynamic
 
thread_local bool volatile ellipsis‿contracts‿proceed‿dynamic
 
thread_local bool volatile ellipsis‿contracts‿verbose‿dynamic
 

Macro Definition Documentation

◆ ELLIPSIS_CONTRACT

#define ELLIPSIS_CONTRACT (   COUNT,
  COND,
  ACTION,
  VERB,
  CSTR,
  CTYPE,
  ... 
)
Value:
\
do { \
_Generic( \
default: ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE __VA_OPT__(,) __VA_ARGS__));\
} while(false)
struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice
Definition ellipsis-expression.c:24
#define __VA_OPT__
A pseudo macro that cannot be redefined.
Definition ellipsis-predefined.dirs:89
#define ELLIPSIS_TEST_ICE(...)
Definition ellipsis-str8.h:65
#define ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR,...)
Definition ellipsis-str8.h:73
#define ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE,...)
Definition ellipsis-str8.h:55

◆ ELLIPSIS_CONTRACT_CHECK_STATIC

#define ELLIPSIS_CONTRACT_CHECK_STATIC (   CTYPE,
  COND,
  CSTR,
  ... 
)
Value:
({\
static_assert(ELLIPSIS_CONTRACT_ICE_OR_TRUE(COND), \
"compile time violation of " CTYPE " " CSTR \
__VA_OPT__(", ") __VA_ARGS__ );\
})
#define ELLIPSIS_CONTRACT_ICE_OR_TRUE(...)
Definition ellipsis-str8.h:67

◆ ELLIPSIS_CONTRACT_ICE_OR_TRUE

#define ELLIPSIS_CONTRACT_ICE_OR_TRUE (   ...)
Value:
_Generic( \
ELLIPSIS_TEST_ICE(__VA_ARGS__), \
ellipsis‿contracts‿is_ice*: (__VA_ARGS__), \
default: true)
#define true
The constant true made accessible to the preprocessor.
Definition ellipsis-builtins.dirs:32

◆ ELLIPSIS_CONTRACT_IMPL

#define ELLIPSIS_CONTRACT_IMPL (   COUNT,
  COND,
  ACTION,
  VERB,
  CSTR,
  CTYPE,
  ... 
)
Value:
(((false) || (COND)) \
? (void)0 \
: (ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR __VA_OPT__(,) __VA_ARGS__) \
, ((false) \
? (void)0 \
: ACTION())))
#define ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR,...)
Definition ellipsis-str8.h:46

◆ ELLIPSIS_CONTRACT_VIOLATION

#define ELLIPSIS_CONTRACT_VIOLATION (   COUNT,
  VERB,
  CTYPE,
  CSTR,
  ... 
)
Value:
({\
static char const contract_format_ ## COUNT[] = \
__FILE__ ":" STRINGIFY(__LINE__) ": violation of " CTYPE " `" CSTR "`" __VA_OPT__(", ") __VA_ARGS__ "\n";\
(VERB \
? fputs(contract_format_ ## COUNT, stderr) \
: 0);\
})
#define __FILE__
The current source file as required by the C standard.
Definition ellipsis-builtins.dirs:21
#define __LINE__
The current physical source line as required by the C standard.
Definition ellipsis-builtins.dirs:24
#define STRINGIFY(...)
Definition ellipsis-str8.h:43

◆ ELLIPSIS_STR8_CONSTRUCT

#define ELLIPSIS_STR8_CONSTRUCT (   S)
related

Construct a ellipsis‿str8 from a string literal and return a pointer to it.

◆ ELLIPSIS_STR8_LITERAL

#define ELLIPSIS_STR8_LITERAL   ELLIPSIS_STR8_LITERAL_LOCAL

◆ ELLIPSIS_STR8_LITERAL_GLOBAL

#define ELLIPSIS_STR8_LITERAL_GLOBAL (   N,
  ... 
)
Value:
sizeof((ellipsis‿str8‿base[]){__VA_ARGS__ }) \
/sizeof(ellipsis‿str8‿base))) \
{\
.length = (N), \
.array = {__VA_ARGS__ }, \
}.fa)
#define ELLIPSIS_STR8_OVERLAY(N)
Definition ellipsis-str8.h:187

◆ ELLIPSIS_STR8_LITERAL_LOCAL

#define ELLIPSIS_STR8_LITERAL_LOCAL (   N,
  ... 
)
related

Create a literal of type ellipsis‿str8, where the array component is initialized with the arguments.

This results in an lvalue of type ellipsis‿str8 for an object that has static storage duration and that is const-qualified.

Most functions that are provided for ellipsis‿str8 need to be able to reallocate the structure, so they will produce an error on a literal that is created with this macro. A notable exception of this is ellipsis‿str8‿delete which will just do nothing on such an object.

Remarks
Because of current restrictions in C23 that constexpr compound literals may not be of union type, this is not yet provided as constexpr.

◆ ELLIPSIS_STR8_OVERLAY

#define ELLIPSIS_STR8_OVERLAY (   N)
Value:
union {\
struct {\
size_t const length;\
size_t const padding;\
unsigned const :(offsetof(ellipsis‿str8, array)-2*sizeof(size_t));\
ellipsis‿str8‿base array[N];\
};\
}
A structure with a flexible array member of base type ellipsis‿str8‿base.
Definition ellipsis-str8.h:150

◆ ELLIPSIS_STR8_STATIC

#define ELLIPSIS_STR8_STATIC (   N,
  ... 
)
Value:
(({\
static const ELLIPSIS_STR8_OVERLAY( \
sizeof((ellipsis‿str8‿base[]){__VA_ARGS__ }) \
/sizeof(ellipsis‿str8‿base)) \
__LOC_ID_1_1 = {\
.length = (N), \
.array = {__VA_ARGS__ }, \
};&__LOC_ID_1_1;})->fa)

◆ ELLIPSIS_STR8_STRING_LITERAL

#define ELLIPSIS_STR8_STRING_LITERAL (   S)
related

Construct a ellipsis‿str8 const from a string literal.

Use this as in

ellipsis‿str8 const* always = &ELLIPSIS_STR8_STRING_LITERAL("always");
__directive__ always
Always expand the code up to the next #end or #endif.
Definition directives.c:151

or

ellipsis‿str8 const* ulways = &ELLIPSIS_STR8_STRING_LITERAL(u8"ulways");
Remarks
Other than for ELLIPSIS_STR8_CONSTRUCT() the resulting lvalue has static storage duration and is const-qualified.
The argument should be an ordinary or UTF-8 string literal.

◆ ELLIPSIS_TEST_ICE

#define ELLIPSIS_TEST_ICE (   ...)    (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr)

◆ ELLIPSIS_TO_VOIDS

#define ELLIPSIS_TO_VOIDS (   ...)    ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__))))

◆ STRINGIFY

#define STRINGIFY (   ...)    STRINGIFY_(__VA_ARGS__)

◆ STRINGIFY_

#define STRINGIFY_ (   ...)    #__VA_ARGS__

Typedef Documentation

◆ ellipsis‿contracts‿is_ice

Variable Documentation

◆ ellipsis‿contracts‿ignore‿dynamic

thread_local bool volatile ellipsis‿contracts‿ignore‿dynamic
extern

◆ ellipsis‿contracts‿proceed‿dynamic

thread_local bool volatile ellipsis‿contracts‿proceed‿dynamic
extern

◆ ellipsis‿contracts‿verbose‿dynamic

thread_local bool volatile ellipsis‿contracts‿verbose‿dynamic
extern