pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:73:   static struct pike_string *defined_str;      struct pike_predef_s   {    struct pike_predef_s *next;    char *name;    char *value;   };      static int use_initial_predefs; + 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 *,
pike.git/src/cpp.cmod:339:    SET_INDEX_CHARP(s.s->str, i, s.s->size_shift, ' ');       keep_new_lines:    pop_n_elems(args);    push_string(finish_string_builder(&s));    }   }   /*! @endclass define    */    + PIKEFUN mapping(string:string|function|object) get_predefines() + { +  if (use_initial_predefs) { +  push_mapping(initial_predefs_mapping()); +  } else { +  APPLY_MASTER("get_predefines", 0); +  } + } +    /*! @class CPP    *!    *! The state for an instance of the preprocessor.    *!    *! @seealso    *! @[predef::cpp()]    */   PIKECLASS CPP    program_flags PROGRAM_USES_PARENT|PROGRAM_NEEDS_PARENT;   {
pike.git/src/cpp.cmod:5198:    }    else if ((TYPEOF(k->val) == T_INT) && !k->val.u.integer) {    add_define (this, s, empty_pike_string);    } else {    Pike_error("Expected zero, string or function value for "    "predefine %O.\n",    &k->ind);    }    }    } +  +  /*! @decl mapping(string:string|function|object) get_predefines() +  *! +  *! Get the predefined macros for this preprocessor. +  *! +  *! This function is called by @[init_pike_cpp()] to +  *! retrieve the set of macros to define at initialization. +  *! +  *! The default implementation returns the internal set of +  *! predefined macros unless @[_take_over_initial_predefines()] +  *! has been called, in which case it instead calls the +  *! corresponding function in the master. +  *! +  *! @note +  *! This function does NOT return the set of currently +  *! defined macros. +  *! +  *! @seealso +  *! @[init_pike_cpp()], @[define_multiple_macros()], +  *! @[_take_over_initial_predefines()] +  */ +  PIKEFUN mapping(string:string|function|object) get_predefines() +  { +  apply_external(1, f_get_predefines_fun_num, args);    } -  +  +  /*! @decl void init_pike_cpp() +  *! +  *! Convenience function for initializing the preprocessor +  *! to Pike defaults. +  *! +  *! The default implementation is essentially: +  *! @code +  *! { +  *! define_ansi_macros(); +  *! define_pike_macros(); +  *! define_multiple_macros(get_predefines()); +  *! } +  *! @endcode +  */ +  PIKEFUN void init_pike_cpp() +  { +  apply_current(f_CPP_define_ansi_macros_fun_num, 0); +  apply_current(f_CPP_define_pike_macros_fun_num, 0); +  apply_current(f_CPP_get_predefines_fun_num, 0); +  apply_current(f_CPP_define_multiple_macros_fun_num, 1); +  } + }   /*! @endclass CPP    */      /*! @endclass CompilerEnvironment    */      /*! @decl string cpp(string data, mapping|string|void current_file, @    *! int|string|void charset, object|void handler, @    *! void|int compat_major, void|int compat_minor, @    *! void|int picky_cpp)