pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:908:    }    if (this->compat_handler) {    ref_push_object(this->compat_handler);    } else {    push_undefined();    }       apply_external(1, CE_RESOLV_FUN_NUM, 4);   }    +  /*! @decl string evaluate_define(string def, string|void arguments) +  *! +  *! Evaluate the #define named @[def] with @[arguments]. +  *! +  *! @param def +  *! Name of the macro. +  *! +  *! @param arguments +  *! Raw string of the contents between the parenthesis +  *! for function-style maros. @[UNDEFINED] or left out +  *! if not a function-style macro. +  *! +  *! This function is used to evaluate callback-style macros +  *! as defined via @[define_multiple_macros()]. +  *! +  *! @note +  *! This API is likely to be removed in a future version of +  *! Pike, where macro functions would be called directly by +  *! the preprocessor. +  */ +  PIKEFUN string evaluate_define(string def, string|void arguments) +  { +  struct CPP_struct *this = THIS; +  low_unsafe_apply_handler("evaluate_define", +  this->handler, this->compat_handler, args); +  } +    /* #if macros and functions. */      /*! @namespace cpp::    *!    *! Pike has a builtin C-style preprocessor. It works similar to the    *! ANSI-C preprocessor but has a few extra features. These and the    *! default set of preprocessor macros are described here.    */      /*! @directive #!
pike.git/src/cpp.cmod:4761:   }      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 ) { +  if (safe_apply(cpp_obj, "evaluate_define", 2) && +  (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(cpp_obj, def, arg, tmp);    string_builder_putchar(tmp, '\n');    }
pike.git/src/cpp.cmod:4787:   }      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 ) +  if (safe_apply(cpp_obj, "evaluate_define", 1) && +  (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);   }         /*! @decl constant __REAL_VERSION__    *!    *! This define always contains the version of the current Pike,    *! represented as a float.    *!
pike.git/src/cpp.cmod:5184:    }       /*! @decl void define_multiple_macros(mapping(string: @    *! string|function|object)|void predefs)    *!    *! Define multiple macros in one operation.    *!    *! @param predefs    *! Macros to define.    *! +  *! @note +  *! Callback-style macros are supported. Note that is up to +  *! @[evaluate_define()] to actually remember the callback. +  *! +  *! @note +  *! It is likely that this function in a future version of Pike +  *! @b{will@} actually register the callback, in which case +  *! @[evaluate_define()] no longer will be called. The implicit +  *! @[evaluate_define()] in that case will probably use the +  *! same semantics as the current reference implementation in +  *! the master. +  *!    *! @seealso    *! @[define_macro()], @[CompilationHandler()->get_predefines()], -  *! @[_take_over_initial_predefines()] +  *! @[_take_over_initial_predefines()], @[evaluate_define()]    */    PIKEFUN void define_multiple_macros(mapping(string:    string|function|object)|void predefs)    {    struct CPP_struct *this = THIS;    struct keypair *k;    int e;    if (!predefs) return;    NEW_MAPPING_LOOP (predefs->data) {    struct pike_string *s;