pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:90:   struct define_struct;   typedef void (*magic_define_fun)(struct CPP_struct *,    struct define_struct *,    struct pike_string *,    struct string_builder *);      DECLARATIONS;      #define CPP_MACRO_DISABLED 1 /* Don't expand. */   #define CPP_MACRO_IN_USE 2 /* In use. */ + #define CPP_MACRO_VARARGS 4 /* Varargs. */      /*! @class Stack    *! This class implements a simple stack. Instead of adding and removing    *! elements to an array, and thus making it vary in size for every push    *! and pop operation, this stack tries to keep the stack size constant.    *! If however the stack risks to overflow, it will allocate double its    *! current size, i.e. pushing an element on an full 32 slot stack will    *! result in a 64 slot stack with 33 elements.    */   PIKECLASS Stack
pike.git/src/cpp.cmod:391:      /*! @class define    */   PIKECLASS define   {    PIKEVAR string name flags ID_PRIVATE|ID_PROTECTED;    PIKEVAR array(string|int) parts flags ID_PRIVATE|ID_PROTECTED;    CVAR magic_define_fun magic;    CVAR int args;    CVAR short flags; /* CPP_MACRO_* */ -  CVAR short varargs; +        CVAR struct svalue self;       DECLARE_STORAGE;       INIT    {    struct define_struct *def = (struct define_struct *)CURRENT_STORAGE;    /* NB: NO reference for def->self! */    SET_SVAL(def->self, T_OBJECT,    Pike_fp->context - Pike_fp->current_program->inherits,    object, Pike_fp->current_object);    def->args=-1;   #ifdef PIKE_NULL_IS_SPECIAL    def->magic=0;    def->flags = 0; -  def->varargs=0; +    #endif    }       PIKEFUN void create(string name, int num_args,    array(string|int|function(mixed|void...:string)) parts)    flags ID_PROTECTED;    {    if (THIS->name) free_string(THIS->name);    add_ref(THIS->name = name);   
pike.git/src/cpp.cmod:491:    {    int raw_arg = sval->u.integer;    int arg = raw_arg & DEF_ARG_MASK;    struct pike_string *str;    if (!arguments || (arg >= arguments->size)) {    yyerror("Too few arguments to macro.");    break;    }    str = arguments->item[arg].u.string;    if (raw_arg & DEF_ARG_NEED_COMMA) { -  if (!(d->varargs) || +  if (!(d->flags & CPP_MACRO_VARARGS) ||    (arg != d->args-1) ||    str->len) {    /* Don't add the comma if the varargs argument and empty. */    string_builder_putchar(&s, ',');    string_builder_putchar(&s, ' ');    }    }    if (!(raw_arg & DEF_ARG_NOPRESPACE)) {    string_builder_putchar(&s, ' ');    }
pike.git/src/cpp.cmod:3468:    if((argument & DEF_ARG_MASK) >= d->args)    {    cpp_error(this, "Macro not expanded correctly.");    continue;    }       a = arguments[argument & DEF_ARG_MASK].arg;    l = arguments[argument & DEF_ARG_MASK].len;       if (argument & DEF_ARG_NEED_COMMA -  && !(d->varargs && d->args-1 +  && !(d->flags & CPP_MACRO_VARARGS && d->args-1    == (argument & DEF_ARG_MASK) && l == 0)) {    string_builder_putchar(&tmp, ',');    string_builder_putchar(&tmp, ' ');    }       if(!(argument & DEF_ARG_NOPRESPACE))    string_builder_putchar(&tmp, ' ');       if(argument & DEF_ARG_STRINGIFY)    {
pike.git/src/cpp.cmod:3723:    for(arg=0;arg<d->args;arg++)    {    if(arg && DATA(pos)==',')    {    pos++;    SKIPWHITE();    }else{    SKIPWHITE();    if(DATA(pos)==')')    { -  if((d->varargs && arg + 1 == d->args) || +  if(((d->flags & CPP_MACRO_VARARGS) && (arg + 1 == d->args)) ||    (!arg && (d->args == 1))) {    /* Allow varargs to be left out.    *    * Allow a single argument to be left out.    */    arguments[arg].arg = ADD_PCHARP(data,pos);    arguments[arg].len=0;    continue;    }else{    cpp_error_sprintf(this,
pike.git/src/cpp.cmod:3803:       case '(':    pos=find_end_parenthesis(this, data, len, pos);    continue;       case '{':    pos=find_end_brace(this, data, len, pos);    continue;       case ',': -  if(d->varargs && arg+1 == d->args) continue; +  if((d->flags & CPP_MACRO_VARARGS) && (arg+1 == d->args)) continue;    /* FALLTHRU */       case ')':    pos--;    break;    }    break;    }    arguments[arg].len = SUBTRACT_PCHARP(ADD_PCHARP(data,pos),arguments[arg].arg);    }
pike.git/src/cpp.cmod:4429:    argno++;    if(argno>=MAX_ARGS)    {    cpp_error(this, "Too many arguments in macro definition.");    pop_stack();    argno--;    }       if(DATA(pos)=='.' && DATA(pos+1)=='.' && DATA(pos+2)=='.')    { -  varargs=1; +  varargs = CPP_MACRO_VARARGS;    pos+=3;    SKIPWHITE();    }    }       if(!GOBBLE(')'))    cpp_error(this, "Missing ) in macro definition.");    }       SKIPSPACE();
pike.git/src/cpp.cmod:4608:    push_string(finish_string_builder(&str));    break;    }       if(OUTP())    {    f_aggregate(Pike_sp - partbase);       def = alloc_empty_define(def_name);    def->args=argno; -  def->varargs=varargs; +  def->flags |= varargs;       add_ref(def->parts = Pike_sp[-2].u.array);       {    struct define_struct *d;    if ((d = FIND_DEFINE(def->name)) &&    (d->flags & (CPP_MACRO_IN_USE | CPP_MACRO_DISABLED))) {    cpp_error(this,    "Illegal to redefine a macro during its expansion.");    } else {
pike.git/src/cpp.cmod:5456:    add_define (this, k->ind.u.string, k->val.u.string);    else if(TYPEOF(k->val) == T_FUNCTION || TYPEOF(k->val) == T_OBJECT)    {    struct define_struct *def;    if( index_shared_string( k->ind.u.string, k->ind.u.string->len-1) == ')' )    {    struct pike_string *s = string_slice( k->ind.u.string, 0, k->ind.u.string->len-2);    def = alloc_empty_define(s);    free_string(s);    def->magic = insert_callback_define; -  def->varargs=1; +  def->flags |= CPP_MACRO_VARARGS;    def->args=1;    }    else    {    def = alloc_empty_define(k->ind.u.string);    def->magic = insert_callback_define_no_args;    }    mapping_string_insert(this->defines, def->name, Pike_sp-1);    pop_stack();    }