Qore Programming Language: include/qore/QoreNamespace.h (6585) Source File

Qore Programming Language 0.8.11

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNamespace.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3 QoreNamespace.h
4
5 Qore Programming Language
6
7 Copyright 2003 - 2013 David Nichols
8
9 namespaces are children of a program object. there is a parse
10 lock per program object to ensure that objects are added (or backed out)
11 atomically per program object. All the objects referenced here should
12 be safe to read & copied at all times. They will only be deleted when the
13 program object is deleted (except the pending structures, which will be
14 deleted any time there is a parse error, together with all other
15 pending structures)
16
17 This library is free software; you can redistribute it and/or
18 modify it under the terms of the GNU Lesser General Public
19 License as published by the Free Software Foundation; either
20 version 2.1 of the License, or (at your option) any later version.
21
22 This library is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 Lesser General Public License for more details.
26
27 You should have received a copy of the GNU Lesser General Public
28 License along with this library; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32 #ifndef _QORE_QORENAMESPACE_H
33
34 #define _QORE_QORENAMESPACE_H
35
36 #include <string.h>
37 #include <stdlib.h>
38
39 #include <string>
40
42
47 typedef QoreClass *(*q_ns_class_handler_t)(QoreNamespace *ns, const char *cname);
48
50 class QoreNamespace {
51 friend class QoreNamespaceList;
52 friend class RootQoreNamespace;
53 friend class qore_ns_private;
54 friend class qore_root_ns_private;
55 friend struct NSOInfoBase;
56
57 private:
59 DLLLOCAL QoreNamespace(const QoreNamespace&);
60
62 DLLLOCAL QoreNamespace& operator=(const QoreNamespace&);
63
64 protected:
65 class qore_ns_private *priv; // private implementation
66
67 // protected, function not exported in the API
68 DLLLOCAL QoreNamespace(qore_ns_private* p);
69
70 public:
72
75 DLLEXPORT QoreNamespace(const char *n);
76
78 DLLEXPORT ~QoreNamespace();
79
81
87 DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value);
88
90
96 DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value, const QoreTypeInfo *typeInfo);
97
99
102 DLLEXPORT void addSystemClass(QoreClass *oc);
103
105
108 DLLEXPORT QoreNamespace *copy(int po) const;
109
111
114 DLLEXPORT QoreNamespace *copy(int64 po = PO_DEFAULT) const;
115
117
122 DLLEXPORT QoreHashNode *getClassInfo() const;
123
125
130 DLLEXPORT QoreHashNode *getConstantInfo() const;
131
133
139 DLLEXPORT QoreHashNode *getInfo() const;
140
142
145 DLLEXPORT const char *getName() const;
146
148
151 DLLEXPORT void addNamespace(QoreNamespace *ns);
152
154
159 DLLEXPORT void addInitialNamespace(QoreNamespace *ns);
160
162
166 DLLEXPORT QoreNamespace *findCreateNamespacePath(const char *nspath);
167
169
174 DLLEXPORT QoreClass *findLocalClass(const char *cname) const;
175
177
181 DLLEXPORT QoreNamespace *findLocalNamespace(const char *nsname) const;
182
184
187 DLLEXPORT void setClassHandler(q_ns_class_handler_t class_handler);
188
190
192 DLLEXPORT const QoreNamespace *getParent() const;
193
195 DLLEXPORT void deleteData(ExceptionSink *xsink);
196
197 DLLEXPORT void addBuiltinVariant(const char* name, q_func_t f, int64 code_flags = QC_NO_FLAGS, int64 functional_domain = QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo = 0, unsigned num_params = 0, ...);
198
199 DLLEXPORT void addBuiltinVariant(const char* name, q_func_int64_t f, int64 code_flags = QC_NO_FLAGS, int64 functional_domain = QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo = 0, unsigned num_params = 0, ...);
200
201 DLLEXPORT void addBuiltinVariant(const char* name, q_func_double_t f, int64 code_flags = QC_NO_FLAGS, int64 functional_domain = QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo = 0, unsigned num_params = 0, ...);
202
203 DLLEXPORT void addBuiltinVariant(const char* name, q_func_bool_t f, int64 code_flags = QC_NO_FLAGS, int64 functional_domain = QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo = 0, unsigned num_params = 0, ...);
204 };
205
207
211 class RootQoreNamespace : public QoreNamespace {
212 friend class qore_ns_private;
213 friend class qore_root_ns_private;
214 friend class StaticSystemNamespace;
215
216 private:
217 DLLLOCAL RootQoreNamespace(class qore_root_ns_private* p);
218
219 protected:
220 // private implementation
221 class qore_root_ns_private* rpriv;
222
223 public:
225
228 DLLEXPORT QoreNamespace *rootGetQoreNamespace() const;
229
231 DLLLOCAL ~RootQoreNamespace();
232 };
233
234 #endif // QORE_NAMESPACE_H
QoreNamespace::getParent
DLLEXPORT const QoreNamespace * getParent() const
returns a pointer to the parent namespace or 0 if there is no parent
PO_DEFAULT
#define PO_DEFAULT
no parse options set by default
Definition: Restrictions.h:69
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:41
QoreNamespace::setClassHandler
DLLEXPORT void setClassHandler(q_ns_class_handler_t class_handler)
sets the namespace class handler
QoreNamespace::~QoreNamespace
DLLEXPORT ~QoreNamespace()
destroys the object and frees all associated memory
QoreNamespace::findLocalNamespace
DLLEXPORT QoreNamespace * findLocalNamespace(const char *nsname) const
finds a subnamespace in this namespace, does not search child namespaces
QoreNamespace::addNamespace
DLLEXPORT void addNamespace(QoreNamespace *ns)
adds a namespace to the namespace tree
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
QoreNamespace
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:50
q_func_int64_t
int64(* q_func_int64_t)(const QoreListNode *args, ExceptionSink *xsink)
the type used for builtin function signatures returning an integer value
Definition: common.h:218
QoreNamespace::getConstantInfo
DLLEXPORT QoreHashNode * getConstantInfo() const
a hash of all constants in the namespace, the hash keys are the constant names and the values are the...
QoreNamespace::getName
DLLEXPORT const char * getName() const
returns the name of the namespace
QoreNamespace::copy
DLLEXPORT QoreNamespace * copy(int po) const
returns a deep copy of the namespace; DEPRECATED: use copy(int64) instead
QoreNamespace::getClassInfo
DLLEXPORT QoreHashNode * getClassInfo() const
gets a hash of all classes in the namespace, the hash keys are the class names and the values are lis...
RootQoreNamespace::rootGetQoreNamespace
DLLEXPORT QoreNamespace * rootGetQoreNamespace() const
returns a pointer to the QoreNamespace for the "Qore" namespace
q_func_t
AbstractQoreNode *(* q_func_t)(const QoreListNode *args, ExceptionSink *xsink)
the type used for builtin function signatures
Definition: common.h:215
RootQoreNamespace
the root namespace of a QoreProgram object
Definition: QoreNamespace.h:211
q_func_double_t
double(* q_func_double_t)(const QoreListNode *args, ExceptionSink *xsink)
the type used for builtin function signatures returning an double value
Definition: common.h:224
QoreClass
defines a Qore-language class
Definition: QoreClass.h:186
QoreNamespace::addInitialNamespace
DLLEXPORT void addInitialNamespace(QoreNamespace *ns)
adds a subnamespace to the namespace
QoreNamespace::findCreateNamespacePath
DLLEXPORT QoreNamespace * findCreateNamespacePath(const char *nspath)
finds a Namespace based on the argument; creates it (or the whole path) if necessary ...
num_params
static unsigned num_params(const QoreListNode *n)
returns the number of arguments passed to the function
Definition: params.h:46
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:35
QoreNamespace::findLocalClass
DLLEXPORT QoreClass * findLocalClass(const char *cname) const
finds a class in this namespace, does not search child namespaces
QoreNamespace::getInfo
DLLEXPORT QoreHashNode * getInfo() const
returns a hash giving information about the definitions in the namespace
QoreNamespace::deleteData
DLLEXPORT void deleteData(ExceptionSink *xsink)
this function must be called before the QoreNamespace object is deleted or a crash could result due i...
QoreNamespace::addSystemClass
DLLEXPORT void addSystemClass(QoreClass *oc)
adds a class to a namespace
QoreNamespace::addConstant
DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value)
adds a constant definition to the namespace
RootQoreNamespace::~RootQoreNamespace
DLLLOCAL ~RootQoreNamespace()
destructor is not exported in the library's public API
q_func_bool_t
bool(* q_func_bool_t)(const QoreListNode *args, ExceptionSink *xsink)
the type used for builtin function signatures returning a boolean value
Definition: common.h:221
QDOM_DEFAULT
#define QDOM_DEFAULT
the default domain (no domain)
Definition: Restrictions.h:102