with-c-syntax

API Reference

with-c-syntax

with-c-syntax is a fun package which introduces the C language syntax into Common Lisp.

WITH-C-SYNTAX.CORE

with-c-syntax core package.
  • Condition WITH-C-SYNTAX-ERROR  (SIMPLE-ERROR)
    * Class Precedence List with-c-syntax-error, simple-error, ... * Description The type ~with-c-syntax-error~ consists of all errors in with-c-syntax system.
  • Condition WITH-C-SYNTAX-WARNING  (SIMPLE-WARNING)
    * Class Precedence List with-c-syntax-warning, simple-warning, ... * Description The type ~with-c-syntax-warning~ consists of all warnings in the with-c-syntax system.
  • Function FIND-STRUCT-SPEC (name)
    * Syntax ~find-struct-spec~ name => struct-spec * Arguments and Values - name :: a symbol - decl-spec :: a struct-spec instance, or nil. * Description Finds and returns a struct-spec. If no struct-specs are found, returns nil. * Affected By ~with-c-compilation-unit~.
  • Function ADD-STRUCT-SPEC (name sspec)
    * Syntax ~add-struct-spec~ name sspec => struct-spec * Arguments and Values - name :: a symbol. - sspec :: a struct-spec instance. - struct-spec :: a struct-spec instance. * Description Establishes a new struct-spec definition named ~name~. * Affected By ~with-c-compilation-unit~.
  • Function REMOVE-STRUCT-SPEC (name)
    * Syntax ~remove-struct-spec~ name => struct-spec * Arguments and Values - name :: a symbol - struct-spec :: a struct-specs instance, or nil. * Description Removes a struct-spec definition named ~name~. Returns the removed struct-spec definition. If no struct-specs are found, returns nil. * Affected By ~with-c-compilation-unit~.
  • Class STRUCT
    * Class Precedence List struct, standard-object, ... * Description A representation of C structs or unions.
    MEMBER-INDEX-TABLE   Reader: STRUCT-MEMBER-INDEX-TABLE
    MEMBER-VECTOR   Accessor: STRUCT-MEMBER-VECTOR
  • Function MAKE-STRUCT (spec-obj &rest init-args)
    * Syntax ~make-struct~ spec-obj &rest init-args => new-struct * Arguments and Values - spec-obj :: a symbol, or an instance of struct-spec. - init-args :: objects. - new-struct :: an instance of struct. * Description Makes a new struct instance based on the specification of ~spec-obj~. If ~spec-obj~ is a symbol, it must be a name of a globally defined struct or union. To define a struct or an union globally, use ~with-c-syntax~ and declare it in a toplevel of translation-unit. If ~spec-obj~ is an instance of struct-spec, it is used directly. ~init-args~ is used for initializing members of the newly created instance. If the number of ~init-args~ is less than the number of members, the rest members are initialized with the default values specified by the ~spec-obj~.
  • Function STRUCT-MEMBER (struct member-name)
    * Syntax ~struct-member~ struct member-name => object * Arguments and Values - struct :: an instance of struct - member-name :: a symbol - object :: an object * Description Returns the value of the member named ~member-name~ in the ~struct~.
  • Function (setf STRUCT-MEMBER) (val struct member-name)
    * Syntax (setf (~struct-member~ struct member-name) new-object) * Arguments and Values - struct :: an instance of struct - member-name :: a symbol - new-object :: an object * Description Sets the value of the member named ~member-name~ in the ~struct~.
  • Function FIND-TYPEDEF (name)
    * Syntax ~find-typedef~ name => decl-spec * Arguments and Values - name :: a symbol - decl-spec :: a decl-specs instance, or nil. * Description Finds and returns a typedef definition. If no typedefs are found, returns nil. * Affected By ~with-c-compilation-unit~.
  • Function ADD-TYPEDEF (name spec)
    * Syntax ~add-typedef~ name spec => decl-spec * Arguments and Values - name :: a symbol - spec :: a decl-specs instance, or a type specifier. - decl-spec :: a decl-specs instance. * Description Establishes a new typedef definition named ~name~. * Affected By ~with-c-compilation-unit~.
  • Function REMOVE-TYPEDEF (name)
    * Syntax ~remove-typedef~ name => decl-spec * Arguments and Values - name :: a symbol - decl-spec :: a decl-specs instance, or nil. * Description Removes a typedef definition named ~name~. Returns the removed typedef definition. If no typedefs are found, returns nil. * Affected By ~with-c-compilation-unit~.
  • Type PSEUDO-POINTER (&optional (pointee-type t))
    * Supertypes pseudo-pointer, fixnum, ... * Description The base type of internal representation of pointers in with-c-syntax. * Compound Type Specifier Syntax ~pseudo-pointer~ &optional (pointee-type t) * Compound Type Specifier Arguments - pointee-type :: the type of the object pointer by the pointer. * Compound Type Specifier Description This notation includes the type of the pointed object. * Notes At this stage, the ~pointee-type~ is ignored by the type system.
  • Macro WITH-PSEUDO-POINTER-SCOPE (nil &body body)
    * Syntax ~with-pseudo-pointer-scope~ () form* => result* * Arguments and Values - forms :: a implicit progn - results :: the values returned by the ~forms~ * Description Establishes a new environment for pseudo-pointers. A pointer made inside this macro is invalidated out of this.
  • Function INVALIDATE-ALL-PSEUDO-POINTERS
    * Syntax ~invalidate-all-pseudo-pointers~ <no arguments> => count * Arguments and Values - count :: an integer. * Description Invalidates all pseudo-pointers in the scope it called. This call doesn't effect pointers out of the ~with-pseudo-pointer-scope~. Returns the number of invalidates pointers. * See Also ~with-pseudo-pointer-scope~.
  • Function PSEUDO-POINTER-POINTABLE-P (obj)
    * Syntax ~pseudo-pointer-pointable-p~ object => boolean * Arguments and Values - object :: an object. - boolean :: a boolean. * Description Returns whether the ~object~ can be held by pseudo-pointers. * Notes At this version, this function returns t only if the ~object~ is a symbol, vector, or an array.
  • Function MAKE-PSEUDO-POINTER (pointee &optional (initial-offset 0))
    * Syntax ~make-pseudo-pointer~ pointee &optional initial-offset => pointer * Arguments and Values - pointee :: an object. - initial-offset :: an integer. default is 0. - pointer :: a newly allocated pseudo-pointer. * Description Makes and returns a new pseudo-pointer points ~pointee~. ~initial-offset~ is added to the ~pointer~ at making.
  • Function PSEUDO-POINTER-DEREFERENCE (p)
    * Syntax ~pseudo-pointer-dereference~ pointer => object * Arguments and Values - pointer :: a pseudo-pointer. - object :: an object. * Description Dereferences the ~pointer~ and returns the result.
  • Function (setf PSEUDO-POINTER-DEREFERENCE) (val p)
    * Syntax (setf (~pseudo-pointer-dereference~ pointer) new-value) * Arguments and Values - pointer :: a pseudo-pointer. - new-value :: an object. * Description Makes the ~pointer~ to point the ~new-value~ object.
  • Function PSEUDO-POINTER-INVALIDATE (p)
    * Syntax ~pseudo-pointer-invalidate~ pointer => boolean * Arguments and Values - pointer : a pseudo-pointer. - boolean :: a boolean. * Description Makes the ~pointer~ to point no objects. After that, calling ~pseudo-pointer-dereference~ to this pointer will be error.
  • Function FIND-PREPROCESSOR-MACRO (name case-spec)
    * Syntax ~find-preprocessor-macro~ name &optional case-spec => macro-def * Arguments and Values - name :: a string or symbol. - case-spec :: ~:upcase~, or nil. - macro-def :: a cons, which have ~name~ as its car, and macro definition as its cdr. * Description Finds and returns a preprocessor macro definition named ~name~. ~case-spec~ specifies for which case the macro is defined. If ~:upcase~ is specified, the macro is defined only for the ~:upcase~ reader. If nil, the macro is defined for all readtable-case. ** Matching rule - If ~name~ is a string, the matching functions is 'string='. Packages are ignored. - If ~name~ is a symbol, the matching functions is 'eq'. This is package-aware.
  • Function ADD-PREPROCESSOR-MACRO (name val &optional (case-spec nil))
    * Syntax ~add-preprocessor-macro~ name val &optional upcase-spec => macro-def * Arguments and Values - name :: a string or symbol. - val :: an object. - case-spec :: ~:upcase~, or nil. - macro-def :: a cons, which have ~name~ as its car, and macro definition as its cdr. * Description Establishes a new preprocessor macro. When the preprocessor finds a symbol matching ~name~, it is expanded by ~val~. ~case-spec~ specifies for which case the macro is defined. If ~:upcase~ is specified, the macro is defined only for the ~:upcase~ reader. If nil, the macro is defined for all readtable-case. * See Also ~find-preprocessor-macro~.
  • Function REMOVE-PREPROCESSOR-MACRO (name &optional (case-spec nil))
    * Syntax ~remove-preprocessor-macro~ name &optional upcase-spec => macro-def * Arguments and Values - name :: a string or symbol. - case-spec :: ~:upcase~, or nil. - macro-def :: a cons, which have ~name~ as its car, and macro definition as its cdr. * Description Removes a preprocessor macro named ~name~. ~case-spec~ specifies for which case the macro is defined. If ~:upcase~ is specified, the macro is defined only for the ~:upcase~ reader. If nil, the macro is defined for all readtable-case. * See Also ~find-preprocessor-macro~.
  • Function PREPROCESSOR (lis &optional (case-spec nil))
    * Syntax ~preprocessor~ list-of-tokens &key allow-upcase-keyword => preprocesed-list * Arguments and Values - list-of-tokens :: a list - case-spec :: ~:upcase~, or nil. - preprocesed-list :: a list * Description This function works like the C Preprocessor. ** Working. At this stage, all of the functionalities of the standard CPP are not implemented. Current working is below: - Concatenation of string literals. - Calling preprocessor macro (not recursive) Invoking preprocessor macros, defined by add-preprocessor-macro. This system is used for converting symbols denoting keywords of C belongs other packages to our package's one. - A dirty hack for 'typedef'. Automatically adds 'void ;' after each typedef declarations. This is a workaround for avoiding the problem between 'the lexer hack' and the look-aheading of cl-yacc. ~case-spec~ specifies which macro definitions are used. If ~:upcase~ is specified, macro definitions for ~:upcase~ reader is used additionally. ** Expansion - If ~val~ is nil, no expansion is done. The original symbol is left. - If ~val~ is a object not a function, it is used as an expansion. - If ~val~ is a function, the function is called, and the returned value is used for expansion. Arguments for the function are datum between the following ( symbol and the next ) symbol, delimited by , symbol. Example: If MAC is defined for a macro and its value is a function, this sequence MAC ( a , b b , c c c ) calls the function like: (funcall #'a-func-of-MAC '(a) '(b b) '(c c c)) * See Also ~find-preprocessor-macro~. * Notes - TODO: recursive expansion - The feature 'If ~val~ is nil, no expansion is done.' is for implementing the recursive expansion in the future. In CPP, an expanded macro is ignored in the next (recursive) expansion. So, if a macro was expanded, I will push (the-expanded-macro . nil), and call the preprocessor recursively.
  • Type ENUM
    Represents the enum type.
  • Macro GET-VARARGS (place)
    * Syntax ~get-varargs~ place => obj * Arguments and Values - place :: a place - obj :: a list * Description Sets the variadic arguments of the with-c-syntax function to the ~place~. If this is called outside of a variadic function, an error is signaled. * Notes This is not intended for calling directly. The ~va_start~ preprocessor macro uses this. When defining a variadic function, a macro has same name is locally established.
  • Macro WITH-C-SYNTAX (&whole whole (&key (keyword-case (readtable-case *readtable*)) (return :auto) (try-add-{} t)) &body body)
    * Syntax ~with-c-syntax~ (&key keyword-case entry-form try-add-{}) form* => result* * Arguments and Values - keyword-case :: one of ~:upcase~, ~:downcase~, ~:preserve~, or ~:invert~. The default is the current readtable case. - return :: ~:auto~, or a form - try-add-{} :: a boolean. - form :: form(s) interpreted by this macro. - results :: the values returned by the ~forms~ * Description This macro is a entry point of the with-c-syntax system. ~forms~ are interpreted as C syntax, executed, and return values. ~keyword-case~ specifies case sensitivity. Especially, if ~:upcase~ is specified, some case-insensitive feature is enabled for convenience. If ~return~ is ~:auto~, returns the last form's value if ~body~ is a simple compound statement, or returns NIL is ~body~ is a compilation unit. If it is not, its valus is inserted after the compilation result translation units. (This feature is intended to access 'static' variables.) If ~try-add-{}~ is t and an error occurred at parsing, with-c-syntax adds '{' and '}' into the head and tail of ~form~ respectively, and tries to parse again.
  • Variable *WITH-C-SYNTAX-READER-LEVEL*
    nil
    * Value Type a symbol or a fixnum. * Description Holds the reader level used by '#{' reader function. The value is one of 0, 1, 2, 3, ~:conservative~, ~:aggressive~, ~:overkill~, or ~:insane~. The default is nil, recognized as ~:overkill~. For inside '#{' and '}#', four syntaxes are defined. These syntaxes are selected by the infix parameter of the '#{' dispatching macro character. If it not specified, its default is this value. If you interest for what syntaxes are defined, Please see the 'reader.lisp'
  • Variable *WITH-C-SYNTAX-READER-CASE*
    nil
    * Value Type a symbol or nil * Description Holds the reader case used by '#{' reader function. When this is not nil, the specified case is used as the readtable-case inside '#{' and '}#', and the case is passed to the wrapping ~with-c-syntax~ form. When this is nil, the readtable-case of ~*readtable*~ at using '#{' is used.

WITH-C-SYNTAX.STDLIB

with-c-syntax libc package.
No exported symbols.

WITH-C-SYNTAX

with-c-syntax user package.
No exported symbols.

Also exports

  • WITH-C-SYNTAX.CORE:WITH-C-SYNTAX
  • WITH-C-SYNTAX.CORE:*WITH-C-SYNTAX-READER-CASE*
  • WITH-C-SYNTAX.CORE:*WITH-C-SYNTAX-READER-LEVEL*
  • WITH-C-SYNTAX.CORE:WITH-C-SYNTAX-READTABLE