pike.git / src / cpp.cmod

version» Context lines:

pike.git/src/cpp.cmod:25:   #include "pike_types.h"   #include "cpp.h"   #include "lex.h"   #include "sprintf.h"   #include "pike_compiler.h"      #include <ctype.h>      #define DEFAULT_CMOD_STORAGE    + /* #define SUPPORT_HANDLERS */ +    #define CPP_NO_OUTPUT 1 /* Inside false section of #if/#else */   #define CPP_EXPECT_ELSE 2 /* Expect #else/#elif/#elseif. */   #define CPP_EXPECT_ENDIF 4 /* Expect #endif */   #define CPP_REALLY_NO_OUTPUT 8 /* Entire preprocessor is in false section. */   #define CPP_END_AT_NEWLINE 16 /* Halt at end of line. */   #define CPP_DO_IF 32   #define CPP_NO_EXPAND 64      #define OUTP() (!(flags & (CPP_NO_OUTPUT | CPP_REALLY_NO_OUTPUT)))   #define PUTNL() string_builder_putchar(&this->buf, '\n')
pike.git/src/cpp.cmod:414:    SET_INDEX_CHARP(s.s->str, i, s.s->size_shift, ' ');    }       pop_n_elems(args);    push_string(finish_string_builder(&s));    }   }   /*! @endclass define    */    + PIKEFUN string handle_include(string header_file, string current_file, +  int(0..1) is_local_ref) + { +  APPLY_MASTER("handle_include", args); + } +  + PIKEFUN string read_include(string filename) + { +  APPLY_MASTER("read_include", args); + } +  + PIKEFUN string decode_charset(string data, string charset) + { +  APPLY_MASTER("decode_charset", args); + } +    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
pike.git/src/cpp.cmod:439:    */   PIKECLASS CPP    program_flags PROGRAM_USES_PARENT|PROGRAM_NEEDS_PARENT;   {    PIKEVAR mapping(string:object(define)) defines flags ID_PRIVATE|ID_PROTECTED;    PIKEVAR int current_line;    PIKEVAR int compile_errors;    PIKEVAR string current_file;    PIKEVAR string charset;    CVAR struct string_builder buf; + #ifdef SUPPORT_HANDLERS    PIKEVAR object handler;    PIKEVAR object compat_handler; -  + #endif    PIKEVAR int compat_major;    PIKEVAR int compat_minor;    PIKEVAR string prefix;    PIKEVAR int picky_cpp;    PIKEVAR int keep_comments;    PIKEVAR int dependencies_fail;    PIKEVAR int auto_convert;       PIKEVAR mapping(string:function(string:string)) directives flags ID_PROTECTED;   
pike.git/src/cpp.cmod:971:    *!    *! @returns    *! Returns the value of @[sym] if found, and @[UNDEFINED] if not.    */    PIKEFUN mixed resolv(string sym)    {    struct CPP_struct *this = THIS;       ref_push_string(sym);    ref_push_string(this->current_file); + #ifdef SUPPORT_HANDLERS    if (this->handler) {    ref_push_object(this->handler);    } else {    push_undefined();    }    if (this->compat_handler) {    ref_push_object(this->compat_handler);    } else {    push_undefined();    } -  + #else +  push_undefined(); +  push_undefined(); + #endif       apply_external(1, CE_RESOLV_FUN_NUM, 4);    }       PIKEFUN mapping|object|program handle_import(string module)    {    struct CPP_struct *this = THIS;    ref_push_string(module);    ref_push_string(this->current_file); -  + #ifdef SUPPORT_HANDLERS    if (this->handler) {    ref_push_object(this->handler);    } else {    push_int(0);    }    low_unsafe_apply_handler("handle_import",    this->handler, this->compat_handler, 3); -  + #else +  apply_external(1, CE_HANDLE_IMPORT_FUN_NUM, 2); + #endif    }       PIKEFUN string handle_include(string header_file, string current_file,    int(0..1) is_local_ref)    { -  + #ifdef SUPPORT_HANDLERS    struct CPP_struct *this = THIS;    low_unsafe_apply_handler("handle_include",    this->handler, this->compat_handler, args); -  + #else +  apply_external(1, f_handle_include_fun_num, args); + #endif    }       PIKEFUN string read_include(string filename)    { -  + #ifdef SUPPORT_HANDLERS    struct CPP_struct *this = THIS;    low_unsafe_apply_handler("read_include",    this->handler, this->compat_handler, args); -  + #else +  apply_external(1, f_read_include_fun_num, args); + #endif    }       PIKEFUN string decode_charset(string data, string charset)    { -  + #ifdef SUPPORT_HANDLERS    struct CPP_struct *this = THIS;    low_unsafe_apply_handler("decode_charset",    this->handler, this->compat_handler, args); -  + #else +  apply_external(1, f_decode_charset_fun_num, args); + #endif    }      /* #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.    *!
pike.git/src/cpp.cmod:5107:    if (GET_TYPE(STRING, "current_file")) current_file = tmp->u.string;    if ((tmp = simple_mapping_string_lookup(m, "charset"))) {    if ((TYPEOF(*tmp) == PIKE_T_STRING) ||    (TYPEOF(*tmp) == PIKE_T_INT)) {    charset_sv = tmp;    } else {    Pike_error("Expected type string|int, got type %s for charset.",    get_name_of_type(TYPEOF(*tmp)));    }    } + #ifdef SUPPORT_HANDLERS    if (GET_TYPE(OBJECT, "handler")) handler = tmp->u.object; -  + #endif    if (GET_TYPE(INT, "compat_major")) compat_major = tmp->u.integer;    if (GET_TYPE(INT, "compat_minor")) compat_minor = tmp->u.integer;    if (GET_TYPE(INT, "picky")) picky_cpp = tmp->u.integer;    if (GET_TYPE(STRING, "prefix")) prefix = tmp->u.string;    if (GET_TYPE(INT, "keep_comments")) this->keep_comments = tmp->u.integer;    if (GET_TYPE(MAPPING, "predefines")) {    ref_push_mapping(tmp->u.mapping);    apply_current(f_CPP_define_multiple_macros_fun_num, 1);    pop_stack();    }
pike.git/src/cpp.cmod:5152:    string_builder_binary_strcat(&this->buf, "#line 1 ", 8);    PUSH_STRING_SHIFT(current_file->str,    current_file->len,    current_file->size_shift,    &this->buf);    string_builder_putchar(&this->buf, '\n');    }       this->compat_major=PIKE_MAJOR_VERSION;    this->compat_minor=PIKE_MINOR_VERSION; + #ifdef SUPPORT_HANDLERS    if (this->compat_handler) {    free_object(this->compat_handler);    }    this->compat_handler = 0;    if (this->handler) {    free_object(this->handler);    }    this->handler = handler;    if(handler)    add_ref(handler); -  + #endif       if (this->prefix) {    free_string(this->prefix);    this->prefix = NULL;    }    if (prefix) {    int i;    if (prefix->size_shift) {    Pike_error("No widechars allowed in cpp prefix.\n");    }
pike.git/src/cpp.cmod:5461:    *! @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()    { - #if 0 + #ifndef SUPPORT_HANDLERS    apply_external(1, f_get_predefines_fun_num, args);   #else    struct CPP_struct *this = THIS;    if (use_initial_predefs) {    push_mapping(initial_predefs_mapping());    } else {    low_unsafe_apply_handler("get_predefines",    this->handler, this->compat_handler, 0);    }   #endif
pike.git/src/cpp.cmod:5642:    defined_macro->args=1;    defined_macro_sval = Pike_sp[-1];    Pike_sp--;   }      void init_cpp(void)   {    struct svalue s;       ADD_INT_CONSTANT("__HAVE_CPP_PREFIX_SUPPORT__", 1, 0); + #ifndef SUPPORT_HANDLERS +  ADD_INT_CONSTANT("__HAVE_CPP_NO_HANDLERS__", 1, 0); + #endif       /* Somewhat tricky to add a _constant_ function in _static_modules.Builtin. */    SET_SVAL(s, T_FUNCTION, FUNCTION_BUILTIN, efun,    make_callable (f__take_over_initial_predefines,    "_take_over_initial_predefines",    "function(void:mapping(string:string))",    OPT_SIDE_EFFECT, NULL, NULL));    simple_add_constant ("_take_over_initial_predefines", &s, 0);    free_svalue (&s);   }