No matching definitions.

c-dsl/typedef

src/c-dsl/typedef.tur
defn

c-field

(c-field [name :cstr type :cstr] :cstr)

format a single struct/union field declaration.

namefield name string
typeTurmeric type keyword or C type string

"C-type name;"

(c-field "x" ":int")    ; => "int32_t x;"
  (c-field "name" ":cstr") ; => "char* name;"

Since: P1

defn

c-defstruct

(c-defstruct [name :cstr fields :int] :cstr)

emit a typedef struct definition.

namestruct name string
fieldscons list of field declaration strings (from c-field)

"typedef struct {\n field1\n field2\n} name;"

(c-defstruct "Point"
    (cons (c-field "x" ":int") (cons (c-field "y" ":int") 0)))
  ; => "typedef struct {\n    int32_t x;\n    int32_t y;\n} Point;"

Since: P1

defn

c-defunion

(c-defunion [name :cstr fields :int] :cstr)

emit a typedef union definition.

nameunion name string
fieldscons list of field declaration strings (from c-field)

"typedef union {\n field1\n ...\n} name;"

(c-defunion "Value"
    (cons (c-field "i" ":int") (cons (c-field "f" ":float") 0)))

Since: P1

defn

c-defenum

(c-defenum [name :cstr variants :int] :cstr)

emit a typedef enum definition.

nameenum name string
variantscons list of variant name strings

"typedef enum {\n VAR1,\n VAR2\n} name;"

(c-defenum "Color" (cons "RED" (cons "GREEN" (cons "BLUE" 0))))
  ; => "typedef enum {\n    RED,\n    GREEN,\n    BLUE\n} Color;"

Since: P1

defn

c-typedef

(c-typedef [type :cstr alias :cstr] :cstr)

emit a typedef alias declaration.

typeoriginal C type string (e.g. "int32_t*" or "void(*)(int32_t)")
aliasnew type name string

"typedef type alias;"

(c-typedef "int32_t*" "IntPtr")  ; => "typedef int32_t* IntPtr;"

Since: P1