This commit is contained in:
King_DuckZ 2020-02-17 22:22:42 +01:00
parent feed734f17
commit 824eb94695
3514 changed files with 90507 additions and 92619 deletions

View file

@ -1,8 +1,8 @@
/*
* Copyright (c) 2001-2008
* Copyright (c) 2001, 2008,
* DecisionSoft Limited. All rights reserved.
* Copyright (c) 2004-2008
* Oracle. All rights reserved.
* Copyright (c) 2004, 2011,
* Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -15,8 +15,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id$
*/
#ifndef XQUSERFUNCTION_HPP
@ -25,13 +23,14 @@
#include <xqilla/framework/XQillaExport.hpp>
#include <xqilla/functions/FuncFactory.hpp>
#include <xqilla/functions/ExternalFunction.hpp>
#include <xqilla/schema/SequenceType.hpp>
#include <xqilla/schema/DocumentCache.hpp>
#include <xqilla/ast/XQFunction.hpp>
#include <xqilla/ast/StaticAnalysis.hpp>
#include <xqilla/context/impl/VarStoreImpl.hpp>
class XQUserFunction;
class XQQuery;
class FunctionSignature;
class DocumentCache;
class VarStoreImpl;
class XQILLA_API XQUserFunctionInstance : public XQFunction, public ExternalFunction::Arguments
{
@ -59,26 +58,6 @@ public:
bool getAddReturnCheck() const { return addReturnCheck_; }
protected:
class FunctionEvaluatorResult : public ResultImpl
{
public:
FunctionEvaluatorResult(const XQUserFunctionInstance *di, DynamicContext *context);
Item::Ptr nextOrTail(Result &tail, DynamicContext *context);
private:
const XQUserFunctionInstance *_di;
};
class ExternalFunctionEvaluatorResult : public ResultImpl
{
public:
ExternalFunctionEvaluatorResult(const XQUserFunctionInstance *di);
Item::Ptr nextOrTail(Result &tail, DynamicContext *context);
private:
const XQUserFunctionInstance *_di;
};
bool addReturnCheck_;
const XQUserFunction *funcDef_;
};
@ -86,7 +65,7 @@ protected:
class XQILLA_API XQUserFunction : public FuncFactory, public LocationInfo
{
public:
class Mode : public LocationInfo
class XQILLA_API Mode : public LocationInfo
{
public:
enum State {
@ -120,56 +99,10 @@ public:
typedef std::vector<Mode*,XQillaAllocator<Mode*> > ModeList;
class ArgumentSpec : public LocationInfo
{
public:
ArgumentSpec(const XMLCh *qname, SequenceType *type, XPath2MemoryManager *memMgr)
: qname_(memMgr->getPooledString(qname)),
uri_(0),
name_(0),
used_(true),
seqType_(type),
src_(memMgr)
{
}
ArgumentSpec(const ArgumentSpec *o, XPath2MemoryManager *memMgr)
: qname_(o->qname_),
uri_(o->uri_),
name_(o->name_),
used_(o->used_),
seqType_(o->seqType_),
src_(memMgr)
{
}
const XMLCh *getURI() const { return uri_; }
void setURI(const XMLCh *uri) { uri_ = uri; }
const XMLCh *getName() const { return name_; }
void setName(const XMLCh *name) { name_ = name; }
const XMLCh *getQName() const { return qname_; }
SequenceType *getType() const { return seqType_; }
void setType(SequenceType *type) { seqType_ = type; }
bool isUsed() const { return used_; }
void setNotUsed() { used_ = false; }
const StaticAnalysis &getStaticAnalysis() const { return src_; }
void staticResolution(StaticContext* context);
private:
const XMLCh *qname_, *uri_, *name_;
bool used_;
SequenceType *seqType_;
StaticAnalysis src_;
};
typedef std::vector<ArgumentSpec*,XQillaAllocator<ArgumentSpec*> > ArgumentSpecs;
// Constructor for an XQuery function
XQUserFunction(const XMLCh *qname, ArgumentSpecs *argSpecs, ASTNode *body, SequenceType *returnType, bool isUpdating, bool isGlobal, XPath2MemoryManager *mm);
XQUserFunction(const XMLCh *qname, FunctionSignature *signature, ASTNode *body, bool isGlobal, XPath2MemoryManager *mm);
// Constructor for an XQuery template
XQUserFunction(const XMLCh *qname, VectorOfASTNodes *pattern, ArgumentSpecs *argSpecs, ASTNode *body, SequenceType *returnType, XPath2MemoryManager *mm);
XQUserFunction(const XMLCh *qname, VectorOfASTNodes *pattern, FunctionSignature *signature, ASTNode *body, XPath2MemoryManager *mm);
// from FuncFactory
virtual ASTNode *createInstance(const VectorOfASTNodes &args, XPath2MemoryManager* expr) const;
@ -183,21 +116,20 @@ public:
ModeList *getModeList() const { return modes_; }
void setModeList(ModeList *modes) { modes_ = modes; }
const ArgumentSpecs* getArgumentSpecs() const { return argSpecs_; }
void setArgumentSpecs(ArgumentSpecs *argSpecs) { argSpecs_ = argSpecs; }
const SequenceType* getReturnType() const { return returnType_; }
void setReturnType(SequenceType *returnType) { returnType_ = returnType; }
FunctionSignature *getSignature() const { return signature_; }
ASTNode *getTemplateInstance() const { return templateInstance_; }
void setTemplateInstance(ASTNode *ast) { templateInstance_ = ast; }
bool isGlobal() const { return isGlobal_; }
bool isUpdating() const { return isUpdating_; }
bool isTemplate() const { return isTemplate_; }
bool isRecursive() const { return recursive_; }
bool isDelayed() const { return delayed_; }
void setDelayed(bool v) { delayed_ = v; }
void resolveName(StaticContext *context);
/// Resolve URIs, give the function a default static type
void staticResolutionStage1(StaticContext* context);
/// Resolve the function body, work out a more static return type
@ -234,16 +166,16 @@ protected:
ASTNode *templateInstance_;
ModeList *modes_;
SequenceType *returnType_;
ArgumentSpecs *argSpecs_;
FunctionSignature *signature_;
bool isGlobal_;
bool isUpdating_;
bool isTemplate_;
XPath2MemoryManager *memMgr_;
StaticAnalysis src_;
bool staticTyped_;
enum StaticTypingStatus { BEFORE, DURING, AFTER } staticTyped_;
bool recursive_;
bool delayed_;
DocumentCache *moduleDocCache_;
friend class XQUserFunctionInstance;
@ -251,4 +183,23 @@ protected:
friend class ASTReleaser;
};
class XQILLA_API DelayedFuncFactory : public FuncFactory
{
public:
DelayedFuncFactory(const XMLCh *uri, const XMLCh *name, size_t numArgs,
const XMLCh *body, int line, int column, XQQuery *query);
DelayedFuncFactory(const XMLCh *uri, const XMLCh *name, size_t numArgs,
const char *body, int line, int column, XQQuery *query);
virtual ASTNode *createInstance(const VectorOfASTNodes &args, XPath2MemoryManager* memMgr) const;
bool isParsed() const { return function_ != 0; }
private:
const XMLCh *body_;
const char *body8_;
int line_, column_;
XQQuery *query_;
XQUserFunction *function_;
};
#endif