pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:46:    int c_=(C); if(OUTP() || c_=='\n') string_builder_putchar(&this->buf, c_); }while(0)      #define MAX_ARGS 255   #define DEF_ARG_STRINGIFY 0x100000   #define DEF_ARG_NOPRESPACE 0x200000   #define DEF_ARG_NOPOSTSPACE 0x400000   #define DEF_ARG_NEED_COMMA 0x800000   #define DEF_ARG_MASK 0x0fffff      struct define_part; - struct define_argument; +    struct define;   struct cpp;      #ifdef __GNUC__   #pragma GCC optimize "-Os"   #endif      /* Return true if compat version is equal or less than MAJOR.MINOR */   #define CPP_TEST_COMPAT(THIS,MAJOR,MINOR) \    (THIS->compat_major < (MAJOR) || \
pike.git/src/cpp.cmod:91:   {    int argument;    struct pike_string *postfix;   };      struct define_argument {    PCHARP arg;    ptrdiff_t len;   };    -  +    struct cpp;   struct define;   typedef void (*magic_define_fun)(struct cpp *,    struct define *, -  struct define_argument *, +  struct pike_string *,    struct string_builder *);      struct define   {    struct hash_entry link; /* must be first */    magic_define_fun magic;    int args;    ptrdiff_t num_parts;    short inside; /* 1 - Don't expand. 2 - In use. */    short varargs;
pike.git/src/cpp.cmod:882:    *!    *! @note    *! @tt{#if defined(MY_DEF)@} is equvivalent to    *! @tt{#ifdef MY_DEF@}.    *!    *! @seealso    *! @[#if], @[#ifdef], @[constant()]    */   static void check_defined(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *args, +  struct pike_string *arg,    struct string_builder *tmp)   { -  struct pike_string *s = binary_findstring_wide( args[0].arg.ptr, -  args[0].arg.shift, -  args[0].len ); -  -  if(s && FIND_DEFINE(s)) +  if(arg && FIND_DEFINE(arg))    string_builder_binary_strcat(tmp, " 1 ", 3);    else    string_builder_binary_strcat(tmp, " 0 ", 3);   }      static int do_safe_index_call(struct cpp *this, struct pike_string *s)   {    int res;    JMP_BUF recovery;    if(!s) return 0;
pike.git/src/cpp.cmod:2193:   }      static ptrdiff_t low_cpp(struct cpp *this,    PCHARP data,    ptrdiff_t len,    int flags,    int auto_convert,    struct pike_string *charset);   static void insert_callback_define(struct cpp *this,    struct define *def, -  struct define_argument *args, +  struct pike_string *arg,    struct string_builder *tmp);   static void insert_callback_define_no_args(struct cpp *this,    struct define *def, -  struct define_argument *args, +  struct pike_string *arg,    struct string_builder *tmp);   static void insert_pragma(struct cpp *this,    struct define *def, -  struct define_argument *args, +  struct pike_string *arg,    struct string_builder *tmp);      static ptrdiff_t calc1(struct cpp *this, PCHARP data, ptrdiff_t len,    ptrdiff_t pos, int flags);      static ptrdiff_t calcC(struct cpp *this, PCHARP data, ptrdiff_t len,    ptrdiff_t pos, int flags)   {    SKIPWHITE();   
pike.git/src/cpp.cmod:2833:      /*** Magic defines ***/      /*! @decl constant __LINE__    *!    *! This define contains the current line number, represented as an    *! integer, in the source file.    */   static void insert_current_line(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    string_builder_sprintf(tmp, " %ld ", (long)this->current_line);   }      /*! @decl constant __FILE__    *!    *! This define contains the file path and name of the source file.    */   static void insert_current_file_as_string(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    PUSH_STRING_SHIFT(this->current_file->str, this->current_file->len,    this->current_file->size_shift, tmp);   }      /*! @decl constant __DIR__    *!    *! This define contains the directory path of the source file.    */   static void insert_current_dir_as_string(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    ref_push_string(this->current_file);    /* FIXME: This isn't safe if the master hasn't been compiled yet. */    SAFE_APPLY_MASTER("dirname",1);    PUSH_STRING_SHIFT(Pike_sp[-1].u.string->str, Pike_sp[-1].u.string->len,    Pike_sp[-1].u.string->size_shift, tmp);    pop_stack();   }      /*! @decl constant __TIME__    *!    *! This define contains the current time at the time of compilation,    *! e.g. "12:20:51".    */   static void insert_current_time_as_string(struct cpp *UNUSED(this),    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    /* FIXME: Is this code safe? */    time_t tmp2;    char *buf;    time(&tmp2);    buf=ctime(&tmp2);       PUSH_STRING0((p_wchar0 *)buf+11, 8, tmp);   }      /*! @decl constant __DATE__    *!    *! This define contains the current date at the time of compilation,    *! e.g. "Jul 28 2001".    */   static void insert_current_date_as_string(struct cpp *UNUSED(this),    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    /* FIXME: Is this code safe? */    time_t tmp2;    char *buf;    time(&tmp2);    buf=ctime(&tmp2);       PUSH_STRING0((p_wchar0 *)buf+4, 6, tmp);    PUSH_STRING0((p_wchar0 *)buf+19, 5, tmp);
pike.git/src/cpp.cmod:2919:    *!    *! This define contains the current Pike version as a float. If    *! another Pike version is emulated, this define is updated    *! accordingly.    *!    *! @seealso    *! @[__REAL_VERSION__]    */   static void insert_current_version(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    string_builder_sprintf(tmp, " %d.%d ", this->compat_major,    this->compat_minor);   }         /*! @decl constant __MINOR__    *! This define contains the minor part of the current Pike version,    *! represented as an integer. If another Pike version is emulated,    *! this define is updated accordingly.    *!    *! @seealso    *! @[__REAL_MINOR__]    */   static void insert_current_minor(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    string_builder_sprintf(tmp, " %d ", this->compat_minor);   }      /*! @decl int(1..) __COUNTER__    *! This define contains a unique counter (unless it has been expanded    *! Int.NATIVE_MAX times) represented as an integer.    *!    */   static void insert_current_counter(struct cpp *UNUSED(this),    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    static int counter = 0;    string_builder_sprintf(tmp, " %d ", ++counter);   }      /*! @decl constant __MAJOR__    *!    *! This define contains the major part of the current Pike version,    *! represented as an integer. If another Pike version is emulated,    *! this define is updated accordingly.    *!    *! @seealso    *! @[__REAL_MAJOR__]    */   static void insert_current_major(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    string_builder_sprintf(tmp, " %d ", this->compat_major);   }      /* _Pragma(STRING) */   /*! @decl void _Pragma(string directive)    *!    *! This macro inserts the corresponding @[#pragma] @[directive]    *! in the source.    *!    *! e.g. @expr{_Pragma("strict_types")@} is the same    *! as @expr{#pragma strict_types@} .    *!    *! @seealso    *! @[#pragma]    */   static void insert_pragma(struct cpp *this,    struct define *UNUSED(def), -  struct define_argument *args, +  struct pike_string *arg,    struct string_builder *tmp)   {    int i;    int in_string = 0; -  PCHARP arg = args->arg; -  ptrdiff_t len = args->len; +        /* Make some reasonable amount of space. */ -  string_build_mkspace(tmp, len + 20, arg.shift); +  string_build_mkspace(tmp, arg->len + 20, arg->size_shift);       string_builder_strcat(tmp, "\n#pragma ");       /* Destringize the argument. */ -  for (i = 0; i < len; i++) { -  p_wchar2 ch = INDEX_PCHARP(arg, i); +  for (i = 0; i < arg->len; i++) { +  p_wchar2 ch = index_shared_string(arg, i);    switch(ch) {    case '\n': case '\r':    ch = ' ';    /* FALL_THROUGH */    case ' ': case '\t':    if (in_string) {    string_builder_putchar(tmp, ch);    }    break;    case '\"':    in_string = !in_string;    break;    case '\\':    if (in_string) { -  ch = (++i < len) ? INDEX_PCHARP(arg, i) : '\0'; +  ch = (++i < arg->len) ? index_shared_string(arg, i) : '\0';    if ((ch != '\\') && (ch != '\"')) {    cpp_error(this, "Invalid \\-escape in _Pragma().");    break;    }    }    /* FALL_THROUGH */    default:    if (in_string) {    string_builder_putchar(tmp, ch);    } else {
pike.git/src/cpp.cmod:3045:    if (in_string) {    cpp_error(this, "Unterminated string constant.");    }       string_builder_sprintf(tmp, "\n#line %ld ", (long)this->current_line);    PUSH_STRING_SHIFT(this->current_file->str,    this->current_file->len,    this->current_file->size_shift,    tmp);    string_builder_putchar(tmp, '\n'); -  +    }      static void insert_callback_define(struct cpp *this,    struct define *def, -  struct define_argument *args, +  struct pike_string *arg,    struct string_builder *tmp)   {    ref_push_string( def->link.s ); -  push_string( make_shared_binary_pcharp( args[0].arg, args[0].len ) ); +  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 )    {    string_builder_sprintf(tmp, "\n#line %ld ", (long)this->current_line); -  insert_current_file_as_string( this,def,args,tmp); +  insert_current_file_as_string( this,def,arg,tmp);    string_builder_putchar(tmp, '\n');    }    }    pop_stack();    }   }      static void insert_callback_define_no_args(struct cpp *this,    struct define *def, -  struct define_argument *UNUSED(args), +  struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    struct svalue *save_sp = Pike_sp;    ref_push_string( def->link.s );    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);   }