pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:74:   struct pike_predef_s   {    struct pike_predef_s *next;    char *name;    char *value;   };      static int use_initial_predefs;   static struct pike_predef_s *first_predef = NULL, *last_predef = NULL;    - struct define_part - { -  int argument; -  struct pike_string *postfix; - }; -  +    struct define_argument {    PCHARP arg;    ptrdiff_t len;   };      struct cpp;   struct define_struct;   typedef void (*magic_define_fun)(struct cpp *,    struct define_struct *,    struct pike_string *,    struct string_builder *);      DECLARATIONS;      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 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; +     } -  -  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->first) -  free_string(d->first); +    } - } +       struct cpp   {    struct mapping *defines;    INT_TYPE current_line;    INT32 compile_errors;    struct pike_string *current_file;    struct string_builder buf;    struct object *handler;    struct object *compat_handler;
pike.git/src/cpp.cmod:1574:    if (p != *pos) {    *pos = p;    return finish_string_builder (&sb);    }    free_string_builder (&sb);    return NULL;   }      /* 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) + static struct define_struct *alloc_empty_define(struct pike_string *name)   {    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->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    *!    *! This removes the effect of a @[#define], all subsequent occurances of    *! the undefined identifier will not be replaced by anything.    *!    *! @note
pike.git/src/cpp.cmod:1672:       if (this->prefix) {    struct string_builder s;    int len = strlen(name);       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); +  def = alloc_empty_define(finish_string_builder(&s));    } else -  def = alloc_empty_define(make_shared_string(name),0); +  def = alloc_empty_define(make_shared_string(name));    def->magic=fun;    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); +  def=alloc_empty_define(name); +  ref_push_string(what); +  f_aggregate(1); +  def->parts = Pike_sp[-1].u.array; +  Pike_sp--;    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) {    struct string_builder s;    int len = strlen(name);       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); +  def = alloc_empty_define(finish_string_builder(&s));    } else -  def = alloc_empty_define(make_shared_string(name),0); +  def = alloc_empty_define(make_shared_string(name));    -  def->first=make_shared_string(what); +  push_string(make_shared_string(what)); +  f_aggregate(1); +  def->parts = Pike_sp[-1].u.array; +  Pike_sp--;    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:3520:    int e;    NEW_MAPPING_LOOP (predefs->data) {    if (TYPEOF(k->val) == T_STRING)    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, 0 ); +  def = alloc_empty_define(s);    def->magic = insert_callback_define;    def->varargs=1;    def->args=1;    }    else    { -  def = alloc_empty_define( k->ind.u.string, 0 ); +  def = alloc_empty_define(k->ind.u.string);    k->ind.u.string->refs++;    def->magic = insert_callback_define_no_args;    }    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);
pike.git/src/cpp.cmod:3619:    struct svalue s;       efun_str = make_shared_string ("efun");    constant_str = make_shared_string ("constant");    defined_str = make_shared_string ("defined");       use_initial_predefs = 1;       INIT;    -  defined_macro=alloc_empty_define(make_shared_string("defined"),0); +  defined_macro = alloc_empty_define(make_shared_string("defined"));    defined_macro->magic=check_defined;    defined_macro->args=1;    defined_macro_sval = Pike_sp[-1];    Pike_sp--;       ADD_INT_CONSTANT("__HAVE_CPP_PREFIX_SUPPORT__", 1, 0);       /* Somewhat tricky to add a _constant_ function in _static_modules.Builtin. */    SET_SVAL(s, T_FUNCTION, FUNCTION_BUILTIN, efun,    make_callable (f__take_over_initial_predefines,