Commit 7d1ccade authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 6.0.6

parent 8f7aae39
Loading
Loading
Loading
Loading

AISC_COM/AISC/aisc.pa

0 → 100644
+206 −0
Original line number Diff line number Diff line
GOTO main

FUNCTION struct_contents
    CREATE $(pre)
    CREATE $(suf)

    FOR $({/TYPE)
        IF $(TYPE) = dllh
            # dllh is "added" as base class by caller  
        ELSEIF $(REF) ~ %
        ELSE
            SET $(pre)
            SET $(suf)
            IF $(REF) ~ *
                SET $(pre) *
            ELSEIF $(REF) ~ v
                SET $(suf) [$(SIZE|NO SIZE DEFINED)]
            ENDIF
            IF $(REF) ~ d
                P dll_public$|  p$(IDENT);
            ENDIF
            IF $(REF) ~ d,r,l,o
                SET $(pre) $(pre)*
            ENDIF
            P $(TYPE|NO TYPE FOUND)$\
            # align '  name' ' *name' '**name'
            SET $(pre) '$(pre)'
            P $|$(pre:''=  :'*'= *:'**'=**:'=)$(IDENT)$(suf);$\
            P $| // $(DOCU| *** )
        ENDIF
    ENDFOR
RETURN

FUNCTION define_type
    P struct $(STRUCT) $\
    FOR $({/TYPE.dllh)
        P : public dll<$(STRUCT)> $\
    ENDFOR
    P { // $(SDOCU|$(STRUCT))
    INDENT +1
        CALL struct_contents
    INDENT -1
    P };
RETURN

FUNCTION datatypes
    P // forward decl dll types
    P struct dllpublic_ext;
    P struct dllheader_ext;
    --

    FOR $(STRUCT.dll_public)
    NEXT
        ERROR mandatory STRUCT 'dll_public' is missing
    ENDFOR
    FOR $(STRUCT.dll_header)
    NEXT
        ERROR mandatory STRUCT 'dll_header' is missing
    ENDFOR

    P // "public" version of dll
    FOR $(STRUCT.dll_public)
        CALL define_type
    ENDFOR
    FOR $(STRUCT.dll_header)
        CALL define_type
    ENDFOR
    --

    P template <typename USERTYPE>
    P struct dll {
    INDENT +1
        P dll_header  mh; // ***ANOTHEROLIHACK**
        P USERTYPE   *previous, *next;
        P int get_count() const { return mh.parent ? mh.parent->cnt : 0; }
    INDENT -1
    P };
    --

    P // "private" (i.e. real) version of dll (DoubledLinkedList)
    P struct dllpublic_ext : public dll_public { 
    INDENT +1
        P dllheader_ext$| *first; 
    INDENT -1
    P };
    P // pseudo-base-class of dll<USERTYPE> (bit-equal)
    P struct dllheader_ext : dll<dllheader_ext> {}; // pseudo-base-class of dll<USERTYPE> (bit-equal)
    --

    P // forward decl user datatypes
    FOR $(STRUCT)
        IF $(STRUCT) ~ dll_header,dll_public
        ELSE
            P struct $(STRUCT);
        ENDIF
    ENDFOR
    --

    P // user defined datatypes
    FOR $(STRUCT)
        IF $(STRUCT) ~ dll_header,dll_public
        ELSE
            CALL define_type
        ENDIF
    ENDFOR
    --

RETURN

FUNCTION constants
    IF $(CONST)
        P // some constants
        FOR $(CONST)
            P #define $(CONST) $|$(VALUE) $|// $(DOCU)
        ENDFOR
        --
    ENDIF
RETURN

FUNCTION enums
    IF $(ENUM)
        ERROR never used before - please check generated code
        P // the enums
        FOR $(ENUM)
            P $n// $(SDOCU|$(ENUM))
            P typedef enum enum_$(ENUM) {
            INDENT +1
                FOR $({/VAR)
                    IF $(VAL)
                        P $(VAR)$| = $|$(VAL),$\
                    ELSE
                        P $(VAR),$|$\
                    ENDIF
                    IF $(DOCU)
                        P $|// $(DOCU)
                    ELSE
                        P 
                    ENDIF
                ENDFOR
            INDENT -1
            P } $(ENUM);
        ENDFOR
        --
    ENDIF
RETURN

FUNCTION keys
    P // the keys
    P typedef enum enum_t_key {
    INDENT +1
        FOR $(STRUCT)
            IF $(JOINED)
            ELSEIF $(SKEY)
                P KEY_$(OBJECT_KEY)_$(SKEY)$| = $|0x10000*$(SKEYC),
            ENDIF
        ENDFOR
        P KEY_MAX
    INDENT -1
    P } t_key;
    --
RETURN

# --------------------------------------------------------------------------------

LABEL main
IF $(argc) != 4
    ERROR Wrong number of parameters[$(argc)]. Usage: aisc aisc.pa xxx.aisc outfile
ENDIF

DATA AISC { $(#FILE $(argv[2])) };
DUMPDATA DUMP/aisc.pa__$(argv[2]).dump
MOVETO $(/AISC/DATA/.)

OPEN save $(argv[3])
OUT save

P // -----------------------------------------------------------------
P // Created automagically from ../$(argv[2])
P // using aisc-script '../AISC/aisc.pa'
P // DO NOT EDIT THIS FILE!!!
P // -----------------------------------------------------------------
--
P #ifndef AISC_GEN_SERVER_INCLUDED
P #define AISC_GEN_SERVER_INCLUDED
--
P typedef char       *aisc_string;
P typedef const char *aisc_cstring;
--
P #ifndef AISC_GLOBAL_H
P #include <aisc_global.h>
P #endif
P $(INCLUDE_INCLUDES)
--
CALL constants
CALL enums
CALL keys
CALL datatypes
P extern const char *aisc_server_error;
--

P #else 
P #error header included twice 
P #endif // AISC_GEN_SERVER_INCLUDED
CLOSE save
EXIT
+196 −0
Original line number Diff line number Diff line
IF $(argc) != 4
    ERROR Wrong number of parameters[$(argc)]. Usage: aisc aisc_com.pa xxx.aisc outfile
ENDIF

DATA AISC { $(#FILE $(argv[2])) };
DUMPDATA DUMP/aisc_com.pa__$(argv[2]).dump

OPEN save $(argv[3])
MOVETO $(AISC/PROJECT)

OUT save
MOVETO $(DATA/.)

P /* -----------------------------------------------------------------
P  * Created automagically from ../$(argv[2])
P  * using aisc-script '../AISC/aisc_com.pa'
P  * DO NOT EDIT THIS FILE!!!
P  * ----------------------------------------------------------------- */$n

P #ifndef _LIMITS_H
P #include <limits.h>
P #endif
P #ifndef AISC_GLOBAL_H
P #include <aisc_global.h>
P #endif

P #ifndef AISC_MAX_OBJECT
P # define AISC_MAX_OBJECT         $(MAX_OBJECT)
P # define AISC_MAX_ATTR           $(MAX_KEY)
P # define MAX_AISC_SET_GET        $(MAX_PAR_CNT)
P # define AISC_MAX_STRING_LEN     $(MAX_STRING_LEN)
P # define AISC_MESSAGE_BUFFER_LEN ((AISC_MAX_STRING_LEN/4+3)*($(MAX_PAR_CNT)+2))
P # define AISC_MAGIC_NUMBER       $(MAGIC_NUMBER)00
--
P struct aisc_com;
--
P const int AISC_GET $|= AISC_MAGIC_NUMBER+0;
P const int AISC_SET $|= AISC_MAGIC_NUMBER+1;
P const int AISC_NSET $|= AISC_MAGIC_NUMBER+2;
P const int AISC_CREATE $|= AISC_MAGIC_NUMBER+3;
P const int AISC_FIND $|= AISC_MAGIC_NUMBER+4;
P const int AISC_COPY $|= AISC_MAGIC_NUMBER+5;
P const int AISC_DELETE $|= AISC_MAGIC_NUMBER+6;
P const int AISC_INIT $|= AISC_MAGIC_NUMBER+7;
P const int AISC_DEBUG_INFO $|= AISC_MAGIC_NUMBER+8;
--
P const int AISC_CCOM_OK $|= AISC_MAGIC_NUMBER+0;
P const int AISC_CCOM_ERROR $|= AISC_MAGIC_NUMBER+1;
P const int AISC_CCOM_MESSAGE $|= AISC_MAGIC_NUMBER+2;
--
P #endif
--
FOR $(ENUM)
    IF $(SKEY)
        CREATE $(my_attribute[$(ENUM)]) $(OBJECT_KEY)_ATTR_$(SKEY)
    ENDIF
ENDFOR
--
P #define $(OBJECT_KEY)_ATTR_INT(a,b) $|(((a)+(b))|0x1000000)
FOR $(ENUM)
    IF $(SKEY)
        P #define $(OBJECT_KEY)_ATTR_$(SKEY)(a,b) $|(((a)+(b))|0x1000000)
    ENDIF
ENDFOR
P #define $(OBJECT_KEY)_ATTR_DOUBLE(a,b) $|(((a)+(b))|0x2000000)
P #define $(OBJECT_KEY)_ATTR_STRING(a,b) $|(((a)+(b))|0x3000000)
CREATE $(my_attribute[char]) $(OBJECT_KEY)_ATTR_INT
CREATE $(my_attribute[int]) $(OBJECT_KEY)_ATTR_INT
CREATE $(my_attribute[func]) $(OBJECT_KEY)_ATTR_INT
CREATE $(my_attribute[t_key]) $(OBJECT_KEY)_ATTR_INT
CREATE $(my_attribute[dllheader_ext]) $(OBJECT_KEY)_ATTR_INT
CREATE $(my_attribute[double]) $(OBJECT_KEY)_ATTR_DOUBLE
CREATE $(my_attribute[aisc_string]) $(OBJECT_KEY)_ATTR_STRING
CREATE $(my_attribute[bytestring]) $(OBJECT_KEY)_ATTR_BYTES
FOR $(STRUCT)
    IF $(JOINED)
    ELSEIF $(SKEY)
        P #define $(OBJECT_KEY)_ATTR_$(SKEY)(a,b) $|(((a)+(b))|0x4000000)
        CREATE $(my_attribute[$(STRUCT)]) $(OBJECT_KEY)_ATTR_$(SKEY)
    ENDIF
ENDFOR
P #define $(OBJECT_KEY)_ATTR_BYTES(a,b) $|(((a)+(b))|0x5000000)
--
P enum Aisc_Object_Type {
INDENT +1
    FOR $(STRUCT)
        IF $(JOINED)
        ELSEIF $(SKEY)
            P $(OBJECT_KEY)_$(SKEY) $|= 0x10000*$(SKEYC),
        ENDIF
    ENDFOR
    P $(OBJECT_KEY)_MAX $|= 0x10000*$(MAX_OBJECT),
    P $(OBJECT_KEY)_INDEX $|= 0x10000*0x1ff
INDENT -1
P };
--
FOR $(STRUCT)
    IF $(JOINED)
    ELSEIF $(SKEY)
        P struct T_$(OBJECT_KEY)_$(SKEY) : public AISC_Object {
        INDENT +1
        P T_$(OBJECT_KEY)_$(SKEY)() : AISC_Object($(OBJECT_KEY)_$(SKEY)) {}
        P void assign(const T_$(OBJECT_KEY)_$(SKEY)& o) { set(o.type(), o.get()); }
        INDENT -1
        P };
    ENDIF
ENDFOR
--

CREATE $(A)
CREATE $(add) 0
CREATE $(str) 0
CREATE $(skey) 0
CREATE $(struct) 0
CREATE $(com)

FOR $(STRUCT)
    IF $(SKEY)
        PUSH
        IF $(JOINED)
        ELSE
            P enum $(OBJECT_KEY)_$(SKEY)_Attribute { // $(SKEY)
            INDENT +1
        ENDIF
        SET $(skey) $(SKEY)
        SET $(struct) $(STRUCT)
        CALL insert_struct_attributes,0,$(SKEY)_,//
        IF $(JOIN_NEXT)
        ELSE
            P $(SKEY)_FORCELONG $|= LONG_MAX
            INDENT -1
            P };
            --
        ENDIF
        POP
    ENDIF
ENDFOR
CLOSE save

EXIT

FUNCTION insert_struct_attributes,a,s,c
    FOR $({/TYPE)
        IF $(KEY)
            IF $(TYPE) = dllh
                P $(s)PRED $|= $\
                P $(my_attribute[$(struct)])$\
                P $|($(OBJECT_KEY)_$(skey), $(+ $(a)+$(KEYC))), $|// DO

                P $(s)NEXT $|= $\
                P $(my_attribute[$(struct)])$\
                P $|($(OBJECT_KEY)_$(skey), $(+ 1+$(+ $(a)+$(KEYC)))), $|$(c)

                SET $(add) $(+ $(a)+$(KEYC))
                SET $(add) $(+ 2+$(add))
                SET $(str) $(s)$(KEY)
                PUSH
                MOVETO $(/AISC/DATA/STRUCT.dll_header)
                CALL insert_struct_attributes,$(add),$(str),$(c) H
                POP
            ELSEIF $(REF) ~ s
                SET $(add) $(+ $(a),$(KEYC))
                SET $(str) $(s)$(KEY)
                SET $(com) $(c) S
                PUSH
                MOVETO $(/AISC/DATA/STRUCT.$(TYPE))
                CALL insert_struct_attributes,$(add),$(str),$(com)
                POP
            ELSE
                IF $(REF) ~ d
                    SET $(com) $(c) DL
                ELSEIF $(REF) ~ v
                    SET $(com) $(c) [$(SIZE)]
                ELSEIF $(REF) ~ *
                    SET $(com) $(c) []
                ELSEIF $(TYPE) = func
                    SET $(com) $(c) FUNC
                ELSE
                    SET $(com) $(c)
                ENDIF
                IF $(my_attribute[$(TYPE)])
                    P $(s)$(KEY) $|= $\
                    P $(my_attribute[$(TYPE)])$\
                    P $|($(OBJECT_KEY)_$(skey), $(+ $(a)+$(KEYC))), $|$(com)
                ELSE
                    ERROR TYPE $(TYPE) unknown, no key build
                ENDIF
                IF $(REF) ~ d
                    P $(s)$(KEY)_CNT $|= $\
                    P $(my_attribute[int])$\
                    P $|($(OBJECT_KEY)_$(skey), $(+ 1,$(+ $(a)+$(KEYC)))), $|$(com)
                ENDIF
            ENDIF
        ENDIF
    ENDFOR
RETURN
+203 −0
Original line number Diff line number Diff line
IF $(argc) < 5
    ERROR Wrong number of parameters[$(argc)]. Usage: aisc aisc_global.pa xxx.aisc outfile extern_file
ENDIF

DATA AISC { $(#FILE $(argv[2])) };
DUMPDATA DUMP/aisc_global.pa__$(argv[2]).dump
OPEN save $(argv[3])

MOVETO $(AISC/PROJECT)
CREATE $(pre) = $(OBJECT_KEY)_
CREATE $(max_key) = $(MAX_KEY)
CREATE $(max_obj) = $(MAX_OBJECT)
CREATE $(i)
CREATE $(termlist) = $10$n};$n

OUT save

MOVETO $(DATA/.)

P /* -----------------------------------------------------------------
P  * Created automagically from ../$(argv[2]) 
P  *                       and ../$(argv[4])
P  * using aisc-script '../AISC/aisc_global.pa'
P  * DO NOT EDIT THIS FILE!!!
P  * ----------------------------------------------------------------- */
--
P #include <aisc_server.h>
--

# create and clear obj and key list
FOR $(i) = 0 TO $(max_obj)
    CREATE $(obj[$(i)]) = 0,
ENDFOR
FOR $(i) = 0 TO $(max_key)
    CREATE $(key[$(i)]) = 0,
ENDFOR

# generate object names struct
FOR $(STRUCT)
    IF $(SKEY)
        IF $(obj[$(SKEYC)])
            SET $(obj[$(SKEYC)]) = "$(pre)$(SKEY)",
        ELSE
            ERROR Increase definition of MAX_OBJECT to $(SKEYC)
        ENDIF
    ENDIF
ENDFOR

P const char *aisc_object_names[] = {
GOSUB printobjlist
P $(termlist)

# generate attribute names structs
CREATE $(nummer)
CREATE $(aisc_string)
FOR $(STRUCT)
    IF $(SKEY)
        GOSUB clearkeylist
        SET $(nummer) = 0
        SET $(aisc_string) = $(pre)$(SKEY)_
        P static const char *$(pre)$(STRUCT)_attribute_names[] = {
        GOSUB make_attr_names
        GOSUB printkeylist
        P $(termlist)
    ENDIF
ENDFOR
P $n

# generate attribute names struct list
GOSUB clearobjlist
P const char *aisc_attribute_names_list[] = {
FOR $(STRUCT)
    IF $(SKEY)
        SET $(obj[$(SKEYC)]) = (const char *)$(pre)$(STRUCT)_attribute_names,
    ENDIF
ENDFOR
GOSUB printobjlist
P $(termlist)

# generate function structs
P typedef int* (*talking_function)(int *x, ...);
P typedef talking_function *talking_function_ptr;
--
FOR $(STRUCT)
    P extern talking_function aisc_talking_functions_create_$(STRUCT)[];
    P extern int *((*(aisc_talking_functions_get_$(STRUCT)[]))());
    P extern int *((*(aisc_talking_functions_find_$(STRUCT)[]))());
    P extern int *((*(aisc_talking_functions_copy_$(STRUCT)[]))());
    P extern int ((*(aisc_talking_functions_set_$(STRUCT)[]))());
    --
ENDFOR

# generate d flags
P int aisc_d_flags[] = {
GOSUB clearkeylist
FOR $(STRUCT)
    IF $(SKEY)
        SET $(i) = 0
        FOR $({/TYPE)
            IF $(TYPE) = dllh
                SET $(i) = 1
            ENDIF
        ENDFOR
        SET $(key[$(SKEYC)]) = $(i),$6// $(SKEY)
    ENDIF
ENDFOR
GOSUB printkeylist
P $(termlist)

# generate callback tables
P int *((**(aisc_talking_functions_get[]))()) = {
GOSUB print_talking_table,aisc_talking_functions_get_

P int ((**(aisc_talking_functions_set[]))()) = {
GOSUB print_talking_table,aisc_talking_functions_set_

P int *((**(aisc_talking_functions_find[]))()) = {
GOSUB print_talking_table,aisc_talking_functions_find_

P int *((**(aisc_talking_functions_copy[]))()) = {
GOSUB print_talking_table,aisc_talking_functions_copy_

P talking_function* aisc_talking_functions_create[] = {
GOSUB print_talking_table,aisc_talking_functions_create_

P aisc_destroy_callback aisc_talking_functions_delete[] = {
GOSUB print_talking_table_casted,destroy_,(aisc_destroy_callback)

# FINISH
P #undef __P
CLOSE save
EXIT

# ----------------- 
#     FUNCTIONS     

FUNCTION print_talking_table,name
    CALL print_talking_table_casted,$(name),
RETURN

FUNCTION print_talking_table_casted,name,cast
    GOSUB clearkeylist
    FOR $(STRUCT)
        IF $(SKEY)
            SET $(key[$(SKEYC)]) = $(cast)$(name)$(STRUCT),
        ENDIF
    ENDFOR
    GOSUB printkeylist
    P $(termlist)
RETURN

FUNCTION make_attr_names
    CREATE $(nr) = $(nummer)
    CREATE $(s) = $(aisc_string)
    FOR $({/TYPE)
        IF $(KEY)
            IF $(REF) ~ s
                PUSH
                SET $(nummer) = $(+ $(nr)+$(KEYC) )
                SET $(aisc_string) = $(s)$(KEY)_
                MOVETO $(/AISC/DATA/STRUCT.$(TYPE))
                GOSUB make_attr_names
                POP
            ELSEIF $(REF) ~ d
                SET $(key[$(+ $(+ $(nr)+1)+$(KEYC))])="$(s)$(KEY)CNT",
                SET $(key[$(+ $(nr)+$(KEYC))]) = "$(s)$(KEY)",
            ELSEIF $(TYPE) = dllh
                PUSH
                SET $(nummer) = $(+ 2+$(+ $(nr)+$(KEYC) ))
                SET $(aisc_string) = $(s)$(KEY)
                MOVETO $(/AISC/DATA/STRUCT.dll_header)
                GOSUB make_attr_names
                POP
                SET $(key[$(+ $(nr)+0)]) = "$(s)PREVIOUS",
                SET $(key[$(+ $(nr)+1)]) = "$(s)NEXT",
            ELSE
                SET $(key[$(+ $(nr)+$(KEYC))]) = "$(s)$(KEY)",
            ENDIF
        ENDIF
    ENDFOR
RETURN

FUNCTION clearkeylist
    FOR $(i) = 0 TO $(max_key)
        SET $(key[$(i)]) = 0,
    ENDFOR
RETURN
FUNCTION clearobjlist
    FOR $(i) = 0 TO $(max_obj)
        SET $(obj[$(i)]) = 0,
    ENDFOR
RETURN
FUNCTION printkeylist
    FOR $(i) = 0 TO $(max_key)
        P $1$(key[$(i)])
    ENDFOR
RETURN
FUNCTION printobjlist
    FOR $(i) = 0 TO $(max_obj)
        P $1$(obj[$(i)])
    ENDFOR
RETURN
+1157 −0

File added.

Preview size limit exceeded, changes collapsed.

+86 −0
Original line number Diff line number Diff line

format of .aisc-files used for client/server interfaces 
-------------------------------------------------------

PROJECT      string   // main name of program
OBJECT_KEY   string   // prefix key for objects
MAX_KEY      num      // maximum attribute number
MAX_OBJECT   num      // maximum object number
MAGIC_NUMBER num      // server version (see magic.lst)

DATA {          

@CONST, @VALUE, @DOCU; // constants

@ENUM;                  // enum is unused and obsolete
..., {;
        @VAR, @VAL, @DOCU;
};

@STRUCT, @SKEY, @SKEYC, @DOCU;

my_struxt, MYKEY, 4711, (~ This is the docu ~), [SAVEDIRECTION VERTICAL,] {
        @TYPE,  @IDENT, @REF, @ACC, @SAVE, @KEY, @KEYC, @INIT, @DOCU;
        ...;
};

};



TYPE can be:

        int,char,double,float

        dllh            header of DoubledLinkedList
        aisc_string     string
        bytestring      string

        // [func    function ]

        or any user defined type

REF can be:
        %               virtual (aka callback) 

                        unspecified ( double char .... )
eor     i               or owner by insertion
eor     o               owner by pointer
eor     d               special owner (double linked list with ident + hash)
eor     l               link
eor     r               reversed_link   (only to those objects with dllh)

        e               enum type
eor     t               terminal type
eor     s               structure type  /* unfold THIS structure else t */

[       *               resizeable vector of ...        (key SIZE is size)
eor     v               fixed   vector of ...           (key SIZE is size)]

[       f               forward reference                               ]
                                                        (THIS-> is father)

z.B.    os*     Vector of unfold substructures


ACC             Accessiongrants
        ,       read and write 
        r,      readonly
        w,      writeonly
        c,      createonly
        rw,     read and write
        privat,
        public,

SAVE    version number for load/save (if AISC_SAVE=YES)

KEY     key name

KEYC    key number

        Has to be unique inside each STRUCT.
        Keys w/o keynumbers exist, but are not accessible via interface.
        Several types use multiple KEYs (e.g. 'd' uses 2 keys (KEY and KEY+1)).

INIT    default value or call to init-funtion
        'THIS' is replaced by pointer to STRUCT 
Loading