QoreReflection.h
Go to the documentation of this file.
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
Qore Programming Language
Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_QOREREFLECTION_H
#define _QORE_QOREREFLECTION_H
class QoreExternalVariant {
public:
DLLEXPORT const QoreClass* getClass() const;
DLLEXPORT const char* getSignatureText() const;
DLLEXPORT int64 getCodeFlags() const;
DLLEXPORT bool isModulePublic() const;
DLLEXPORT bool isSynchronized() const;
DLLEXPORT bool isBuiltin() const;
DLLEXPORT bool hasBody() const;
DLLEXPORT int64 getDomain() const;
DLLEXPORT unsigned numParams() const;
DLLEXPORT const QoreTypeInfo* getReturnTypeInfo() const;
DLLEXPORT const type_vec_t& getParamTypeList() const;
DLLEXPORT const arg_vec_t& getDefaultArgList() const;
DLLEXPORT const name_vec_t& getParamNames() const;
DLLEXPORT const QoreExternalProgramLocation* getSourceLocation() const;
private:
DLLLOCAL QoreExternalVariant();
};
class QoreExternalMethodVariant : public QoreExternalVariant {
public:
DLLEXPORT const QoreMethod* getMethod() const;
DLLEXPORT bool isAbstract() const;
DLLEXPORT bool isFinal() const;
DLLEXPORT bool isStatic() const;
DLLEXPORT ClassAccess getAccess() const;
DLLEXPORT const char* getAccessString() const;
private:
DLLLOCAL QoreExternalMethodVariant();
};
class QoreExternalMemberBase {
public:
DLLEXPORT const QoreTypeInfo* getTypeInfo() const;
DLLEXPORT QoreValue getDefaultValue(ExceptionSink* xsink) const;
DLLEXPORT const QoreExternalProgramLocation* getSourceLocation() const;
private:
DLLLOCAL QoreExternalMemberBase();
};
class QoreExternalMemberVarBase : public QoreExternalMemberBase {
public:
DLLEXPORT ClassAccess getAccess() const;
DLLEXPORT const char* getAccessString() const;
private:
DLLLOCAL QoreExternalMemberVarBase();
};
class QoreExternalStaticMember : public QoreExternalMemberVarBase {
public:
DLLEXPORT QoreValue getValue() const;
DLLEXPORT int setValue(const QoreValue val, ExceptionSink* xsink) const;
private:
DLLLOCAL QoreExternalStaticMember();
};
class QoreExternalNormalMember : public QoreExternalMemberVarBase {
public:
DLLEXPORT bool isTransient() const;
private:
DLLLOCAL QoreExternalNormalMember();
};
class QoreExternalProgramLocation {
public:
DLLEXPORT QoreHashNode* getHash() const;
private:
DLLLOCAL QoreExternalProgramLocation();
};
class QoreExternalConstant {
public:
DLLEXPORT const char* getName() const;
DLLEXPORT const char* getModuleName() const;
DLLEXPORT bool isModulePublic() const;
DLLEXPORT bool isBuiltin() const;
DLLEXPORT const QoreTypeInfo* getTypeInfo() const;
DLLEXPORT QoreValue getReferencedValue() const;
DLLEXPORT const QoreExternalProgramLocation* getSourceLocation() const;
DLLEXPORT ClassAccess getAccess() const;
private:
DLLLOCAL QoreExternalConstant();
};
class QoreExternalFunction {
public:
DLLEXPORT const char* getName() const;
DLLEXPORT const char* getModuleName() const;
DLLEXPORT const QoreClass* getClass() const;
DLLEXPORT const QoreExternalVariant* findVariant(const type_vec_t& type_vec, ExceptionSink* xsink) const;
DLLEXPORT bool isBuiltin() const;
DLLEXPORT bool isInjected() const;
DLLEXPORT unsigned numVariants() const;
DLLEXPORT QoreValue evalFunction(const QoreExternalVariant* variant, const QoreListNode* args, QoreProgram* pgm, ExceptionSink* xsink) const;
DLLEXPORT const QoreExternalVariant* getFirstVariant() const;
DLLEXPORT int64 getDomain() const;
DLLEXPORT int64 getCodeFlags() const;
private:
DLLLOCAL QoreExternalFunction();
};
class QoreExternalFunctionIterator {
public:
DLLEXPORT QoreExternalFunctionIterator(const QoreExternalFunction& f);
DLLEXPORT ~QoreExternalFunctionIterator();
DLLEXPORT bool next();
DLLEXPORT const QoreExternalVariant* getVariant();
private:
class qore_external_function_iterator_private* priv;
};
class QoreExternalMethodFunction : public QoreExternalFunction {
public:
DLLEXPORT const QoreMethod* getMethod() const;
DLLEXPORT bool isStatic() const;
private:
DLLLOCAL QoreExternalMethodFunction();
};
class QoreExternalGlobalVar {
public:
DLLEXPORT const char* getName() const;
DLLEXPORT bool isModulePublic() const;
DLLEXPORT bool isBuiltin() const;
DLLEXPORT const QoreTypeInfo* getTypeInfo() const;
DLLEXPORT QoreValue getReferencedValue() const;
DLLEXPORT const QoreExternalProgramLocation* getSourceLocation() const;
DLLEXPORT int setValue(const QoreValue val, ExceptionSink* xsink) const;
private:
DLLLOCAL QoreExternalGlobalVar();
};
DLLEXPORT const char* qore_type_get_name(const QoreTypeInfo* ti);
DLLEXPORT const char* qore_type_get_path(const QoreTypeInfo* ti);
DLLEXPORT bool qore_type_equal(const QoreTypeInfo* ti1, const QoreTypeInfo* ti2);
DLLEXPORT bool qore_type_is_output_compatible(const QoreTypeInfo* ti1, const QoreTypeInfo* ti2);
DLLEXPORT bool qore_type_is_assignable_from(const QoreTypeInfo* ti1, const QoreTypeInfo* ti2);
DLLEXPORT bool qore_type_is_assignable_from(const QoreTypeInfo* ti1, const QoreTypeInfo* ti2, bool& may_not_match);
DLLEXPORT int qore_type_is_assignable_from(const QoreTypeInfo* t, QoreValue value);
DLLEXPORT QoreValue qore_type_assign_value(const QoreTypeInfo* t, const QoreValue value, ExceptionSink* xsink);
DLLEXPORT qore_type_t qore_type_get_base_type(const QoreTypeInfo* t);
DLLEXPORT QoreHashNode* qore_type_get_accept_types(const QoreTypeInfo* t);
DLLEXPORT QoreHashNode* qore_type_get_return_types(const QoreTypeInfo* t);
DLLEXPORT bool qore_type_can_convert_to_scalar(const QoreTypeInfo* ti);
DLLEXPORT bool qore_type_has_default_value(const QoreTypeInfo* ti);
DLLEXPORT QoreValue qore_type_get_default_value(const QoreTypeInfo* ti);
DLLEXPORT bool qore_type_is_input_output_compatible(const QoreTypeInfo* ti1, const QoreTypeInfo* ti2);
#endif
qore_type_get_name
DLLEXPORT const char * qore_type_get_name(const QoreTypeInfo *ti)
returns the name of the type; the argument may be nullptr meaning no type restrictions ...
qore_type_has_default_value
DLLEXPORT bool qore_type_has_default_value(const QoreTypeInfo *ti)
returns true if the type has a default value; the argument may be nullptr meaning no type restriction...
QoreExternalNormalMember
external wrapper base class for class normal members
Definition: QoreReflection.h:174
QoreExternalConstant::getName
DLLEXPORT const char * getName() const
returns the constant name
QoreExternalProgramLocation::getHash
DLLEXPORT QoreHashNode * getHash() const
returns a hash of the given source location
QoreExternalVariant::getParamTypeList
DLLEXPORT const type_vec_t & getParamTypeList() const
returns the parameter types for the variant
QoreExternalConstant
external wrapper class for constants
Definition: QoreReflection.h:200
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
QoreExternalMemberBase::getDefaultValue
DLLEXPORT QoreValue getDefaultValue(ExceptionSink *xsink) const
evaluates the initialization expression for the member and returns the referenced value ...
QoreExternalMethodVariant::getMethod
DLLEXPORT const QoreMethod * getMethod() const
returns the method for a method variant
QoreExternalConstant::isBuiltin
DLLEXPORT bool isBuiltin() const
returns true if the constant is builtin
QoreExternalVariant::isBuiltin
DLLEXPORT bool isBuiltin() const
returns true if the variant is builtin
QoreExternalMethodVariant::getAccessString
DLLEXPORT const char * getAccessString() const
returns a string for the access info for the member
qore_type_is_assignable_from
DLLEXPORT bool qore_type_is_assignable_from(const QoreTypeInfo *ti1, const QoreTypeInfo *ti2)
returns true if ti2&#39;s return type is compatible with ti1 input (i.e. ti1 is assignable from ti2) ...
QoreExternalStaticMember
external wrapper base class for class static members
Definition: QoreReflection.h:153
QoreExternalVariant
external wrapper class for function and call variants
Definition: QoreReflection.h:38
QoreExternalMethodVariant::isFinal
DLLEXPORT bool isFinal() const
returns true if the method variant is final
QoreExternalVariant::isSynchronized
DLLEXPORT bool isSynchronized() const
returns true if the variant has the synchronized flag set
QoreExternalStaticMember::getValue
DLLEXPORT QoreValue getValue() const
returns the current value of the member; caller owns an reference returned
QoreExternalConstant::getTypeInfo
DLLEXPORT const QoreTypeInfo * getTypeInfo() const
returns the type info for the constant
QoreExternalVariant::numParams
DLLEXPORT unsigned numParams() const
returns the number of parameters
QoreExternalConstant::getModuleName
DLLEXPORT const char * getModuleName() const
returns the module name, if any, otherwise returns nullptr
QoreExternalMemberBase::getTypeInfo
DLLEXPORT const QoreTypeInfo * getTypeInfo() const
returns the type info for the member
QoreExternalMethodVariant::getAccess
DLLEXPORT ClassAccess getAccess() const
returns the access info for the member
QoreExternalNormalMember::isTransient
DLLEXPORT bool isTransient() const
returns true if the member is transient (i.e. will not be serialized)
QoreExternalConstant::getReferencedValue
DLLEXPORT QoreValue getReferencedValue() const
returns the value of the constant; caller owns any reference returned
QoreExternalVariant::getParamNames
DLLEXPORT const name_vec_t & getParamNames() const
returns a list of parameter names for the variant
QoreExternalVariant::hasBody
DLLEXPORT bool hasBody() const
returns true if the variant has a function body
QoreExternalMemberBase
external wrapper base class for class and hashdecl members
Definition: QoreReflection.h:118
QoreListNode
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
QoreExternalMemberVarBase
external wrapper base class for class members
Definition: QoreReflection.h:137
qore_type_get_path
DLLEXPORT const char * qore_type_get_path(const QoreTypeInfo *ti)
returns the full namespace path of the type; the argument may be nullptr meaning no type restrictions...
QoreExternalVariant::getSourceLocation
DLLEXPORT const QoreExternalProgramLocation * getSourceLocation() const
returns the source location of the variant
qore_type_is_output_compatible
DLLEXPORT bool qore_type_is_output_compatible(const QoreTypeInfo *ti1, const QoreTypeInfo *ti2)
returns true if ti2&#39;s return type is compatible with ti1&#39;s; either argument may be nullptr meaning no...
QoreClass
defines a Qore-language class
Definition: QoreClass.h:239
QoreExternalVariant::getCodeFlags
DLLEXPORT int64 getCodeFlags() const
returns binary-or-combined code flags
QoreValue
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275
QoreProgram
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only ...
Definition: QoreProgram.h:127
qore_type_get_accept_types
DLLEXPORT QoreHashNode * qore_type_get_accept_types(const QoreTypeInfo *t)
returns a hash of base types accepted by the type
QoreExternalMethodVariant
external wrapper class for method variants
Definition: QoreReflection.h:90
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
QoreExternalVariant::isModulePublic
DLLEXPORT bool isModulePublic() const
returns true if the variant has the module public flag set
qore_type_is_input_output_compatible
DLLEXPORT bool qore_type_is_input_output_compatible(const QoreTypeInfo *ti1, const QoreTypeInfo *ti2)
returns true if the types are compatible with inputs and outputs
name_vec_t
std::vector< std::string > name_vec_t
vector of parameter names for parameter lists
Definition: common.h:257
QoreExternalProgramLocation
external wrapper class for source code location information
Definition: QoreReflection.h:187
QoreExternalStaticMember::setValue
DLLEXPORT int setValue(const QoreValue val, ExceptionSink *xsink) const
sets the value of the member
QoreExternalVariant::getDefaultArgList
DLLEXPORT const arg_vec_t & getDefaultArgList() const
returns a list of default arguments for the variant
qore_type_get_base_type
DLLEXPORT qore_type_t qore_type_get_base_type(const QoreTypeInfo *t)
returns the base type code for the type or NT_ALL for those that don&#39;t have types ...
QoreExternalMemberBase::getSourceLocation
DLLEXPORT const QoreExternalProgramLocation * getSourceLocation() const
returns the source location of the member&#39;s declaration
int64
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
arg_vec_t
std::vector< QoreValue > arg_vec_t
vector of value information for default argument lists
Definition: common.h:254
QoreExternalMethodVariant::isAbstract
DLLEXPORT bool isAbstract() const
returns true if the method variant is abstract
QoreExternalConstant::getSourceLocation
DLLEXPORT const QoreExternalProgramLocation * getSourceLocation() const
returns the source code location of the constant&#39;s definition
qore_type_get_return_types
DLLEXPORT QoreHashNode * qore_type_get_return_types(const QoreTypeInfo *t)
returns a hash of base types returned by the type
QoreExternalMemberVarBase::getAccess
DLLEXPORT ClassAccess getAccess() const
returns the access info for the member
QoreExternalVariant::getClass
DLLEXPORT const QoreClass * getClass() const
returns the class for a method variant or nullptr for a normal variant
qore_type_equal
DLLEXPORT bool qore_type_equal(const QoreTypeInfo *ti1, const QoreTypeInfo *ti2)
returns true if the types are equal; either argument may be nullptr meaning no type restrictions ...
qore_type_t
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:70
QoreExternalMemberVarBase::getAccessString
DLLEXPORT const char * getAccessString() const
returns a string for the access info for the member
QoreExternalVariant::getReturnTypeInfo
DLLEXPORT const QoreTypeInfo * getReturnTypeInfo() const
returns the return type
qore_type_can_convert_to_scalar
DLLEXPORT bool qore_type_can_convert_to_scalar(const QoreTypeInfo *ti)
returns true if the type&#39;s value can be converted to a scalar; the argument may be nullptr meaning no...
QoreExternalConstant::isModulePublic
DLLEXPORT bool isModulePublic() const
returns true if the constant has the module public flag set
type_vec_t
std::vector< const QoreTypeInfo * > type_vec_t
vector of type information for parameter lists
Definition: common.h:251
QoreMethod
a method in a QoreClass
Definition: QoreClass.h:125
qore_type_assign_value
DLLEXPORT QoreValue qore_type_assign_value(const QoreTypeInfo *t, const QoreValue value, ExceptionSink *xsink)
processes the given value by the given type and returns the result; a Qore-language exception is thro...
qore_type_get_default_value
DLLEXPORT QoreValue qore_type_get_default_value(const QoreTypeInfo *ti)
returns the default value of the type (if any); the caller owns any reference returned; the argument ...
QoreExternalVariant::getSignatureText
DLLEXPORT const char * getSignatureText() const
returns the signature for the variant
QoreExternalMethodVariant::isStatic
DLLEXPORT bool isStatic() const
returns true if the method variant is static
QoreExternalVariant::getDomain
DLLEXPORT int64 getDomain() const
returns the functional domain of the variant
QoreExternalConstant::getAccess
DLLEXPORT ClassAccess getAccess() const
returns the access info for the constant