1 /* 2 * Copyright 2006-2008 The FLWOR Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 #ifndef ZORBA_EXTERNAL_FUNCTION_ADAPTERS_H 18 #define ZORBA_EXTERNAL_FUNCTION_ADAPTERS_H 19 20 #include <vector> 21 #include <zorba/function.h> 22 23 #include "common/shared_types.h" 24 25 #include "functions/function.h" 26 27 namespace zorba 28 { 29 30 /******************************************************************************* 31 theLoc : The location of the declaration of this external function. 32 theNamespace : The namespace of the module containing the declaration. 33 theScriptingKind : Whether the external function is simple, updating, or 34 sequential (this property is part of the declaration). 35 theImpl : The user-provided c++ class that implements the external 36 function. 37 ********************************************************************************/ 38 class external_function : public function 39 { 40 protected: 41 QueryLoc theLoc; 42 zstring theNamespace; 43 unsigned short theScriptingKind; 44 ExternalFunction * theImpl; 45 46 public: 47 SERIALIZABLE_CLASS(external_function) 48 SERIALIZABLE_CLASS_CONSTRUCTOR2(external_function, function) 49 void serialize(::zorba::serialization::Archiver& ar); 50 51 public: 52 external_function( 53 const QueryLoc& loc, 54 static_context* modSctx, 55 const zstring& ns, 56 const signature& sig, 57 unsigned short scriptingType, 58 ExternalFunction* internal); 59 ~external_function()60 ~external_function() { } 61 getScriptingKind()62 unsigned short getScriptingKind() const { return theScriptingKind; } 63 64 bool accessesDynCtx() const; 65 66 bool propagatesInputNodes(expr* fo, csize input) const; 67 68 bool mustCopyInputNodes(expr* fo, csize input) const; 69 70 PlanIter_t codegen( 71 CompilerCB* /*cb*/, 72 static_context* sctx, 73 const QueryLoc& loc, 74 std::vector<PlanIter_t>& argv, 75 expr& ann) const; 76 }; 77 78 79 } /* namespace zorba */ 80 #endif /* ZORBA_EXTERNAL_FUNCTION_ADAPTERS_H */ 81 82 83 /* 84 * Local variables: 85 * mode: c++ 86 * End: 87 */ 88 /* vim:set et sw=2 ts=2: */ 89