Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/clang-c/CXCppInterOp.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // NOLINTBEGIN()
0002 #ifndef LLVM_CLANG_C_CXCPPINTEROP_H
0003 #define LLVM_CLANG_C_CXCPPINTEROP_H
0004 
0005 #include "clang-c/CXErrorCode.h"
0006 #include "clang-c/CXString.h"
0007 #include "clang-c/ExternC.h"
0008 #include "clang-c/Index.h"
0009 #include "clang-c/Platform.h"
0010 
0011 #include <stdbool.h>
0012 #include <stddef.h>
0013 #include <stdint.h>
0014 
0015 LLVM_CLANG_C_EXTERN_C_BEGIN
0016 
0017 /**
0018  * \defgroup CPPINTEROP_INTERPRETER_MANIP Interpreter manipulations
0019  *
0020  * @{
0021  */
0022 
0023 /**
0024  * An opaque pointer representing an interpreter context.
0025  */
0026 typedef struct CXInterpreterImpl* CXInterpreter;
0027 
0028 /**
0029  * Create a Clang interpreter instance from the given arguments.
0030  *
0031  * \param argv The arguments that would be passed to the interpreter.
0032  *
0033  * \param argc The number of arguments in \c argv.
0034  *
0035  * \returns a \c CXInterpreter.
0036  */
0037 CINDEX_LINKAGE CXInterpreter clang_createInterpreter(const char* const* argv,
0038                                                      int argc);
0039 
0040 typedef void* TInterp_t;
0041 
0042 /**
0043  * Bridge between C API and C++ API.
0044  *
0045  * \returns a \c CXInterpreter.
0046  */
0047 CINDEX_LINKAGE CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I);
0048 
0049 /**
0050  * Returns a pointer to the underlying interpreter.
0051  */
0052 CINDEX_LINKAGE void* clang_Interpreter_getClangInterpreter(CXInterpreter I);
0053 
0054 /**
0055  * Returns a \c TInterp_t and takes the ownership.
0056  */
0057 CINDEX_LINKAGE TInterp_t
0058 clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I);
0059 
0060 /**
0061  * Undo N previous incremental inputs.
0062  */
0063 CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_undo(CXInterpreter I,
0064                                                        unsigned int N);
0065 
0066 /**
0067  * Dispose of the given interpreter context.
0068  */
0069 CINDEX_LINKAGE void clang_Interpreter_dispose(CXInterpreter I);
0070 
0071 /**
0072  * Describes the return result of the different routines that do the incremental
0073  * compilation.
0074  */
0075 typedef enum {
0076   /**
0077    * The compilation was successful.
0078    */
0079   CXInterpreter_Success = 0,
0080   /**
0081    * The compilation failed.
0082    */
0083   CXInterpreter_Failure = 1,
0084   /**
0085    * More more input is expected.
0086    */
0087   CXInterpreter_MoreInputExpected = 2,
0088 } CXInterpreter_CompilationResult;
0089 
0090 /**
0091  * Add a search path to the interpreter.
0092  *
0093  * \param I The interpreter.
0094  *
0095  * \param dir The directory to add.
0096  *
0097  * \param isUser Whether the directory is a user directory.
0098  *
0099  * \param prepend Whether to prepend the directory to the search path.
0100  */
0101 CINDEX_LINKAGE void clang_Interpreter_addSearchPath(CXInterpreter I,
0102                                                     const char* dir,
0103                                                     bool isUser, bool prepend);
0104 
0105 /**
0106  * Add an include path.
0107  *
0108  * \param I The interpreter.
0109  *
0110  * \param dir The directory to add.
0111  */
0112 CINDEX_LINKAGE void clang_Interpreter_addIncludePath(CXInterpreter I,
0113                                                      const char* dir);
0114 
0115 /**
0116  * Declares a code snippet in \c code and does not execute it.
0117  *
0118  * \param I The interpreter.
0119  *
0120  * \param code The code snippet to declare.
0121  *
0122  * \param silent Whether to suppress the diagnostics or not
0123  *
0124  * \returns a \c CXErrorCode.
0125  */
0126 CINDEX_LINKAGE enum CXErrorCode
0127 clang_Interpreter_declare(CXInterpreter I, const char* code, bool silent);
0128 
0129 /**
0130  * Declares and executes a code snippet in \c code.
0131  *
0132  * \param I The interpreter.
0133  *
0134  * \param code The code snippet to execute.
0135  *
0136  * \returns a \c CXErrorCode.
0137  */
0138 CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_process(CXInterpreter I,
0139                                                           const char* code);
0140 
0141 /**
0142  * An opaque pointer representing a lightweight struct that is used for carrying
0143  * execution results.
0144  */
0145 typedef void* CXValue;
0146 
0147 /**
0148  * Create a CXValue.
0149  *
0150  * \returns a \c CXValue.
0151  */
0152 CINDEX_LINKAGE CXValue clang_createValue(void);
0153 
0154 /**
0155  * Dispose of the given CXValue.
0156  *
0157  * \param V The CXValue to dispose.
0158  */
0159 CINDEX_LINKAGE void clang_Value_dispose(CXValue V);
0160 
0161 /**
0162  * Declares, executes and stores the execution result to \c V.
0163  *
0164  * \param[in] I The interpreter.
0165  *
0166  * \param[in] code The code snippet to evaluate.
0167  *
0168  * \param[out] V The value to store the execution result.
0169  *
0170  * \returns a \c CXErrorCode.
0171  */
0172 CINDEX_LINKAGE enum CXErrorCode
0173 clang_Interpreter_evaluate(CXInterpreter I, const char* code, CXValue V);
0174 
0175 /**
0176  * Looks up the library if access is enabled.
0177  *
0178  * \param I The interpreter.
0179  *
0180  * \param lib_name The name of the library to lookup.
0181  *
0182  * \returns the path to the library.
0183  */
0184 CINDEX_LINKAGE CXString clang_Interpreter_lookupLibrary(CXInterpreter I,
0185                                                         const char* lib_name);
0186 
0187 /**
0188  * Finds \c lib_stem considering the list of search paths and loads it by
0189  * calling dlopen.
0190  *
0191  * \param I The interpreter.
0192  *
0193  * \param lib_stem The stem of the library to load.
0194  *
0195  * \param lookup Whether to lookup the library or not.
0196  *
0197  * \returns a \c CXInterpreter_CompilationResult.
0198  */
0199 CINDEX_LINKAGE CXInterpreter_CompilationResult clang_Interpreter_loadLibrary(
0200     CXInterpreter I, const char* lib_stem, bool lookup);
0201 
0202 /**
0203  * Finds \c lib_stem considering the list of search paths and unloads it by
0204  * calling dlclose.
0205  *
0206  * \param I The interpreter.
0207  *
0208  * \param lib_stem The stem of the library to unload.
0209  */
0210 CINDEX_LINKAGE void clang_Interpreter_unloadLibrary(CXInterpreter I,
0211                                                     const char* lib_stem);
0212 
0213 /**
0214  * @}
0215  */
0216 
0217 /**
0218  * \defgroup CPPINTEROP_SCOPE_MANIP Scope manipulations
0219  *
0220  * @{
0221  */
0222 
0223 /**
0224  * A fake CXCursor for working with the interpreter.
0225  * It has the same structure as CXCursor, but unlike CXCursor, it stores a
0226  * handle to the interpreter in the third slot of the data field.
0227  * This pave the way for upstreaming features to the LLVM project.
0228  */
0229 typedef struct {
0230   enum CXCursorKind kind;
0231   int xdata;
0232   const void* data[3];
0233 } CXScope;
0234 
0235 // for debugging purposes
0236 CINDEX_LINKAGE void clang_scope_dump(CXScope S);
0237 
0238 /**
0239  * Checks if a class has a default constructor.
0240  */
0241 CINDEX_LINKAGE bool clang_hasDefaultConstructor(CXScope S);
0242 
0243 /**
0244  * Returns the default constructor of a class, if any.
0245  */
0246 CINDEX_LINKAGE CXScope clang_getDefaultConstructor(CXScope S);
0247 
0248 /**
0249  * Returns the class destructor, if any.
0250  */
0251 CINDEX_LINKAGE CXScope clang_getDestructor(CXScope S);
0252 
0253 /**
0254  * Returns a stringified version of a given function signature in the form:
0255  * void N::f(int i, double d, long l = 0, char ch = 'a').
0256  */
0257 CINDEX_LINKAGE CXString clang_getFunctionSignature(CXScope func);
0258 
0259 /**
0260  * Checks if a function is a templated function.
0261  */
0262 CINDEX_LINKAGE bool clang_isTemplatedFunction(CXScope func);
0263 
0264 /**
0265  * This function performs a lookup to check if there is a templated function of
0266  * that type. \c parent is mandatory, the global scope should be used as the
0267  * default value.
0268  */
0269 CINDEX_LINKAGE bool clang_existsFunctionTemplate(const char* name,
0270                                                  CXScope parent);
0271 
0272 typedef struct {
0273   void* Type;
0274   const char* IntegralValue;
0275 } CXTemplateArgInfo;
0276 
0277 /**
0278  * Builds a template instantiation for a given templated declaration.
0279  * Offers a single interface for instantiation of class, function and variable
0280  * templates.
0281  *
0282  * \param[in] tmpl The uninstantiated template class/function.
0283  *
0284  * \param[in] template_args The pointer to vector of template arguments stored
0285  * in the \c TemplateArgInfo struct
0286  *
0287  * \param[in] template_args_size The size of the vector of template arguments
0288  * passed as \c template_args
0289  *
0290  * \returns a \c CXScope representing the instantiated templated
0291  * class/function/variable.
0292  */
0293 CINDEX_LINKAGE CXScope clang_instantiateTemplate(
0294     CXScope tmpl, CXTemplateArgInfo* template_args, size_t template_args_size);
0295 
0296 /**
0297  * A fake CXType for working with the interpreter.
0298  * It has the same structure as CXType, but unlike CXType, it stores a
0299  * handle to the interpreter in the second slot of the data field.
0300  */
0301 typedef struct {
0302   enum CXTypeKind kind;
0303   void* data[2];
0304 } CXQualType;
0305 
0306 /**
0307  * Gets the string of the type that is passed as a parameter.
0308  */
0309 CINDEX_LINKAGE CXString clang_getTypeAsString(CXQualType type);
0310 
0311 /**
0312  * Returns the complex of the provided type.
0313  */
0314 CINDEX_LINKAGE CXQualType clang_getComplexType(CXQualType eltype);
0315 
0316 /**
0317  * An opaque pointer representing the object of a given type (\c CXScope).
0318  */
0319 typedef void* CXObject;
0320 
0321 /**
0322  * Allocates memory for the given type.
0323  */
0324 CINDEX_LINKAGE CXObject clang_allocate(unsigned int n);
0325 
0326 /**
0327  * Deallocates memory for a given class.
0328  */
0329 CINDEX_LINKAGE void clang_deallocate(CXObject address);
0330 
0331 /**
0332  * Creates an object of class \c scope and calls its default constructor. If \c
0333  * arena is set it uses placement new.
0334  */
0335 CINDEX_LINKAGE CXObject clang_construct(CXScope scope, void* arena);
0336 
0337 /**
0338  * Creates a trampoline function and makes a call to a generic function or
0339  * method.
0340  *
0341  * \param func The function or method to call.
0342  *
0343  * \param result The location where the return result will be placed.
0344  *
0345  * \param args The arguments to pass to the invocation.
0346  *
0347  * \param n The number of arguments.
0348  *
0349  * \param self The 'this pointer' of the object.
0350  */
0351 CINDEX_LINKAGE void clang_invoke(CXScope func, void* result, void** args,
0352                                  size_t n, void* self);
0353 
0354 /**
0355  * Calls the destructor of object of type \c type. When withFree is true it
0356  * calls operator delete/free.
0357  *
0358  * \param This The object to destruct.
0359  *
0360  * \param type The type of the object.
0361  *
0362  * \param withFree Whether to call operator delete/free or not.
0363  */
0364 CINDEX_LINKAGE void clang_destruct(CXObject This, CXScope S, bool withFree);
0365 
0366 /**
0367  * @}
0368  */
0369 
0370 LLVM_CLANG_C_EXTERN_C_END
0371 
0372 #endif // LLVM_CLANG_C_CXCPPINTEROP_H
0373        // NOLINTEND()