pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:83:   static struct mapping *initial_predefs_mapping(void);   static struct pike_predef_s *first_predef = NULL, *last_predef = NULL;      struct define_argument {    PCHARP arg;    ptrdiff_t len;   };      struct CPP_struct;   struct define_struct; - typedef void (*magic_define_fun)(struct CPP_struct *, + typedef void (*magic_define_fun)(struct object *,    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. */   
pike.git/src/cpp.cmod:132:    * string cpp(...)    * {    * Preprocessor p = Preprocessor();    * p->init();    * Preprocessor.Context ctx = p->Context();    * ctx->cpp(data);    * return ctx->get();    * }    */    - static void insert_callback_define(struct CPP_struct *this, + static void insert_callback_define(struct object *cpp_obj,    struct define_struct *def,    struct pike_string *arg,    struct string_builder *tmp); - static void insert_callback_define_no_args(struct CPP_struct *this, + static void insert_callback_define_no_args(struct object *cpp_obj,    struct define_struct *def,    struct pike_string *arg,    struct string_builder *tmp); - static void insert_pragma(struct CPP_struct *this, + static void insert_pragma(struct object *cpp_obj,    struct define_struct *def,    struct pike_string *arg,    struct string_builder *tmp);      /*! @class define    */   PIKECLASS define   {    PIKEVAR string name flags ID_PRIVATE|ID_PROTECTED;    PIKEVAR array(string|int) parts flags ID_PRIVATE|ID_PROTECTED;
pike.git/src/cpp.cmod:218:    struct define_struct *d = THIS;    struct string_builder s;    struct array *parts = THIS->parts;    INT32 i;    INT_TYPE flags = flags_sval?flags_sval->u.integer:0;       init_string_builder(&s, 0);    if(d->magic)    {    struct pike_string *a = NULL; -  struct CPP_struct *this = get_storage(context_obj, CPP_program); +        if (d->args > 0) {    a = ITEM(arguments)[0].u.string;    } -  d->magic(this, d, a, &s); +  d->magic(context_obj, d, a, &s);       /* NB: The variable 'a' does not holdany refs. */       if (d->magic == insert_callback_define ||    d->magic == insert_callback_define_no_args ||    d->magic == insert_pragma) {    goto keep_new_lines;    }    goto remove_new_lines;    }
pike.git/src/cpp.cmod:1375:    *! @[defined] returns true if the symbol given as argument    *! is defined.    *!    *! @note    *! @tt{#if defined(MY_DEF)@} is equivalent to    *! @tt{#ifdef MY_DEF@}.    *!    *! @seealso    *! @[#if], @[#ifdef], @[constant()]    */ - static void check_defined(struct CPP_struct *this, + static void check_defined(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *arg,    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    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_struct *this, struct pike_string *s)   {    int res;    JMP_BUF recovery;
pike.git/src/cpp.cmod:4532:    init_string_builder(&this->buf, 0);    }      /*** 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_struct *this, + static void insert_current_line(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    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_struct *this, + static void insert_current_file_as_string(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    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_struct *this, + static void insert_current_dir_as_string(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    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_struct *UNUSED(this), + static void insert_current_time_as_string(struct object *UNUSED(cpp_obj),    struct define_struct *UNUSED(def),    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_struct *UNUSED(this), + static void insert_current_date_as_string(struct object *UNUSED(cpp_obj),    struct define_struct *UNUSED(def),    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   {    /* FIXME: Is this code safe? */    time_t tmp2;    char *buf;    time(&tmp2);    buf=ctime(&tmp2);   
pike.git/src/cpp.cmod:4618:      /*! @decl constant __VERSION__    *!    *! 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_struct *this, + static void insert_current_version(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    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_struct *this, + static void insert_current_minor(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    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_struct *UNUSED(this), + static void insert_current_counter(struct object *UNUSED(cpp_obj),    struct define_struct *UNUSED(def),    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_struct *this, + static void insert_current_major(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    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_struct *this, + static void insert_pragma(struct object *cpp_obj,    struct define_struct *UNUSED(def),    struct pike_string *arg,    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    int i;    int in_string = 0;       /* Make some reasonable amount of space. */    string_build_mkspace(tmp, arg->len + 20, arg->size_shift);       string_builder_strcat(tmp, "\n#pragma ");       /* Destringize the argument. */    for (i = 0; i < arg->len; i++) {
pike.git/src/cpp.cmod:4746:    }       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_struct *this, + static void insert_callback_define(struct object *cpp_obj,    struct define_struct *def,    struct pike_string *arg,    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    ref_push_string( def->name );    ref_push_string( arg );    if (safe_apply_handler( "evaluate_define",    this->handler, this->compat_handler, 2, 0 ) &&    TYPEOF(Pike_sp[-1]) == T_STRING ) {    string_builder_shared_strcat(tmp, Pike_sp[-1].u.string);    if( !this->prefix ){    int min;    check_string_range( Pike_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,arg,tmp); +  insert_current_file_as_string(cpp_obj, def, arg, tmp);    string_builder_putchar(tmp, '\n');    }    }    pop_stack();    }   }    - static void insert_callback_define_no_args(struct CPP_struct *this, + static void insert_callback_define_no_args(struct object *cpp_obj,    struct define_struct *def,    struct pike_string *UNUSED(arg),    struct string_builder *tmp)   { -  +  struct CPP_struct *this = get_storage(cpp_obj, CPP_program);    struct svalue *save_sp = Pike_sp;    ref_push_string( def->name );    if (safe_apply_handler( "evaluate_define",    this->handler, this->compat_handler, 1, 0 ) &&    TYPEOF(Pike_sp[-1]) == T_STRING )    string_builder_shared_strcat(tmp, Pike_sp[-1].u.string);    if (Pike_sp > save_sp) pop_n_elems(Pike_sp-save_sp);   }