os/ossrv/ossrv_pub/boost_apis/boost/wave/preprocessing_hooks.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*=============================================================================
     2     Boost.Wave: A Standard compliant C++ preprocessor library
     3 
     4     http://www.boost.org/
     5 
     6     Copyright (c) 2001-2007 Hartmut Kaiser. Distributed under the Boost
     7     Software License, Version 1.0. (See accompanying file
     8     LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     9 =============================================================================*/
    10 
    11 #if !defined(PREPROCESSING_HOOKS_HPP_338DE478_A13C_4B63_9BA9_041C917793B8_INCLUDED)
    12 #define PREPROCESSING_HOOKS_HPP_338DE478_A13C_4B63_9BA9_041C917793B8_INCLUDED
    13 
    14 #include <boost/wave/wave_config.hpp>
    15 #include <vector>
    16 
    17 // this must occur after all of the includes and before any code appears
    18 #ifdef BOOST_HAS_ABI_HEADERS
    19 #include BOOST_ABI_PREFIX
    20 #endif
    21 
    22 ///////////////////////////////////////////////////////////////////////////////
    23 namespace boost {
    24 namespace wave {
    25 namespace context_policies {
    26 
    27 ///////////////////////////////////////////////////////////////////////////////
    28 //  
    29 //  The default_preprocessing_hooks class is a placeholder for all 
    30 //  preprocessing hooks called from inside the preprocessing engine
    31 //
    32 ///////////////////////////////////////////////////////////////////////////////
    33 struct default_preprocessing_hooks {
    34 
    35     ///////////////////////////////////////////////////////////////////////////
    36     //  
    37     //  The function 'expanding_function_like_macro' is called, whenever a 
    38     //  function-like macro is to be expanded.
    39     //
    40     //  The macroname parameter marks the position, where the macro to expand 
    41     //  is defined.
    42     //  The formal_args parameter holds the formal arguments used during the
    43     //  definition of the macro.
    44     //  The definition parameter holds the macro definition for the macro to 
    45     //  trace.
    46     //
    47     //  The macro call parameter marks the position, where this macro invoked.
    48     //  The arguments parameter holds the macro arguments used during the 
    49     //  invocation of the macro
    50     //
    51     ///////////////////////////////////////////////////////////////////////////
    52     template <typename TokenT, typename ContainerT>
    53     void expanding_function_like_macro(
    54         TokenT const &macrodef, std::vector<TokenT> const &formal_args, 
    55         ContainerT const &definition,
    56         TokenT const &macrocall, std::vector<ContainerT> const &arguments) 
    57     {}
    58 
    59     ///////////////////////////////////////////////////////////////////////////
    60     //  
    61     //  The function 'expanding_object_like_macro' is called, whenever a 
    62     //  object-like macro is to be expanded .
    63     //
    64     //  The macroname parameter marks the position, where the macro to expand 
    65     //  is defined.
    66     //  The definition parameter holds the macro definition for the macro to 
    67     //  trace.
    68     //
    69     //  The macro call parameter marks the position, where this macro invoked.
    70     //
    71     ///////////////////////////////////////////////////////////////////////////
    72     template <typename TokenT, typename ContainerT>
    73     void expanding_object_like_macro(TokenT const &macro, 
    74         ContainerT const &definition, TokenT const &macrocall)
    75     {}
    76 
    77     ///////////////////////////////////////////////////////////////////////////
    78     //  
    79     //  The function 'expanded_macro' is called, whenever the expansion of a 
    80     //  macro is finished but before the rescanning process starts.
    81     //
    82     //  The parameter 'result' contains the token sequence generated as the 
    83     //  result of the macro expansion.
    84     //
    85     ///////////////////////////////////////////////////////////////////////////
    86     template <typename ContainerT>
    87     void expanded_macro(ContainerT const &result)
    88     {}
    89 
    90     ///////////////////////////////////////////////////////////////////////////
    91     //  
    92     //  The function 'rescanned_macro' is called, whenever the rescanning of a 
    93     //  macro is finished.
    94     //
    95     //  The parameter 'result' contains the token sequence generated as the 
    96     //  result of the rescanning.
    97     //
    98     ///////////////////////////////////////////////////////////////////////////
    99     template <typename ContainerT>
   100     void rescanned_macro(ContainerT const &result)
   101     {}
   102 
   103     ///////////////////////////////////////////////////////////////////////////
   104     //  
   105     //  The function 'found_include_directive' is called, whenever a #include
   106     //  directive was located.
   107     //
   108     //  The parameter 'filename' contains the (expanded) file name found after 
   109     //  the #include directive. This has the format '<file>', '"file"' or 
   110     //  'file'.
   111     //  The formats '<file>' or '"file"' are used for #include directives found 
   112     //  in the preprocessed token stream, the format 'file' is used for files
   113     //  specified through the --force_include command line argument.
   114     //
   115     //  The parameter 'include_next' is set to true if the found directive was
   116     //  a #include_next directive and the BOOST_WAVE_SUPPORT_INCLUDE_NEXT
   117     //  preprocessing constant was defined to something != 0.
   118     //
   119     ///////////////////////////////////////////////////////////////////////////
   120     void 
   121     found_include_directive(std::string const &filename, bool include_next) 
   122     {}
   123     
   124     ///////////////////////////////////////////////////////////////////////////
   125     //  
   126     //  The function 'opened_include_file' is called, whenever a file referred 
   127     //  by an #include directive was successfully located and opened.
   128     //
   129     //  The parameter 'filename' contains the file system path of the 
   130     //  opened file (this is relative to the directory of the currently 
   131     //  processed file or a absolute path depending on the paths given as the
   132     //  include search paths).
   133     //
   134     //  The include_depth parameter contains the current include file depth.
   135     //
   136     //  The is_system_include parameter denotes, whether the given file was 
   137     //  found as a result of a #include <...> directive.
   138     //  
   139     ///////////////////////////////////////////////////////////////////////////
   140     void 
   141     opened_include_file(std::string const &relname, std::string const &absname, 
   142         std::size_t include_depth, bool is_system_include) 
   143     {}
   144     
   145     ///////////////////////////////////////////////////////////////////////////
   146     //  
   147     //  The function 'returning_from_include_file' is called, whenever an
   148     //  included file is about to be closed after it's processing is complete.
   149     //
   150     ///////////////////////////////////////////////////////////////////////////
   151     void
   152     returning_from_include_file() 
   153     {}
   154 
   155     ///////////////////////////////////////////////////////////////////////////
   156     //  
   157     //  The function 'interpret_pragma' is called, whenever a #pragma command 
   158     //  directive is found which isn't known to the core Wave library, where
   159     //  command is the value defined as the BOOST_WAVE_PRAGMA_KEYWORD constant
   160     //  which defaults to "wave".
   161     //
   162     //  The parameter 'ctx' is a reference to the context object used for 
   163     //  instantiating the preprocessing iterators by the user.
   164     //
   165     //  The parameter 'pending' may be used to push tokens back into the input 
   166     //  stream, which are to be used as the replacement text for the whole 
   167     //  #pragma directive.
   168     //
   169     //  The parameter 'option' contains the name of the interpreted pragma.
   170     //
   171     //  The parameter 'values' holds the values of the parameter provided to 
   172     //  the pragma operator.
   173     //
   174     //  The parameter 'act_token' contains the actual #pragma token, which may 
   175     //  be used for error output.
   176     //
   177     //  If the return value is 'false', the whole #pragma directive is 
   178     //  interpreted as unknown and a corresponding error message is issued. A
   179     //  return value of 'true' signs a successful interpretation of the given 
   180     //  #pragma.
   181     //
   182     ///////////////////////////////////////////////////////////////////////////
   183     template <typename ContextT, typename ContainerT>
   184     bool 
   185     interpret_pragma(ContextT const &ctx, ContainerT &pending, 
   186         typename ContextT::token_type const &option, ContainerT const &values, 
   187         typename ContextT::token_type const &act_token)
   188     {
   189         return false;
   190     }
   191 
   192     ///////////////////////////////////////////////////////////////////////////
   193     //
   194     //  The function 'defined_macro' is called, whenever a macro was defined
   195     //  successfully.
   196     //
   197     //  The parameter 'name' is a reference to the token holding the macro name.
   198     //
   199     //  The parameter 'is_functionlike' is set to true, whenever the newly 
   200     //  defined macro is defined as a function like macro.
   201     //
   202     //  The parameter 'parameters' holds the parameter tokens for the macro
   203     //  definition. If the macro has no parameters or if it is a object like
   204     //  macro, then this container is empty.
   205     //
   206     //  The parameter 'definition' contains the token sequence given as the
   207     //  replacement sequence (definition part) of the newly defined macro.
   208     //
   209     //  The parameter 'is_predefined' is set to true for all macros predefined 
   210     //  during the initialisation phase of the library.
   211     //
   212     ///////////////////////////////////////////////////////////////////////////
   213     template <typename TokenT, typename ParametersT, typename DefinitionT>
   214     void
   215     defined_macro(TokenT const &macro_name, bool is_functionlike, 
   216         ParametersT const &parameters, DefinitionT const &definition, 
   217         bool is_predefined)
   218     {}
   219     
   220     ///////////////////////////////////////////////////////////////////////////
   221     //
   222     //  The function 'undefined_macro' is called, whenever a macro definition
   223     //  was removed successfully.
   224     //  
   225     //  The parameter 'name' holds the name of the macro, which definition was 
   226     //  removed.
   227     //
   228     ///////////////////////////////////////////////////////////////////////////
   229     template <typename TokenT>
   230     void
   231     undefined_macro(TokenT const &macro_name)
   232     {}
   233     
   234     ///////////////////////////////////////////////////////////////////////////
   235     //
   236     //  The function 'found_directive' is called, whenever a preprocessor 
   237     //  directive was encountered, but before the corresponding action is 
   238     //  executed.
   239     //
   240     //  The parameter 'directive' is a reference to the token holding the 
   241     //  preprocessing directive.
   242     //
   243     ///////////////////////////////////////////////////////////////////////////
   244     template <typename TokenT>
   245     void
   246     found_directive(TokenT const& directive)
   247     {}
   248 
   249     ///////////////////////////////////////////////////////////////////////////
   250     //
   251     //  The function 'evaluated_conditional_expression' is called, whenever a 
   252     //  conditional preprocessing expression was evaluated (the expression
   253     //  given to a #if, #ifdef or #ifndef directive)
   254     //
   255     //  The parameter 'expression' holds the non-expanded token sequence
   256     //  comprising the evaluated expression.
   257     //
   258     //  The parameter expression_value contains the result of the evaluation of
   259     //  the expression in the current preprocessing context.
   260     //
   261     ///////////////////////////////////////////////////////////////////////////
   262     template <typename ContainerT>
   263     void
   264     evaluated_conditional_expression(ContainerT const& expression, 
   265         bool expression_value)
   266     {}
   267     
   268     ///////////////////////////////////////////////////////////////////////////
   269     //
   270     //  The function 'skipped_token' is called, whenever a token is about to be
   271     //  skipped due to a false preprocessor condition (code fragments to be
   272     //  skipped inside the not evaluated conditional #if/#else/#endif branches).
   273     //
   274     //  The parameter 'token' refers to the token to be skipped.
   275     //  
   276     //
   277     ///////////////////////////////////////////////////////////////////////////
   278     template <typename TokenT>
   279     void
   280     skipped_token(TokenT const& token)
   281     {}
   282 
   283     ///////////////////////////////////////////////////////////////////////////
   284     //
   285     //  The function 'may_skip_whitespace' is called, will be called by the 
   286     //  library, whenever a token is about to be returned to the calling 
   287     //  application. 
   288     //
   289     //  The parameter 'ctx' is a reference to the context object used for 
   290     //  instantiating the preprocessing iterators by the user.
   291     //
   292     //  The 'token' parameter holds a reference to the current token. The policy 
   293     //  is free to change this token if needed.
   294     //
   295     //  The 'skipped_newline' parameter holds a reference to a boolean value 
   296     //  which should be set to true by the policy function whenever a newline 
   297     //  is going to be skipped. 
   298     //
   299     //  If the return value is true, the given token is skipped and the 
   300     //  preprocessing continues to the next token. If the return value is 
   301     //  false, the given token is returned to the calling application. 
   302     //
   303     //  ATTENTION!
   304     //  Caution has to be used, because by returning true the policy function 
   305     //  is able to force skipping even significant tokens, not only whitespace. 
   306     //
   307     ///////////////////////////////////////////////////////////////////////////
   308     template <typename ContextT, typename TokenT>
   309     bool
   310     may_skip_whitespace(ContextT const& ctx, TokenT& token, bool& skipped_newline)
   311     { return false; }
   312 };
   313 
   314 ///////////////////////////////////////////////////////////////////////////////
   315 }   // namespace context_policies
   316 }   // namespace wave
   317 }   // namespace boost
   318 
   319 // the suffix header occurs after all of the code
   320 #ifdef BOOST_HAS_ABI_HEADERS
   321 #include BOOST_ABI_SUFFIX
   322 #endif
   323 
   324 #endif // !defined(PREPROCESSING_HOOKS_HPP_338DE478_A13C_4B63_9BA9_041C917793B8_INCLUDED)