pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:97:   struct define_struct;   typedef void (*magic_define_fun)(struct cpp *,    struct define_struct *,    struct pike_string *,    struct string_builder *);      DECLARATIONS;      PIKECLASS define   { -  CVAR struct hash_entry link; /* must be first */ +  PIKEVAR string name flags ID_PRIVATE|ID_PROTECTED;    CVAR magic_define_fun magic;    CVAR int args;    CVAR ptrdiff_t num_parts;    CVAR short inside; /* 1 - Don't expand. 2 - In use. */    CVAR short varargs;    CVAR struct pike_string *first;    CVAR struct define_part *parts;       DECLARE_STORAGE;       INIT    {    struct define_struct *def = (struct define_struct *)(Pike_fp->current_storage);    def->magic=0;    def->args=-1;    def->inside=0;    def->varargs=0;    def->parts = NULL;    def->num_parts=0;    def->first=0; -  def->link.s = NULL; +     }       EXIT    {    struct define_struct *d = (struct define_struct *)(Pike_fp->current_storage);    INT32 e;    for (e = 0; e < d->num_parts; e++)    free_string(d->parts[e].postfix);    if (d->parts)    free(d->parts); -  if (d->link.s) -  free_string(d->link.s); +     if(d->first)    free_string(d->first);    }   }      struct cpp   {    struct mapping *defines;    INT_TYPE current_line;    INT32 compile_errors;
pike.git/src/cpp.cmod:1586:   /* devours one reference to 'name'! */   /* The reference to the define is held by the stack on return. */   static struct define_struct *alloc_empty_define(struct pike_string *name,    ptrdiff_t parts)   {    struct define_struct *def;    struct object *o;       push_object(o = clone_object(define_program, 0));    def = (struct define_struct *)get_storage(o, define_program); -  def->link.s=name; +  def->name = name;    debug_malloc_touch(name);    if (parts) {    def->parts = xalloc(sizeof(struct define_part) * parts);    def->num_parts = parts;    }    return def;   }      /*! @directive #undef    *! @directive #undefine
pike.git/src/cpp.cmod:1680:       init_string_builder(&s, 0);    string_builder_append(&s, MKPCHARP_STR(this->prefix),    this->prefix->len);    string_builder_putchar(&s, '_');    string_builder_binary_strcat(&s, name, len);    def = alloc_empty_define(finish_string_builder(&s),0);    } else    def = alloc_empty_define(make_shared_string(name),0);    def->magic=fun; -  mapping_string_insert(this->defines, def->link.s, Pike_sp-1); +  mapping_string_insert(this->defines, def->name, Pike_sp-1);    pop_stack();       return def;   }      static void add_define(struct cpp *this,    struct pike_string *name,    struct pike_string *what)   {    struct define_struct* def;    add_ref (name);    def=alloc_empty_define(name,0);    add_ref (def->first = what); -  mapping_string_insert(this->defines, def->link.s, Pike_sp-1); +  mapping_string_insert(this->defines, def->name, Pike_sp-1);    pop_stack();   }      static void simple_add_define(struct cpp *this,    const char *name,    const char *what)   {    struct define_struct* def;       if (this->prefix) {
pike.git/src/cpp.cmod:1718:    init_string_builder(&s, 0);    string_builder_append(&s, MKPCHARP_STR(this->prefix),    this->prefix->len);    string_builder_putchar(&s, '_');    string_builder_binary_strcat(&s, name, len);    def = alloc_empty_define(finish_string_builder(&s),0);    } else    def = alloc_empty_define(make_shared_string(name),0);       def->first=make_shared_string(what); -  mapping_string_insert(this->defines, def->link.s, Pike_sp-1); +  mapping_string_insert(this->defines, def->name, Pike_sp-1);    pop_stack();   }      static struct pike_string *recode_string(struct cpp *this, struct pike_string *data)   {    /* Observations:    *    * * At least a prefix of two bytes need to be 7bit in a valid    * Pike program.    *
pike.git/src/cpp.cmod:3066:    this->current_file->size_shift,    tmp);    string_builder_putchar(tmp, '\n');   }      static void insert_callback_define(struct cpp *this,    struct define_struct *def,    struct pike_string *arg,    struct string_builder *tmp)   { -  ref_push_string( def->link.s ); +  ref_push_string( def->name );    ref_push_string( arg );    if (safe_apply_handler( "evaluate_define",    this->handler, this->compat_handler, 2, 0 ) &&    TYPEOF(sp[-1]) == T_STRING ) {    string_builder_shared_strcat(tmp, sp[-1].u.string);    if( !this->prefix ){    int min;    check_string_range( sp[-1].u.string, 0, &min, 0 );    if( min < 32 )    {
pike.git/src/cpp.cmod:3092:    pop_stack();    }   }      static void insert_callback_define_no_args(struct cpp *this,    struct define_struct *def,    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    struct svalue *save_sp = Pike_sp; -  ref_push_string( def->link.s ); +  ref_push_string( def->name );    if (safe_apply_handler( "evaluate_define",    this->handler, this->compat_handler, 1, 0 ) &&    TYPEOF(sp[-1]) == T_STRING )    string_builder_shared_strcat(tmp, sp[-1].u.string);    if (Pike_sp > save_sp) pop_n_elems(Pike_sp-save_sp);   }         /*! @decl constant __REAL_VERSION__    *!
pike.git/src/cpp.cmod:3476:       {   #if 0    /* Left in place for documentation reference purposes. */    struct define_struct *def =    alloc_empty_define(make_shared_string("__deprecated__"), 1);    def->args = 1;    REF_MAKE_CONST_STRING(def->first, "__attribute__(\"deprecated\", ");    def->parts[0].argument = 0;    REF_MAKE_CONST_STRING(def->parts[0].postfix, ")"); -  mapping_string_insert(this.defines, def->link.s, Pike_sp-1); +  mapping_string_insert(this.defines, def->name, Pike_sp-1);    pop_stack();   #endif /* 0 */       simple_add_define(&this, "__PIKE__", " 1 ");       simple_add_define(&this, "__REAL_VERSION__",    " " DEFINETOSTR(PIKE_MAJOR_VERSION) "."    DEFINETOSTR(PIKE_MINOR_VERSION) " ");    simple_add_define(&this, "__REAL_MAJOR__",    " " DEFINETOSTR(PIKE_MAJOR_VERSION) " ");
pike.git/src/cpp.cmod:3535:    def->magic = insert_callback_define;    def->varargs=1;    def->args=1;    }    else    {    def = alloc_empty_define( k->ind.u.string, 0 );    k->ind.u.string->refs++;    def->magic = insert_callback_define_no_args;    } -  mapping_string_insert(this.defines, def->link.s, Pike_sp-1); +  mapping_string_insert(this.defines, def->name, Pike_sp-1);    pop_stack();    }    else    add_define (&this, k->ind.u.string, empty_pike_string);    }    free_mapping (predefs);    }       string_builder_binary_strcat(&this.buf, "#line 1 ", 8);    PUSH_STRING_SHIFT(this.current_file->str, this.current_file->len,