All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNamespace.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreNamespace.h
Qore Programming Language
Copyright 2003 - 2013 David Nichols
namespaces are children of a program object. there is a parse
lock per program object to ensure that objects are added (or backed out)
atomically per program object. All the objects referenced here should
be safe to read & copied at all times. They will only be deleted when the
program object is deleted (except the pending structures, which will be
deleted any time there is a parse error, together with all other
pending structures)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_QORENAMESPACE_H
#define _QORE_QORENAMESPACE_H
#include <string.h>
#include <stdlib.h>
#include <string>
typedef QoreClass *(*q_ns_class_handler_t)(QoreNamespace *ns, const char *cname);
class QoreNamespace {
friend class QoreNamespaceList;
friend class RootQoreNamespace;
friend class qore_ns_private;
friend class qore_root_ns_private;
friend struct NSOInfoBase;
private:
DLLLOCAL QoreNamespace(const QoreNamespace&);
DLLLOCAL QoreNamespace& operator=(const QoreNamespace&);
protected:
class qore_ns_private *priv; // private implementation
// protected, function not exported in the API
DLLLOCAL QoreNamespace(qore_ns_private* p);
public:
DLLEXPORT QoreNamespace(const char *n);
DLLEXPORT ~QoreNamespace();
DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value);
DLLEXPORT void addConstant(const char *name, AbstractQoreNode *value, const QoreTypeInfo *typeInfo);
DLLEXPORT void addSystemClass(QoreClass *oc);
DLLEXPORT QoreNamespace *copy(int po) const;
DLLEXPORT QoreNamespace *copy(int64 po = PO_DEFAULT) const;
DLLEXPORT QoreHashNode *getClassInfo() const;
DLLEXPORT QoreHashNode *getConstantInfo() const;
DLLEXPORT QoreHashNode *getInfo() const;
DLLEXPORT const char *getName() const;
DLLEXPORT void addNamespace(QoreNamespace *ns);
DLLEXPORT void addInitialNamespace(QoreNamespace *ns);
DLLEXPORT QoreNamespace *findCreateNamespacePath(const char *nspath);
DLLEXPORT QoreClass *findLocalClass(const char *cname) const;
DLLEXPORT QoreNamespace *findLocalNamespace(const char *nsname) const;
DLLEXPORT void setClassHandler(q_ns_class_handler_t class_handler);
DLLEXPORT const QoreNamespace *getParent() const;
DLLEXPORT void deleteData(ExceptionSink *xsink);
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, ...);
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, ...);
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, ...);
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, ...);
};
class RootQoreNamespace : public QoreNamespace {
friend class qore_ns_private;
friend class qore_root_ns_private;
friend class StaticSystemNamespace;
private:
DLLLOCAL RootQoreNamespace(class qore_root_ns_private* p);
protected:
// private implementation
class qore_root_ns_private* rpriv;
public:
DLLEXPORT QoreNamespace *rootGetQoreNamespace() const;
DLLLOCAL ~RootQoreNamespace();
};
#endif // QORE_NAMESPACE_H