pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:1629:    *! #define @b{@i{<identifier>@}@}(arg1, arg2) @i{<replacement string>@}    *! @endcode    *!    *! would cause @tt{@b{@i{<identifer>@}@}@} to be a macro. All occurances of    *! '@tt{@b{@i{<identifier>@}@}(something1,something2d)@}' would be replaced    *! with the @tt{@i{<replacement string>@}@}.    *! And in the @tt{@i{<replacement string>@}@}, @tt{arg1@} and @tt{arg2@}    *! will be replaced with @tt{something1@} and @tt{something2@}.    */    - static struct define_struct *do_magic_define(struct cpp *this, -  const char *name, -  magic_define_fun fun) + static struct pike_string *make_define_name(struct cpp *this, +  const char *name)   { -  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)); -  } else -  def = alloc_empty_define(make_shared_string(name)); +  return finish_string_builder(&s); +  } +  return make_shared_string(name); + } +  + static struct define_struct *do_magic_define(struct cpp *this, +  const char *name, +  magic_define_fun fun) + { +  struct define_struct* def; +  def = alloc_empty_define(make_define_name(this, 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);
pike.git/src/cpp.cmod:1673:    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)); -  } else -  def = alloc_empty_define(make_shared_string(name)); -  -  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(); +  add_define(this, make_define_name(this, name), make_shared_string(what));   }      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.    *    * * NUL isn't valid in a Pike program.