Browse Source

--- Merging r14235 into '.':
A rtl/solaris/x86_64
A rtl/solaris/x86_64/sighnd.inc
A rtl/solaris/x86_64/start.inc
A rtl/solaris/x86_64/sighndh.inc
U rtl/solaris/Makefile
--- Merging r14236 into '.':
U utils/fpcm/fpcmmain.pp
--- Merging r14238 into '.':
U rtl/solaris/x86_64/start.inc
--- Merging r14250 into '.':
G rtl/solaris/x86_64/start.inc
--- Merging r14265 into '.':
U packages/zorba/fpmake.pp
U packages/zorba/Makefile.fpc
U packages/zorba/src/zorba_options.inc
U packages/zorba/src/zorba.inc
A packages/zorba/src/xqc_static_context_consts.inc
A packages/zorba/src/xqc_error.inc
A packages/zorba/src/xqc.pas
D packages/zorba/src/zorba_error.inc
D packages/zorba/src/zorba_static_context_consts.inc
U packages/zorba/Makefile
--- Merging r14266 into '.':
U rtl/solaris/ptypes.inc
U rtl/solaris/ostypes.inc
--- Merging r14267 into '.':
U packages/zorba/src/xqc.pas
--- Merging r14276 into '.':
G utils/fpcm/fpcmmain.pp
--- Merging r14277 into '.':
U tests/webtbs/tw9089c.pp
--- Merging r14313 into '.':
U rtl/darwin/arm/sighnd.inc

# revisions: 14235,14236,14238,14250,14265,14266,14267,14276,14277,14313
------------------------------------------------------------------------
r14235 | pierre | 2009-11-21 01:18:13 +0100 (Sat, 21 Nov 2009) | 1 line
Changed paths:
M /trunk/rtl/solaris/Makefile
A /trunk/rtl/solaris/x86_64
A /trunk/rtl/solaris/x86_64/sighnd.inc
A /trunk/rtl/solaris/x86_64/sighndh.inc
A /trunk/rtl/solaris/x86_64/start.inc

+ x86_64 processor specific solaris files
------------------------------------------------------------------------
------------------------------------------------------------------------
r14236 | pierre | 2009-11-21 01:27:16 +0100 (Sat, 21 Nov 2009) | 1 line
Changed paths:
M /trunk/utils/fpcm/fpcmmain.pp

+ enable x86_64-solaris
------------------------------------------------------------------------
------------------------------------------------------------------------
r14238 | pierre | 2009-11-21 17:12:48 +0100 (Sat, 21 Nov 2009) | 1 line
Changed paths:
M /trunk/rtl/solaris/x86_64/start.inc

* Correct wrong size suffixes
------------------------------------------------------------------------
------------------------------------------------------------------------
r14250 | pierre | 2009-11-21 23:20:15 +0100 (Sat, 21 Nov 2009) | 1 line
Changed paths:
M /trunk/rtl/solaris/x86_64/start.inc

* fix argc error
------------------------------------------------------------------------
------------------------------------------------------------------------
r14265 | ivost | 2009-11-24 13:10:12 +0100 (Tue, 24 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/zorba/Makefile
M /trunk/packages/zorba/Makefile.fpc
M /trunk/packages/zorba/fpmake.pp
A /trunk/packages/zorba/src/xqc.pas
A /trunk/packages/zorba/src/xqc_error.inc (from /trunk/packages/zorba/src/zorba_error.inc:14172)
A /trunk/packages/zorba/src/xqc_static_context_consts.inc (from /trunk/packages/zorba/src/zorba_static_context_consts.inc:14172)
M /trunk/packages/zorba/src/zorba.inc
D /trunk/packages/zorba/src/zorba_error.inc
M /trunk/packages/zorba/src/zorba_options.inc
D /trunk/packages/zorba/src/zorba_static_context_consts.inc

* splittet zorba(dyn).pas into xqc.pas and zorba(dyn).pas

------------------------------------------------------------------------
------------------------------------------------------------------------
r14266 | pierre | 2009-11-24 17:36:20 +0100 (Tue, 24 Nov 2009) | 1 line
Changed paths:
M /trunk/rtl/solaris/ostypes.inc
M /trunk/rtl/solaris/ptypes.inc

fix stat type for x86_64 cpu
------------------------------------------------------------------------
------------------------------------------------------------------------
r14267 | ivost | 2009-11-24 20:20:26 +0100 (Tue, 24 Nov 2009) | 2 lines
Changed paths:
M /trunk/packages/zorba/src/xqc.pas

* added some helper functions

------------------------------------------------------------------------
------------------------------------------------------------------------
r14276 | florian | 2009-11-26 20:39:23 +0100 (Thu, 26 Nov 2009) | 3 lines
Changed paths:
M /trunk/utils/fpcm/fpcmmain.pp

+ mips*
+ armel
- unused variables removed
------------------------------------------------------------------------
------------------------------------------------------------------------
r14277 | jonas | 2009-11-27 11:02:44 +0100 (Fri, 27 Nov 2009) | 2 lines
Changed paths:
M /trunk/tests/webtbs/tw9089c.pp

* fixed libname

------------------------------------------------------------------------
------------------------------------------------------------------------
r14313 | jonas | 2009-12-03 21:21:27 +0100 (Thu, 03 Dec 2009) | 2 lines
Changed paths:
M /trunk/rtl/darwin/arm/sighnd.inc

* fixed clearing fpscr "exception happened" flags

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@14726 -

marco 15 years ago
parent
commit
520200ba09

+ 6 - 2
.gitattributes

@@ -5526,11 +5526,12 @@ packages/zorba/Makefile.fpc svneol=native#text/plain
 packages/zorba/examples/simple/simple.lpi svneol=native#text/plain
 packages/zorba/examples/simple/simple.lpr svneol=native#text/plain
 packages/zorba/fpmake.pp svneol=native#text/plain
+packages/zorba/src/xqc.pas svneol=native#text/plain
+packages/zorba/src/xqc_error.inc svneol=native#text/plain
+packages/zorba/src/xqc_static_context_consts.inc svneol=native#text/plain
 packages/zorba/src/zorba.inc svneol=native#text/plain
 packages/zorba/src/zorba.pas svneol=native#text/plain
-packages/zorba/src/zorba_error.inc svneol=native#text/plain
 packages/zorba/src/zorba_options.inc svneol=native#text/plain
-packages/zorba/src/zorba_static_context_consts.inc svneol=native#text/plain
 packages/zorba/src/zorbadyn.pas svneol=native#text/plain
 rtl/COPYING.FPC -text
 rtl/COPYING.txt svneol=native#text/plain
@@ -6590,6 +6591,9 @@ rtl/solaris/termiosproc.inc svneol=native#text/plain
 rtl/solaris/unxconst.inc svneol=native#text/plain
 rtl/solaris/unxfunc.inc svneol=native#text/plain
 rtl/solaris/unxsockh.inc svneol=native#text/plain
+rtl/solaris/x86_64/sighnd.inc svneol=native#text/plain
+rtl/solaris/x86_64/sighndh.inc svneol=native#text/plain
+rtl/solaris/x86_64/start.inc svneol=native#text/plain
 rtl/sparc/int64p.inc svneol=native#text/plain
 rtl/sparc/makefile.cpu svneol=native#text/plain
 rtl/sparc/math.inc svneol=native#text/plain

+ 63 - 63
packages/zorba/Makefile

@@ -1,10 +1,10 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/01]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/14]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
 BSDs = freebsd netbsd openbsd darwin
-UNIXs = linux $(BSDs) solaris qnx
+UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
 OSNeedsComspecToRunBatch = go32v2 watcom
 FORCE:
@@ -267,178 +267,178 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(F
 override PACKAGE_NAME=zorba
 override PACKAGE_VERSION=0.9.9
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_UNITS+=zorba zorbadyn
+override TARGET_UNITS+=xqc zorba zorbadyn
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -1741,9 +1741,9 @@ else
 UNITDIR_RTL=$(PACKAGEDIR_RTL)
 endif
 ifdef CHECKDEPEND
-$(PACKAGEDIR_RTL)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE)
-override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
+$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE)
 endif
 else
 PACKAGEDIR_RTL=

+ 1 - 1
packages/zorba/Makefile.fpc

@@ -7,7 +7,7 @@ name=zorba
 version=0.9.9
 
 [target]
-units=zorba zorbadyn
+units=xqc zorba zorbadyn
 
 [require]
 

+ 8 - 4
packages/zorba/fpmake.pp

@@ -20,21 +20,25 @@ begin
     P.SourcePath.Add('src');
     P.IncludePath.Add('src');
 
+    T:=P.Targets.AddUnit('xqc.pas');
+      with T.Dependencies do
+        begin
+          AddInclude('xqc_error.inc');
+          AddInclude('xqc_static_context_consts.inc');
+        end;
     T:=P.Targets.AddUnit('zorbadyn.pas');
       with T.Dependencies do
         begin
+          AddUnit('xqc.pas');
           AddInclude('zorba.inc');
-          AddInclude('zorba_error.inc');
           AddInclude('zorba_options.inc');
-          AddInclude('zorba_static_context_consts.inc');
         end;
     T:=P.Targets.AddUnit('zorba.pas');
       with T.Dependencies do
         begin
+          AddUnit('xqc.pas');
           AddInclude('zorba.inc');
-          AddInclude('zorba_error.inc');
           AddInclude('zorba_options.inc');
-          AddInclude('zorba_static_context_consts.inc');
         end;
 
 //    P.ExamplePath.Add('tests/');

+ 2133 - 0
packages/zorba/src/xqc.pas

@@ -0,0 +1,2133 @@
+(*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ *)
+
+{
+  Translation of the zorba headers for FreePascal
+  Copyright(C) 2009 by Ivo Steinmann
+}
+
+unit xqc;
+
+{$mode objfpc}{$H+}
+{$PACKRECORDS C}
+{$MACRO ON}
+
+interface
+
+uses
+  Classes,
+  ctypes;
+
+{$IFDEF UNIX}
+  {$DEFINE extdecl:=cdecl}
+{$ENDIF}
+{$IFDEF WINDOWS}
+  {$DEFINE extdecl:=stdcall}
+{$ENDIF}
+
+{$i xqc_error.inc}
+{$i xqc_static_context_consts.inc}
+
+type
+  pfile = pointer;
+
+  XQC_Implementation = ^XQC_Implementation_s;
+  XQC_Implementation_Ref = ^XQC_Implementation;
+
+  XQC_Query = ^XQC_Query_s;
+  XQC_Query_Ref = ^XQC_Query;
+
+  XQC_StaticContext = ^XQC_StaticContext_s;
+  XQC_StaticContext_Ref = ^XQC_StaticContext;
+
+  XQC_DynamicContext = ^XQC_DynamicContext_s;
+  XQC_DynamicContext_Ref = ^XQC_DynamicContext;
+
+  XQC_Sequence = ^XQC_Sequence_s;
+  XQC_Sequence_Ref = ^XQC_Sequence;
+
+  XQC_Item = ^XQC_Item_s;
+  XQC_Item_Ref = ^XQC_Item;
+
+  XQC_ItemFactory = ^XQC_ItemFactory_s;
+  XQC_ItemFactory_Ref = ^XQC_ItemFactory;
+
+  XQC_Collection = ^XQC_Collection_s;
+  XQC_Collection_Ref = ^XQC_Collection;
+
+  XQC_DataManager = ^XQC_DataManager_s;
+  XQC_DataManager_Ref = ^XQC_DataManager;
+
+  XQC_OutputStream = ^XQC_OutputStream_s;
+  XQC_InputStream = ^XQC_InputStream_s;
+  XQC_ErrorHandler = ^XQC_ErrorHandler_s;
+
+
+// external functions
+  external_function_init = procedure(out user_data: Pointer; global_user_data: Pointer); extdecl;
+
+  external_function_next = function(args: XQC_Sequence; argc: cint; out res: XQC_Item;
+    user_data: Pointer; global_user_data: Pointer): XQUERY_ERROR; extdecl;
+
+  external_function_release = procedure(user_data: Pointer; global_user_data: Pointer); extdecl;
+
+
+(**
+ * The ::XQC_Implementation struct provides factory functions for parsing queries.
+ * An XQC_Implementation object is thread-safe and can be used by multiple threads
+ * of execution at the same time.
+ *
+ * Creating an XQC_Implementation object can be done using the zorba_implementation function.
+ * Once created, the user is responsible for freeing the object by calling
+ * the free() function.
+ * The XQC_Implementation object should not be freed before all objects created using it's
+ * functions have been freed - doing so causes undefined behaviour.
+ *)
+  XQC_Implementation_s = record
+   (**
+    * Creates a static context suitable for use in the parse() and parse_file()
+    * functions. The user is responsible for freeing the ::XQC_StaticContext object returned by calling
+    * XQC_StaticContext::free().
+    *
+    * \param implementation The XQC_Implementation that this function pointer is a member of
+    * \param[out] context The newly created XQC_StaticContext object.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    *)
+    create_context: function(impl: XQC_Implementation; out context: XQC_StaticContext): XQUERY_ERROR; extdecl;
+
+   (**
+    * Prepares a query from a string, returning an ::XQC_Query object.
+    * The user is responsible for freeing the ::XQC_Query object
+    * returned by calling XQC_Query::free().
+    *
+    * \param implementation The XQC_Implementation that this function pointer is a member of.
+    * \param string The query to prepare as a string.
+    * \param context The initial static context for this query, or null to use the default
+    *        static context.
+    * \param handler An optional error handler whose <code>error</code> function is called
+    *                if preparing the query fails.
+    * \param[out] expression The resulting prepared expression.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    * \retval An XQuery static or type error (e.g. XPST*, XPTY* )
+    *)
+    prepare: function(impl: XQC_Implementation; query_string: pchar; context: XQC_StaticContext;
+      handler: XQC_ErrorHandler; out query: XQC_Query): XQUERY_ERROR; extdecl;
+
+    (**
+     * Prepares a query from a FILE pointer, returning an ::XQC_Query object.
+     * The user remains responsible for closing the file after parsing.
+     * The user is responsible for freeing the ::XQC_Query object returned by
+     * calling XQC_Query::free().
+     *
+     * \param implementation The XQC_Implementation that this function pointer is a member of.
+     * \param file The file containing the query to prepare.
+     * \param context The initial static context for this query, or null to use the default
+     *        static context.
+     * \param handler An optional error handler whose <code>error</code> function is called
+     *                if preparing the query fails.
+     * \param[out] expression The resulting prepared expression.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval An XQuery static or type error (e.g. XPST*, XPTY* )
+     *)
+    prepare_file: function(impl: XQC_Implementation; query_file: pfile; context: XQC_StaticContext;
+      handler: XQC_ErrorHandler; out query: XQC_Query): XQUERY_ERROR; extdecl;
+
+    (**
+     * Prepares a query from a ::XQC_InputStream, returning an ::XQC_Query object.
+     * The user is responsible for freeing the ::XQC_Query object returned by
+     * calling XQC_Query::free().
+     *
+     * \param implementation The XQC_Implementation that this function pointer is a member of.
+     * \param stream The input stream returning the query to prepare.
+     *               free will be called on the XQC_InputStream after the query has been read.
+     * \param context The initial static context for this query, or null to use the default
+     *        static context.
+     * \param handler An optional error handler whose <code>error</code> function is called
+     *                if preparing the query fails.
+     * \param[out] expression The resulting prepared expression.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval An XQuery static or type error (e.g. XPST*, XPTY* )
+     *)
+    prepare_stream: function(impl: XQC_Implementation; stream: XQC_InputStream; context: XQC_StaticContext;
+      handler: XQC_ErrorHandler; out query: XQC_Query): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates an item wrapper suitable for use in the ::XQC_Sequence::next function or
+     * the ::XQC_ItemFactory::create functions.
+     * The user is responsible for freeing the XQC_Item object returned by calling
+     * XQC_Item::free().
+     *
+     * \param implementation The XQC_Implementation that this function pointer is a member of
+     * \param[out] item The newly created XQC_Item wrapper object.
+     *
+  	 * \retval ::XQC_NO_ERROR
+  	 * \retval ::XQP0019_INTERNAL_ERROR
+     *)
+    create_item: function(impl: XQC_Implementation; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a XQC_ItemFactory that can be used for creating items, i.e. instances of the
+     * XQuery data model (XDM).
+     * The user is responsible for freeing the XQC_ItemFactory object returned by calling
+     * XQC_ItemFactory::free().
+     *
+     * \param implementation The XQC_Implementation that this function pointer is a member of
+     * \param[out] factory The newly created XQC_ItemFactory  object.
+     *
+  	 * \retval ::XQC_NO_ERROR
+  	 * \retval ::XQP0019_INTERNAL_ERROR
+     *)
+    item_factory: function(impl: XQC_Implementation; out factory: XQC_ItemFactory): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a XQC_DataManager that can be used for managing collections and documents.
+     * The user is responsible for freeing the XQC_DataManager object returned by calling
+     * XQC_DataManager::free().
+     *
+     * \param implementation The XQC_Implementation that this function pointer is a member of
+     * \param[out] data_manager The newly created XQC_DataManager object.
+     *
+  	 * \retval ::XQC_NO_ERROR
+  	 * \retval ::XQP0019_INTERNAL_ERROR
+     *)
+    data_manager: function(impl: XQC_Implementation; out data_manager: XQC_DataManager): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Called to free the resources associated with the XQC_Implementation.
+     *
+     * \param implementation The XQC_Implementation that this function pointer is a member of
+     *)
+    free: procedure(impl: XQC_Implementation); extdecl;
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * The ::XQC_Expression struct represents a pre-parsed query, and allows the user to execute
+ * that query any number of times. An ::XQC_Expression object is thread-safe and
+ * can be used by multiple threads of execution at the same time.
+ *
+ * ::XQC_Expression objects are created by calling the XQC_Implementation::prepare() or
+ * XQC_Implementation::prepare_file() functions.
+ * Once created, the user is responsible for freeing the object by calling the free() function.
+ * The ::XQC_Expression object should be freed before the ::XQC_Implementation object
+ * that created it.
+ *)
+ XQC_Query_s = record
+    (**
+     * This function returns the dynamic context that belongs to this query and
+     * is used during query execution.
+     * The context can be used, for example, to set values of external variables,
+     * the default collation, or the current datetime.
+     * It is only available if the query has been compiled, otherwise
+     * an error is reported. Moreover, the context must not be modified during the
+     * execution of a query (i.e. if a ResultIterator is opened).
+  	 * The user is responsible for freeing the ::XQC_DynamicContext object returned by calling
+  	 * XQC_DynamicContext::free().
+     *
+  	 * \retval ::XQC_NO_ERROR
+  	 * \retval ::XQP0019_INTERNAL_ERROR
+     *)
+    get_dynamic_context: function(query: XQC_Query; out context: XQC_DynamicContext): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * This function returns the static context that belongs to this query.
+     * The static context is only available if the query has been compiled, otherwise
+     * an error is reported.
+     * The context has all the components and values that have been set by the either
+     * the static context that was passed when creating the query and and those that
+     * were set in the prolog of the query.
+     * Note that after compilation of the query the static context is a read only structure.
+  	 * The user is responsible for freeing the ::XQC_StaticContext object returned by calling
+  	 * XQC_StaticContext::free().
+     *
+  	 * \retval ::XQC_NO_ERROR
+  	 * \retval ::XQP0019_INTERNAL_ERROR
+     *)
+    get_static_context: function(query: XQC_Query; out context: XQC_StaticContext): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Executes the query represented by the XQC_Query object and prints the serialized XML
+    * output to the given FILE pointer. The user remains responsible for closing
+    * the file.
+    *
+    * \param query The XQC_Query that this function pointer is a member of.
+    * \param file The FILE pointer to print the serialized result to.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
+    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY* )
+    *)
+    execute: function(query: XQC_Query; fileptr: pfile): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Executes the query represented by the XQC_Query object and prints the serialized
+    * output to the given FILE pointer. The target format of the serialization is
+    * specified by the passed serializer options.
+    *
+    * \param query The XQC_Query that this function pointer is a member of.
+    * \param options The Zorba_SerializerOptions_t that specifies serializer options.
+    * \param file The FILE pointer to print the serialized result to.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
+    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY* )
+    *)
+    serialize_file: function(query: XQC_Query; options: pointer; fileptr: pfile): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Executes the query represented by the XQC_Query object and writes the serialized
+    * output to the given ::XQC_OutputStream. The target format of the serialization is
+    * specified by the passed serializer options.
+    *
+    * \param query The XQC_Query that this function pointer is a member of.
+    * \param options The Zorba_SerializerOptions_t that specifies serializer options.
+    * \param file The XQC_OutputStream to print the serialized result to.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
+    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY*)
+    serialize_stream: function(query: XQC_Query; options: pointer; stream: XQC_OutputStream): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Checks if the query is an updating query.
+    *
+    * \param query The XQC_Query that this function pionter is a member of.
+    *
+    * \retval 1 if query is updating query, else 0
+    *)
+    is_update_query: function(query: XQC_Query): cint; extdecl;
+
+
+   (**
+    * Applies the updates declared in the query represented by the XQC_Query object.
+    *
+    * \param query The XQC_Query that this function pointer is a member of.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
+    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY*)
+    apply_updates: function(query: XQC_Query): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Executes the query represented by the XQC_Query object.
+    * An ::XQC_Sequence object is returned which can be used to examine the results
+    * of the query execution. The user is responsible for freeing the
+    * ::XQC_Sequence object returned by calling XQC_Sequence::free().
+    *
+    * \param query The XQC_Query that this function pointer is a member of.
+    * \param[out] sequence The newly created XQC_Sequence object.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    * \retval ::API0024_CANNOT_ITERATE_OVER_UPDATE_QUERY
+    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY* )
+    *)
+    sequence: function(query: XQC_Query; out sequence: XQC_Sequence): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Sets the error handler whose <code>error</code> function is called
+     * if an error occurs when executing the query.
+     * The user keeps the ownership of this object and is required to freeing
+     * the aquired resources.
+     *)
+    set_error_handler: procedure(query: XQC_Query; handler: XQC_ErrorHandler); extdecl;
+
+
+   (**
+    * Called to free the resources associated with the XQC_Query.
+    *
+    * \param query The XQC_Query that this function pointer is a member of.
+    *)
+    free: procedure(query: XQC_Query); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * The ::XQC_StaticContext struct provides a way to specify values for the static context of
+ * the query to be prepared. An ::XQC_StaticContext object is not thread-safe - threads should
+ * each use their own instance of a ::XQC_StaticContext object (see create_child_context).
+ *
+ * ::XQC_StaticContext objects are created by calling the XQC_Implementation::create_context()
+ * function. Once created, the user is responsible for freeing the object by calling
+ * the free() function.
+ * The ::XQC_StaticContext object should be freed before the ::XQC_Implementation object that
+ * created it.
+ *)
+  XQC_StaticContext_s = record
+   (**
+    * Creates a child context of the given static context.
+    * A child context contains the same information as it's parent context but
+    * it allows the user to override and add information.
+    * The user is responsible for freeing the ::XQC_StaticContext object returned by calling
+    * XQC_StaticContext::free().
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] child_context The newly created XQC_StaticContext object which is
+    *             a child of the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQP0019_INTERNAL_ERROR
+    *)
+    create_child_context: function(context: XQC_StaticContext; out child_context: XQC_StaticContext): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Adds a (prefix, uri) pair to the set of statically known namespaces of
+    * the given context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of.
+    * \param prefix The prefix of the namespace to add to the given XQC_StaticContext.
+    * \param uri    The uri of the namespace to add to the given XQC_StaticContext.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    declare_ns: function(context: XQC_StaticContext; const prefix: pchar; const uri: ppchar): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the namespace uri that belongs to the given prefix.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param prefix The prefix of the namespace to add to the given XQC_StaticContext.
+    * \param[out] result_ns The namespace uri of the namespace registered with the given prefix.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_ns_by_prefix: function(context: XQC_StaticContext; const prefix: pchar; out result_ns: ppchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Sets the value of the default namespace for elements and types.
+     *
+  	 * \param context The XQC_StaticContext that this function pointer is a member of
+     * \param uri The uri of the default element and type namespace to set in the given context.
+     *
+  	 * \retval ::XQC_NO_ERROR
+  	 * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_default_element_and_type_ns: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the default namespace for elements and types.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] uri The uri of the default element and type namespace that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_default_element_and_type_ns: function(context: XQC_StaticContext; out uri: pchar): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the default namespace for functions.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param uri The uri of the default function namespace to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_default_function_ns: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the default namespace for functions set in this static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] uri The uri of the default function namespace that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_default_function_ns: function(context: XQC_StaticContext; out uri: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Add a collation URI.
+     * The URI specifies the locale and collation strength of the collation that is added.
+     * A valid collation URI must begin with http://www.flworfound.org/collations/.
+     * This prefix is followed by a collation strength (i.e. PRIMARY, SECONDARY, TERTIARY,
+     * QUATTERNARY, or IDENTICAL) followed by a '/'.
+     * After the strength a lower-case two- or three-letter ISO-639 language code must follow.
+     * The URI may end with an upper-case two-letter ISO-3166.
+     * For example, http://www.flworfound.org/collations/PRIMARY/en/US
+     * specifies an english language with US begin the country..
+     *
+     * Internally, ICU is used for comparing strings. For detailed description see
+     * http://www.icu-project.org/apiref/icu4c/classCollator.html
+     * and http://www.icu-project.org/apiref/icu4c/classLocale.html
+     *
+     * \param context The XQC_StaticContext that this function pointer is a member of
+     * \param uri The URI of the collation to add.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQST0038
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    add_collation: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Set the URI of the default collation.
+     * (see http://www.w3.org/TR/xquery/#static_context)
+     *
+     * \param context The XQC_StaticContext that this function pointer is a member of
+     * \param uri The URI of the default collation to set
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQST0038
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_default_collation: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Get the URI of the default collation. The uri returned is valid
+     * as long as the corresponding XQC_StaticContext object is valid.
+     *
+     * \param context The XQC_StaticContext that this function pointer is a member of
+     * \param[out] uri The URI of the default collation that is currently set in the given context.
+     *)
+    get_default_collation: function(context: XQC_StaticContext; out uri: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+    * Sets the XQuery processor's version to either xquery_version_1_0 or xquery_version_1_1.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param mode The xquery_version_t to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_xquery_version: function(context: XQC_StaticContext; mode: xquery_version_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the XQuery processor's version that is set in the given static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] mode The xquery_version_t that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_xquery_version: function(context: XQC_StaticContext; out mode: xquery_version_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the XPath 1.0 compatibility mode to either xpath1_0 or xpath2_0.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param mode The xpath1_0compatib_mode_t to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_xpath1_0_mode: function(context: XQC_StaticContext; mode: xpath1_0compatib_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the XPath 1.0 compatibility that is set in the given static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] mode The xpath1_0compatib_mode_t that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_xpath1_0_mode: function(context: XQC_StaticContext; out mode: xpath1_0compatib_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the construction mode to either preserve_cons or strip_cons.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param mode The construction_mode_t to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_construction_mode: function(context: XQC_StaticContext; mode: construction_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the construction mode that is set in the given static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] mode The construction_mode_t that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_construction_mode: function(context: XQC_StaticContext; out mode: construction_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the ordering mode to either order or unordered.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param mode The ordering_mode_t to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_ordering_mode: function(context: XQC_StaticContext; mode: ordering_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the ordering mode that is set in the given static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] mode The ordering_mode_t that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_ordering_mode: function(context: XQC_StaticContext; out mode: ordering_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the default order mode for empty sequences to either empty_least or
+    * empty_greatest
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param mode The order_empty_mode_t to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_default_order_empty_sequences: function(context: XQC_StaticContext; mode: order_empty_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the default order mode for empty sequences that is set in the given
+    * static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] mode The order_empty_mode_t that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_default_order_empty_sequences: function(context: XQC_StaticContext; out mode: order_empty_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the boundary space policy to either preserve_space or strip_space.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param mode The boundary_space_mode_t to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_boundary_space_policy: function(context: XQC_StaticContext; mode: boundary_space_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the boundary space policy that is set in the given static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] mode The boundary_space_mode_t that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_boundary_space_policy: function(context: XQC_StaticContext; out mode: boundary_space_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the copy namespace mode which consists of the preserve and the inherit mode.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param preserve The preserve_mode_t to set in the given context.
+    * \param inherit The inherit_mode_t to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_copy_ns_mode: function(context: XQC_StaticContext; mode: preserve_mode_t; inherit: inherit_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the copy namespace mode as a pair consisting of the preserve and the inherit
+    * mode.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] preserve The preserve_mode_t that is set in the given context.
+    * \param[out] inherit The inherit_mode_t that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_copy_ns_mode: function(context: XQC_StaticContext; out mode: preserve_mode_t; out inherit: inherit_mode_t): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Sets the base uri in the given static context.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param base_uri The base uri to set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    set_base_uri: function(context: XQC_StaticContext; const base_uri: pchar): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Returns the base uri that is set in the given static context.
+    * The returned base uri is only valid as long as the corresponding static context
+    * is valid.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    * \param[out] base_uri The base uri that is set in the given context.
+    *
+    * \retval ::XQC_NO_ERROR
+    * \retval ::XQC_INTERNAL_ERROR
+    *)
+    get_base_uri: function(context: XQC_StaticContext; out base_uri: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Register an external function that can be called within a query.
+     * One external function consists of three function parameters, i.e. init, next, and release.
+     *
+     * \param context The XQC_StaticContext that this function pointer is a member of
+     * \param uri The URI of the external function to add.
+     * \param localname The localname of the function to add.
+     * \param init A callback function pointer that is called once when the external function
+     *             is initialized. The init function gets the global_user_data pointer
+     *             as parameter.
+     * \param next A callback function pointer that is called each time the corresponding
+     *             XQuery function is executed.
+     * \param release A callback function pointer that is called once when the external function
+     *                is deinitialized.
+     * \param global_user_data User specific data that is passed to the init function as a parameter.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::API0019_FUNCTION_ALREADY_REGISTERED,
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    register_external_function: function(context: XQC_StaticContext; const uri, localname: pchar; init: external_function_init;
+      next: external_function_next; release: external_function_release; global_user_data: pointer): XQUERY_ERROR; extdecl;
+
+
+   (**
+    * Called to free the resources associated with the XQC_StaticContext.
+    *
+    * \param context The XQC_StaticContext that this function pointer is a member of
+    *)
+    free: procedure(context: XQC_StaticContext); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: Pointer;
+  end;
+
+
+(**
+ * An object of the type ::XQC_DynamicContext contains the information that is available at the
+ * time the query is executed.  It contains the information that is defined in the %XQuery
+ * specification (see http://www.w3.org/TR/xquery/#eval_context).
+ * An instance of this struct can be retrieved by calling the <code>get_dynamic_context</code> function
+ * of an ::XQC_Query object.
+ *)
+  XQC_DynamicContext_s = record
+    (**
+     * Sets the context item to the given ::XQC_Item.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     * \param value The XQC_Item for the context item.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_context_item: function(context: XQC_DynamicContext; value: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Sets the context item to the document given by the FILE pointer.
+     * The provided document is accessible by the provided doc_uri.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     * \param doc_uri The URI referencing the given document
+     * \param document The document to which the context item should be set as a FILE pointer.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0016_LOADER_IO_ERROR,
+     * \retval ::XQP0017_LOADER_PARSING_ERROR,
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_context_document: function(context: XQC_DynamicContext; const doc_uri: pchar; document: pfile): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Sets the external variable to the value given.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     * \param qname The qname of the external variable to set
+     * \param value The XQC_Item value for the variable.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_variable_item: function(context: XQC_DynamicContext; const qname: pchar; value: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Sets the external variable to the sequence given.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     * \param qname The qname of the external variable to set
+     * \param value The XQC_Sequence value for the variable.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_variable_sequence: function(context: XQC_DynamicContext; const qname: pchar; value: XQC_Sequence): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Sets the external variable to the document given by the FILE pointer.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     * \param var_qname The qname of the external variable to set
+     * \param doc_uri The URI referencing the given document
+     * \param document The document to which the context item should be set as a FILE pointer.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0016_LOADER_IO_ERROR,
+     * \retval ::XQP0017_LOADER_PARSING_ERROR,
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_variable_document: function(context: XQC_DynamicContext; const var_qname, doc_uri: pchar; document: pfile): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Sets the implicit timezone parameter.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     * \param timezone The implicit timezone to set
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_implicit_timezone: function(context: XQC_DynamicContext; timezone: cint): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Defines the value of the default collection that is used when calling the
+     * fn:collection function without a parameter.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     * \param collection_uri the URI of the collection used by the fn:collection function.
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    set_default_collection: function(context: XQC_DynamicContext; collection_uri: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Called to free the resources associated with the XQC_DynamicContext.
+     *
+     * \param context The XQC_DynamicContext that this function pointer is a member of
+     *)
+    free: procedure(context: XQC_DynamicContext); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * This struct is Zorba's representation of an Item as defined in the
+ * XQuery 1.0 and XPath 2.0 Data Model (XDM); see http://www.w3.org/TR/xpath-datamodel/.
+ *
+ * Instances of the XDM are a sequence, i.e. an ordered collection of zero or more items.
+ * In the Zorba API, a sequence is represented by the XQC_Sequence struct.
+ *
+ * The Item class is the union of all XQuery node and atomic types.
+ * The class provides functions to access the information of an Item. Note that not
+ * all functions are defined on every Item kind. If a function is called on an Item that
+ * does not provide the function called, an XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE error
+ * is raised.
+ *
+ * A new atomic Item can be created using the ItemFactory. A new node Item should be created
+ * by the result of a query.
+ *)
+  XQC_Item_s = record
+    (**
+     * The string value is the string that is extracted by calling the fn:string function
+     * on the Item (see http://www.w3.org/TR/xpath-functions/#func-string).
+     * Note that this function is available for all types of Items.
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     * \param[out] string_value The string-value of the given item.
+     *             This string is valid as long as the given item is valid.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
+     *)
+    string_value: function(item: XQC_Item; out string_value: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Get the (optional) value of a QName's prefix.
+     * Note that this function is only available for Items of type QName.
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     * \param[out] prefix The prefix of the given QName item.
+     *             This string is valid as long as the given item is valid.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
+     *)
+    prefix: function(item: XQC_Item; out prefix: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Get the (optional) value of a QName's namespace.
+     * Note that this function is only available for Items of type QName.
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     * \param[out] namespace The namespace of the given QName item.
+     *             This string is valid as long as the given item is valid.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
+     *)
+    ns: function(item: XQC_Item; out ns: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Get the value of a QName's localname.
+     * Note that this function is only available for Items of type QName.
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     * \param[out] localname The localname of the given QName item.
+     *             This string is valid as long as the given item is valid.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
+     *)
+    localname: function(item: XQC_Item; out local_name: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Get the bool value of the boolean Item.
+     * Note that this function is only available for Items of type boolean.
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     * \param[out] bool_value 1 if the boolean value of the given item is true, 0 otherwise.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
+     *)
+    boolean_value: function(item: XQC_Item; out bool_value: cint): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Check if the value of the Item is not a number (NaN).
+     * Note that this function is implemented for all item types but may only return
+     * 1 for a numeric item (e.g. Double or Float).
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     * \param[out] is_nan 1 if the given item is not a number, 0 otherwise.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
+     *)
+    nan: function(item: XQC_Item; out is_nan: cint): XQUERY_ERROR; extdecl;
+
+
+    (**
+      Check if the value of the Item is positive or negative infinity.
+     * Note that this function is only available for numeric items (e.g. Double or Float).
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     * \param[out] inf 1 if the given item is +/-INF, 0 otherwise.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
+     *)
+    pos_or_neg_inf: function(item: XQC_Item; out pos_or_neg_inf: cint): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Called to free the resources associated with the XQC_Item.
+     *
+     * \param item The XQC_Item that this function pointer is a member of
+     *)
+    free: procedure(item: XQC_Item); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * An instance of this class can be obtained by calling <code>item_factory</code> function
+ * of an ::XQC_Implementation object.
+ *
+ * Each <code>create_XXX</code> function of this struct creates an ::XQC_Item of an XML Schema item.
+ * Each of the functions takes either NULL or a valid XQC_Item wrapper. The latter is created
+ * by calling <code>XQC_Implementation::create_item</code>. In both cases, the user is responsible
+ * for freeing the object by calling the XQC_Item::free() function.
+ *)
+  XQC_ItemFactory_s = record
+    (**
+     * Creates a String Item see [http://www.w3.org/TR/xmlschema-2/#string].
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param str The string as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_string: function(factory: XQC_ItemFactory; const str: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates an AnyURI Item see [http://www.w3.org/TR/xmlschema-2/#anyURI]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param str The uri as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_anyuri: function(factory: XQC_ItemFactory; const str: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a QName Item see [http://www.w3.org/TR/xmlschema-2/#QName]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param str The uri as a char pointer.
+     * \param localname The localname as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_qname2: function(factory: XQC_ItemFactory; const uri, localname: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a QName Item see [http://www.w3.org/TR/xmlschema-2/#QName]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param str The uri as a char pointer.
+     * \param prefix The prefix as a char pointer.
+     * \param localname The localname as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_qname3: function(factory: XQC_ItemFactory; const uri, prefix, localname: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Boolean Item see [http://www.w3.org/TR/xmlschema-2/#bool]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param boolean 0 for a boolean <code>false</code> boolean item, 1 otherwise.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_boolean: function(factory: XQC_ItemFactory; boolean: cint; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a NCName Item see [http://www.w3.org/TR/xmlschema-2/#NCName]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param ncname The NCName as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_ncname: function(factory: XQC_ItemFactory; const ncname: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Base64Binary Item see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param binary_data The binary data as a char pointer.
+     * \param letter The length of the binary data.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_base64binary: function(factory: XQC_ItemFactory; const binary_data: pchar; length: csize_t; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Decimal Item see [http://www.w3.org/TR/xmlschema-2/#decimal]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The value as a doule
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_decimal: function(factory: XQC_ItemFactory; value: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Decimal Item see [http://www.w3.org/TR/xmlschema-2/#decimal]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The value as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_decimal_char: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates an Integer Item see [http://www.w3.org/TR/xmlschema-2/#integer]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param integer_value The value as a long long.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_integer: function(factory: XQC_ItemFactory; const integer_value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates an Integer Item see [http://www.w3.org/TR/xmlschema-2/#integer]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param integer_value The value as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_integer_char: function(factory: XQC_ItemFactory; const integer_value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Long Item see [http://www.w3.org/TR/xmlschema-2/#long]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param long_value The value as a long long.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_long: function(factory: XQC_ItemFactory; const long_value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Int Item see [http://www.w3.org/TR/xmlschema-2/#int]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param int_value The value as an int.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_int: function(factory: XQC_ItemFactory; const int_value: cint; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Short Item see [http://www.w3.org/TR/xmlschema-2/#short]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param short_value The value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_short: function(factory: XQC_ItemFactory; const short_value: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Byte Item see [http://www.w3.org/TR/xmlschema-2/#byte]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param byte_value The byte value as a char.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_byte: function(factory: XQC_ItemFactory; const byte_value: cchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Date Item see [http://www.w3.org/TR/xmlschema-2/#date]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param date_value The date value as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_date_char: function(factory: XQC_ItemFactory; const date_value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Date Item see [http://www.w3.org/TR/xmlschema-2/#date]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param year The year value as a short.
+     * \param month The month value as a short.
+     * \param day The day value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_date: function(factory: XQC_ItemFactory; const year, month, day: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a DateTime Item see [http://www.w3.org/TR/xmlschema-2/#dateTime]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param year The year value as a short.
+     * \param month The month value as a short.
+     * \param day The day value as a short.
+     * \param hour The hour value as a short.
+     * \param minute The minute value as a short.
+     * \param seconds The seconds value as a short.
+     * \param timezone_hours The timezone as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_datetime: function(factory: XQC_ItemFactory; const year, month, day, hour, minute: cshort;
+      seconds: cdouble; timezone_hours: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a DateTime Item see [http://www.w3.org/TR/xmlschema-2/#dateTime]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param datetime_value The string representation of the datetime value as a char pointer
+     *                       (for example, 2002-10-10T12:00:00-05:00).
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_datetime_char: function(factory: XQC_ItemFactory; const datetime_value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Double Item see [http://www.w3.org/TR/xmlschema-2/#double]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_double: function(factory: XQC_ItemFactory; const value: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Double Item see [http://www.w3.org/TR/xmlschema-2/#double]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The value as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_double_char: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Duration Item see [http://www.w3.org/TR/xmlschema-2/#duration]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param year The year value as a short.
+     * \param month The month value as a short.
+     * \param day The day value as a short.
+     * \param hour The hour value as a short.
+     * \param minute The minute value as a short.
+     * \param seconds The seconds value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_duration: function(factory: XQC_ItemFactory; const year, month, day, hour, minute: cshort;
+      seconds: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Float Item see [http://www.w3.org/tr/xmlschema-2/#float]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The float value as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_float: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a gDay Item see [http://www.w3.org/TR/xmlschema-2/#gDay]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param day The day value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_gday: function(factory: XQC_ItemFactory; day: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a gMonth Item see [http://www.w3.org/TR/xmlschema-2/#gMonth]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param month The month value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_gmonth: function(factory: XQC_ItemFactory; month: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a gMonthDay Item see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param month The month value as a short.
+     * \param day The day value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_gmonthday: function(factory: XQC_ItemFactory; month, day: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a gYear Item see [http://www.w3.org/TR/xmlschema-2/#gYear]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param year The year value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_gyear: function(factory: XQC_ItemFactory; year: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a gYearMonth Item see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param year The year value as a short.
+     * \param month The month value as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_gyearmonth: function(factory: XQC_ItemFactory; year, month: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a HexBinary Item see [http://www.w3.org/TR/xmlschema-2/#hexBinary]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param hex_data The hex data as a char pointer.
+     * \param size The size of the hex data.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_hexbinary: function(factory: XQC_ItemFactory; const hex_data: pchar; size: csize_t; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a negativeInteger Item see [http://www.w3.org/TR/xmlschema-2/#negativeInteger]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The negative integer as a long long value.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_negativeinteger: function(factory: XQC_ItemFactory; value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a nonNegativeInteger Item see [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The non-negative integer as an unsigned long long value.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_nonnegativeinteger: function(factory: XQC_ItemFactory; value: culonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a nonPositiveInteger Item see [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The non-positive integer as a long long value.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_nonpositiveinteger: function(factory: XQC_ItemFactory; value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a positiveInteger Item see [http://www.w3.org/TR/xmlschema-2/#positiveInteger]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The positive integer as an unsigned long long value.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_positiveinteger: function(factory: XQC_ItemFactory; value: culonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Time Item see [http://www.w3.org/TR/xmlschema-2/#time]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The time as a char pointer.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_time_char: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Time Item see [http://www.w3.org/TR/xmlschema-2/#time]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param hour The hour as a short.
+     * \param minute The minute as a short.
+     * \param second The second as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_time: function(factory: XQC_ItemFactory; hour, minute: cshort; second: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a Time Item see [http://www.w3.org/TR/xmlschema-2/#time]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param hour The hour as a short.
+     * \param minute The minute as a short.
+     * \param second The second as a double.
+     * \param timezone_hours The timezone hours as a short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_time_timezone: function(factory: XQC_ItemFactory; hour, minute: cshort; second: cdouble;
+      timezone_hours: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates an Unsigned Byte Item see [http://www.w3.org/TR/xmlschema-2/#unsignedByte]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The unsigned byte value as an unsigned char.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_unsignedbyte: function(factory: XQC_ItemFactory; value: cuchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates an unsigned int Item see [http://www.w3.org/TR/xmlschema-2/#unsignedInt]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The unsigned int value as an unsigned int.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_unsignedint: function(factory: XQC_ItemFactory; value: cuint; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates an unsignedLong Item see [http://www.w3.org/TR/xmlschema-2/#unsignedLong]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The unsigned long value as an unsigned long long.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_unsignedlong: function(factory: XQC_ItemFactory; value: culonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Creates a unsignedShort Item see [http://www.w3.org/TR/xmlschema-2/#unsignedShort]
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param value The unsigned short value as an unsigned short.
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
+     *)
+    create_unsignedshort: function(factory: XQC_ItemFactory; value: cushort; out item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Called to free the resources associated with the XQC_ItemFactory.
+     *
+     * \param factory The XQC_ItemFactory that this function pointer is a member of
+     * \param[out] item The item to create. This can either be a wrapper created using
+     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
+     *)
+    free: procedure(factory: XQC_ItemFactory); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * This struct represents an instance of the XQuery 1.0 and XPath 2.0 Data Model (XDM).
+ *
+ * See http://www.w3.org/TR/xpath-datamodel/.
+ *)
+  XQC_Sequence_s = record
+    (**
+     * Get the next item of the sequence.
+     *
+     * \param sequence The XQC_Sequence_s that this function pointer is a member of
+     * \param[out] item The item wrapper that should contain the next item if XQ_NO_ERROR is returned
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval any XQuery type or dynamic error
+     *)
+    next: function(sequence: XQC_Sequence; item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * called to free the resources associated with the xqc_itemfactory.
+     *
+     * \param sequence the XQC_Sequence that this function pointer is a member of
+     *)
+    free: procedure(sequence: XQC_Sequence); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * A Collection is a sequence of Node Items.
+ *
+ * Each Collection is created by the XmlDataManager and referenced by a URI.
+ * The URI can be accessed in a query's fn:collection function.
+ *)
+  XQC_Collection_s = record
+    (**
+     * Get the URI of a collection as an anyURI Item.
+     *
+     * \param collection the XQC_Collection_s that this function pointer is a member of
+     * \param[out] uri_item The uri item of the given collection. The user is responsible
+     *             for freeing the object by calling the XQC_Item::free() function.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     *)
+    get_name: function(collection: XQC_Collection; out name_item: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Adds a Node Item to the Collection
+     *
+     * \param collection the XQC_Collection_s that this function pointer is a member of
+     * \param node The node item to add to the given collection.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::API0007_COLLECTION_ITEM_MUST_BE_A_NODE
+     *)
+    add_node: function(collection: XQC_Collection; node: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Deletes a Node Item from the given Collection
+     *
+     * \param collection the XQC_Collection_s that this function pointer is a member of
+     * \param node The node item to delete from the given collection.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::API0007_COLLECTION_ITEM_MUST_BE_A_NODE
+     *)
+    delete_node: function(collection: XQC_Collection; node: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Adds a sequence of Node Items to the Collection
+     *
+     * \param collection the XQC_Collection_s that this function pointer is a member of
+     * \param sequence The sequence of node items to add to the given collection.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0019_INTERNAL_ERROR
+     * \retval ::API0007_COLLECTION_ITEM_MUST_BE_A_NODE
+     *)
+    add_sequence: function(collection: XQC_Collection; sequence: XQC_Sequence): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Adds a document given by the FILE pointer to this collection.
+     *
+     * \param collection the XQC_Collection_s that this function pointer is a member of
+     * \param doc The document to add as a FILE pointer.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0016_LOADER_IO_ERROR,
+     * \retval ::XQP0017_LOADER_PARSING_ERROR,
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    add_document: function(collection: XQC_Collection; doc: pfile): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Adds a document given by the char pointer to this collection.
+     *
+     * \param collection the XQC_Collection_s that this function pointer is a member of
+     * \param doc The document to add as a char pointer.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0016_LOADER_IO_ERROR,
+     * \retval ::XQP0017_LOADER_PARSING_ERROR,
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    add_document_char: function(collection: XQC_Collection; const doc: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * called to free the resources associated with the xqc_itemfactory.
+     *
+     * \param collection the XQC_Collection that this function pointer is a member of
+     *)
+    free: procedure(collection: XQC_Collection); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * Using the XmlDataManager one can manage documents and collections.
+ *
+ * The XmlDataManager is a singelton instance. The instance can be accessed by calling
+ * XQC_Implementation::data_manager. The XmlDataManager is thread-safe.
+ *)
+  XQC_DataManager_s = record
+    (**
+     * This function loads a document from the given FILE pointer. The document
+     * is identified by the given URI.
+     *
+     * \param data_manager The XQC_DataManager that this function pointer is a member of
+     * \param doc_uri The URI of the document to load.
+     * \param document The document to load as a FILE pointer.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0016_LOADER_IO_ERROR,
+     * \retval ::XQP0017_LOADER_PARSING_ERROR,
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    load_document: function(data_manager: XQC_DataManager; const doc_uri: pchar; document: pfile): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * This function loads a document that is retrieved from the given URI location. The document
+     * is identified by the given URI.
+     *
+     * \param data_manager The XQC_DataManager that this function pointer is a member of
+     * \param location The URI of the document to load.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQP0016_LOADER_IO_ERROR,
+     * \retval ::XQP0017_LOADER_PARSING_ERROR,
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    load_document_uri: function(data_manager: XQC_DataManager; const location: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Get the document identified by the given URI.
+     *
+     * \param data_manager The XQC_DataManager that this function pointer is a member of
+     * \param document_uri The URI of the document to retrieve.
+     * \param[out] doc The Item of the document to get.  The user is responsible
+     *                 for freeing the object by calling the XQC_Item::free() function.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    get_document: function(data_manager: XQC_DataManager; const document_uri: pchar; out doc: XQC_Item): XQUERY_ERROR; extdecl;
+
+
+    (*
+     * Delete the document identified by the given URI.
+     *
+     * \param data_manager The XQC_DataManager that this function pointer is a member of
+     * \param document_uri The URI of the document to delete.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    delete_document: function(data_manager: XQC_DataManager; const document_uri: pchar): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Create a new collection that is identified by the given URI.
+     *
+     * \param data_manager The XQC_DataManager that this function pointer is a member of
+     * \param document_uri The URI of the collection to create.
+     * \param[out] col The collection to create. The user is responsible
+     *                 for freeing the object by calling the XQC_Item::free() function.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    create_collection: function(data_manager: XQC_DataManager; const collection_uri: pchar; out col: XQC_Collection): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Get the collection that is identified by the given URI.
+     *
+     * \param data_manager The XQC_DataManager that this function pointer is a member of
+     * \param document_uri The URI of the collection to retrieve.
+     * \param[out] col The collection to retrieve. The user is responsible
+     *                 for freeing the object by calling the XQC_Item::free() function.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    get_collection: function(data_manager: XQC_DataManager; const collection_uri: pchar; out col: XQC_Collection): XQUERY_ERROR; extdecl;
+
+
+    (**
+     * Delete the collection that is identified by the given URI.
+     *
+     * \param data_manager The XQC_DataManager that this function pointer is a member of
+     * \param document_uri The URI of the collection to delete.
+     *
+     * \retval ::XQC_NO_ERROR
+     * \retval ::XQC_INTERNAL_ERROR
+     *)
+    delete_collection: function(data_manager: XQC_DataManager; const collection_uri: pchar): XQUERY_ERROR; extdecl;
+
+    (**
+     * Called to free the resources associated with the XQC_DataManager.
+     *
+     * \param context The XQC_DataManager that this function pointer is a member of
+     *)
+    free: procedure(data_manager: XQC_DataManager); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * The ::XQC_OutputStream struct is designed to be passed to an XQC implementation in order
+ * to return streaming data (i.e. the result of a query).
+ *)
+  XQC_OutputStream_s = record
+    (**
+     * The function is called to provide the streaming result of a query
+     * in the buffer provided.
+     *
+     * \param stream The XQC_OutputStream that this function pointer is a member of
+     * \param buf The buffer that contains the data
+     * \param length The length of the contents in the buffer
+     *)
+    write: procedure(stream: XQC_OutputStream; const buf: pchar; length: cuint); extdecl;
+
+
+    (**
+     * Called to free the resources associated with the XQC_OutputStream.
+     * Free is called by the implementation if it finished writing to the stream.
+     *
+     * \param stream The XQC_OutputStream that this function pointer is a member of
+     *
+     *)
+    free: procedure(stream: XQC_OutputStream); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * The ::XQC_InputStream struct is designed to be populated by users for the purpose
+ * of streaming data into an XQC implementation.
+ *)
+  XQC_InputStream_s = record
+     (**
+      * The function called to read more of the input (e.g. the query). The function should read
+      * the next chunk of input into the buffer provided, returning the length of the
+      * data read.
+      *
+      * \param stream The XQC_InputStream that this function pointer is a member of
+      * \param[out] buffer The buffer to read the data into
+      * \param length The length of the buffer
+      *
+      * \return The number of bytes read - this will be less than length if the end of the input is reached
+      *         or -1 if an error occured
+      *
+      *)
+    read: function(stream: XQC_InputStream; const buf: pchar; length: cuint): cint; extdecl;
+
+
+    (**
+     * Called to free the resources associated with the XQC_InputStream.
+     * The free function is called by the implementation if it finished reading from the stream.
+     * This allows for lazy evaluation without the user needing to know when reading from the
+     * stream has finished.
+     *
+     * \param stream The XQC_InputStream that this function pointer is a member of
+     *
+     *)
+    free: procedure(stream: XQC_InputStream); extdecl;
+
+
+    (**
+     * for internal use only
+     *)
+    data: pointer;
+  end;
+
+
+(**
+ * The ::XQC_ErrorHandler struct is designed to be populated by users for the purpose
+ * of collecting more detailed error messages from an XQC implementation. An XQC_ErrorHandler
+ * can be set for a query using the XQC_Query::set_error_handler() function.
+ *
+ * The XQC_ErrorHandler struct has no free() function pointer because the user remains
+ * responsible for freeing the resources associated with this struct.
+ *)
+  XQC_ErrorHandler_s = record
+    (**
+     * The function is called when an error occurs. The function receives the components of the
+     * error as arguments. When this function returns, the implementation will exit query parsing or
+     * execution with the error enumeration value passed as an argument.
+     *
+     * \param handler The XQC_ErrorHandler that this function pointer is a member of
+     * \param error The error as a value of the XQUERY_ERROR enum.
+     * \param local_name The local name of the error or an empty string if no local_name is given
+     *                   (e.g. for errors not defined in the spec).
+     * \param description A detailed description of the error or an empty string if no description is available.
+     * \param query_uri The uri of the query causing the error or an empty string if no uri is available for the query.
+     * \param line The line number of the query where the error occured.
+     * \param components The column number in the line in the query where the error occured.
+     *)
+    error: procedure(handler: XQC_ErrorHandler; error: XQUERY_ERROR; const local_name, description,
+      query_uri: pchar; line, column: cuint); extdecl;
+
+
+    (**
+     * Can be used for user specific purposes.
+     *)
+    data: pointer;
+  end;
+
+
+(* helper functions *)
+procedure xqc_errorhandler_error(handler: XQC_ErrorHandler; error: XQUERY_ERROR; const local_name,
+  description, query_uri: pchar; line, column: cuint); extdecl;
+
+const
+  XQC_Console_ErrorHandler_impl: XQC_ErrorHandler_s = (error:@xqc_errorhandler_error; data: nil);
+  XQC_Console_ErrorHandler: XQC_ErrorHandler = @XQC_Console_ErrorHandler_impl;
+
+function XQC_InputStream_create(const Stream: TStream; const Owned: Boolean): XQC_InputStream;
+function XQC_OutputStream_create(const Stream: TStream; const Owned: Boolean): XQC_OutputStream;
+
+implementation
+
+procedure xqc_errorhandler_error(handler: XQC_ErrorHandler; error: XQUERY_ERROR; const local_name,
+  description, query_uri: pchar; line, column: cuint); extdecl;
+begin
+  WriteLn(query_uri, '(', line, ',', column, ') ', local_name, ': ', description);
+end;
+
+
+type
+  PStreamData = ^TStreamData;
+  TStreamData = record
+    Stream: TStream;
+    Owned: Boolean;
+  end;
+
+function xqc_inputstream_read(stream: XQC_InputStream; const buf: pchar; length: cuint): cint; extdecl;
+begin
+  if Assigned(buf) and (length > 0) then
+    Result := PStreamData(stream^.data)^.Stream.Read(buf^, length)
+  else
+    Result := 0;
+end;
+
+procedure xqc_inputstream_free(stream: XQC_InputStream); extdecl;
+begin
+  if PStreamData(stream^.data)^.Owned then
+    PStreamData(stream^.data)^.Stream.Free;
+  FreeMem(stream);
+end;
+
+function XQC_InputStream_create(const Stream: TStream; const Owned: Boolean): XQC_InputStream;
+begin
+  if not Assigned(Stream) then
+    Exit(nil);
+
+  GetMem(Result, Sizeof(XQC_InputStream_s)+Sizeof(TStreamData));
+  Result^.read := @xqc_inputstream_read;
+  Result^.free := @xqc_inputstream_free;
+  Result^.data := PChar(Result) + Sizeof(XQC_InputStream_s);
+  PStreamData(Result^.data)^.Owned := Owned;
+  PStreamData(Result^.data)^.Stream := Stream;
+end;
+
+procedure xqc_outputstream_write(stream: XQC_OutputStream; const buf: pchar; length: cuint); extdecl;
+begin
+  if Assigned(buf) and (length > 0) then
+    PStreamData(stream^.data)^.Stream.Write(buf^, length);
+end;
+
+procedure xqc_outputstream_free(stream: XQC_OutputStream); extdecl;
+begin
+  if PStreamData(stream^.data)^.Owned then
+    PStreamData(stream^.data)^.Stream.Free;
+  FreeMem(stream);
+end;
+
+function XQC_OutputStream_create(const Stream: TStream; const Owned: Boolean): XQC_OutputStream;
+begin
+  if not Assigned(Stream) then
+    Exit(nil);
+
+  GetMem(Result, Sizeof(XQC_OutputStream_s)+Sizeof(TStreamData));
+  Result^.write := @xqc_outputstream_write;
+  Result^.free := @xqc_outputstream_free;
+  Result^.data := PChar(Result) + Sizeof(XQC_OutputStream_s);
+  PStreamData(Result^.data)^.Owned := Owned;
+  PStreamData(Result^.data)^.Stream := Stream;
+end;
+
+end.

+ 0 - 0
packages/zorba/src/zorba_error.inc → packages/zorba/src/xqc_error.inc


+ 0 - 0
packages/zorba/src/zorba_static_context_consts.inc → packages/zorba/src/xqc_static_context_consts.inc


+ 17 - 2027
packages/zorba/src/zorba.inc

@@ -1,3 +1,19 @@
+(*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ *)
+
 {$mode objfpc}{$H+}
 {$PACKRECORDS C}
 {$MACRO ON}
@@ -5,7 +21,7 @@
 interface
 
 uses
-  ctypes, dynlibs;
+  ctypes, dynlibs, xqc;
 
 {$IFDEF UNIX}
   {$DEFINE extdecl:=cdecl}
@@ -26,2035 +42,9 @@ uses
   {$DEFINE S}
 {$ENDIF}
 
-
-(*
- * Copyright 2006-2008 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- *)
-
 {.$i zorba_config.inc}
-{$i zorba_error.inc}
-{$i zorba_static_context_consts.inc}
 {$i zorba_options.inc}
 
-type
-  pfile = pointer;
-
-  XQC_Implementation = ^XQC_Implementation_s;
-  XQC_Implementation_Ref = ^XQC_Implementation;
-
-  XQC_Query = ^XQC_Query_s;
-  XQC_Query_Ref = ^XQC_Query;
-
-  XQC_StaticContext = ^XQC_StaticContext_s;
-  XQC_StaticContext_Ref = ^XQC_StaticContext;
-
-  XQC_DynamicContext = ^XQC_DynamicContext_s;
-  XQC_DynamicContext_Ref = ^XQC_DynamicContext;
-
-  XQC_Sequence = ^XQC_Sequence_s;
-  XQC_Sequence_Ref = ^XQC_Sequence;
-
-  XQC_Item = ^XQC_Item_s;
-  XQC_Item_Ref = ^XQC_Item;
-
-  XQC_ItemFactory = ^XQC_ItemFactory_s;
-  XQC_ItemFactory_Ref = ^XQC_ItemFactory;
-
-  XQC_Collection = ^XQC_Collection_s;
-  XQC_Collection_Ref = ^XQC_Collection;
-
-  XQC_DataManager = ^XQC_DataManager_s;
-  XQC_DataManager_Ref = ^XQC_DataManager;
-
-  XQC_OutputStream = ^XQC_OutputStream_s;
-  XQC_InputStream = ^XQC_InputStream_s;
-  XQC_ErrorHandler = ^XQC_ErrorHandler_s;
-
-
-// external functions
-  external_function_init = procedure(out user_data: Pointer; global_user_data: Pointer); extdecl;
-
-  external_function_next = function(args: XQC_Sequence; argc: cint; out result: XQC_Item;
-    user_data: Pointer; global_user_data: Pointer): XQUERY_ERROR; extdecl;
-
-  external_function_release = procedure(user_data: Pointer; global_user_data: Pointer); extdecl;
-
-
-(**
- * The ::XQC_Implementation struct provides factory functions for parsing queries. 
- * An XQC_Implementation object is thread-safe and can be used by multiple threads 
- * of execution at the same time.
- *
- * Creating an XQC_Implementation object can be done using the zorba_implementation function.
- * Once created, the user is responsible for freeing the object by calling
- * the free() function. 
- * The XQC_Implementation object should not be freed before all objects created using it's
- * functions have been freed - doing so causes undefined behaviour.
- *)
-  XQC_Implementation_s = record
-   (**
-    * Creates a static context suitable for use in the parse() and parse_file()
-    * functions. The user is responsible for freeing the ::XQC_StaticContext object returned by calling
-    * XQC_StaticContext::free().
-    *
-    * \param implementation The XQC_Implementation that this function pointer is a member of
-    * \param[out] context The newly created XQC_StaticContext object.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    *)
-    create_context: function(impl: XQC_Implementation; out context: XQC_StaticContext): XQUERY_ERROR; extdecl;
-
-   (**
-    * Prepares a query from a string, returning an ::XQC_Query object.
-    * The user is responsible for freeing the ::XQC_Query object
-    * returned by calling XQC_Query::free().
-    *
-    * \param implementation The XQC_Implementation that this function pointer is a member of.
-    * \param string The query to prepare as a string.
-    * \param context The initial static context for this query, or null to use the default
-    *        static context.
-    * \param handler An optional error handler whose <code>error</code> function is called
-    *                if preparing the query fails.
-    * \param[out] expression The resulting prepared expression.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    * \retval An XQuery static or type error (e.g. XPST*, XPTY* )
-    *)
-    prepare: function(impl: XQC_Implementation; query_string: pchar; context: XQC_StaticContext;
-      handler: XQC_ErrorHandler; out query: XQC_Query): XQUERY_ERROR; extdecl;
-
-    (**
-     * Prepares a query from a FILE pointer, returning an ::XQC_Query object.
-     * The user remains responsible for closing the file after parsing.
-     * The user is responsible for freeing the ::XQC_Query object returned by
-     * calling XQC_Query::free().
-     *
-     * \param implementation The XQC_Implementation that this function pointer is a member of.
-     * \param file The file containing the query to prepare.
-     * \param context The initial static context for this query, or null to use the default
-     *        static context.
-     * \param handler An optional error handler whose <code>error</code> function is called
-     *                if preparing the query fails.
-     * \param[out] expression The resulting prepared expression.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval An XQuery static or type error (e.g. XPST*, XPTY* )
-     *)
-    prepare_file: function(impl: XQC_Implementation; query_file: pfile; context: XQC_StaticContext;
-      handler: XQC_ErrorHandler; out query: XQC_Query): XQUERY_ERROR; extdecl;
-
-    (**
-     * Prepares a query from a ::XQC_InputStream, returning an ::XQC_Query object.
-     * The user is responsible for freeing the ::XQC_Query object returned by
-     * calling XQC_Query::free().
-     *
-     * \param implementation The XQC_Implementation that this function pointer is a member of.
-     * \param stream The input stream returning the query to prepare.
-     *               free will be called on the XQC_InputStream after the query has been read.
-     * \param context The initial static context for this query, or null to use the default
-     *        static context.
-     * \param handler An optional error handler whose <code>error</code> function is called
-     *                if preparing the query fails.
-     * \param[out] expression The resulting prepared expression.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval An XQuery static or type error (e.g. XPST*, XPTY* )
-     *)
-    prepare_stream: function(impl: XQC_Implementation; stream: XQC_InputStream; context: XQC_StaticContext;
-      handler: XQC_ErrorHandler; out query: XQC_Query): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates an item wrapper suitable for use in the ::XQC_Sequence::next function or
-     * the ::XQC_ItemFactory::create functions.
-     * The user is responsible for freeing the XQC_Item object returned by calling
-     * XQC_Item::free().
-     *
-     * \param implementation The XQC_Implementation that this function pointer is a member of
-     * \param[out] item The newly created XQC_Item wrapper object.
-     *
-  	 * \retval ::XQC_NO_ERROR
-  	 * \retval ::XQP0019_INTERNAL_ERROR
-     *)
-    create_item: function(impl: XQC_Implementation; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a XQC_ItemFactory that can be used for creating items, i.e. instances of the
-     * XQuery data model (XDM).
-     * The user is responsible for freeing the XQC_ItemFactory object returned by calling
-     * XQC_ItemFactory::free().
-     *
-     * \param implementation The XQC_Implementation that this function pointer is a member of
-     * \param[out] factory The newly created XQC_ItemFactory  object.
-     *
-  	 * \retval ::XQC_NO_ERROR
-  	 * \retval ::XQP0019_INTERNAL_ERROR
-     *)
-    item_factory: function(impl: XQC_Implementation; out factory: XQC_ItemFactory): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a XQC_DataManager that can be used for managing collections and documents.
-     * The user is responsible for freeing the XQC_DataManager object returned by calling
-     * XQC_DataManager::free().
-     *
-     * \param implementation The XQC_Implementation that this function pointer is a member of
-     * \param[out] data_manager The newly created XQC_DataManager object.
-     *
-  	 * \retval ::XQC_NO_ERROR
-  	 * \retval ::XQP0019_INTERNAL_ERROR
-     *)
-    data_manager: function(impl: XQC_Implementation; out data_manager: XQC_DataManager): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Called to free the resources associated with the XQC_Implementation.
-     *
-     * \param implementation The XQC_Implementation that this function pointer is a member of
-     *)
-    free: procedure(impl: XQC_Implementation); extdecl;
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * The ::XQC_Expression struct represents a pre-parsed query, and allows the user to execute 
- * that query any number of times. An ::XQC_Expression object is thread-safe and 
- * can be used by multiple threads of execution at the same time.
- *
- * ::XQC_Expression objects are created by calling the XQC_Implementation::prepare() or 
- * XQC_Implementation::prepare_file() functions. 
- * Once created, the user is responsible for freeing the object by calling the free() function. 
- * The ::XQC_Expression object should be freed before the ::XQC_Implementation object
- * that created it.
- *)
- XQC_Query_s = record
-    (**
-     * This function returns the dynamic context that belongs to this query and
-     * is used during query execution.
-     * The context can be used, for example, to set values of external variables,
-     * the default collation, or the current datetime.
-     * It is only available if the query has been compiled, otherwise
-     * an error is reported. Moreover, the context must not be modified during the
-     * execution of a query (i.e. if a ResultIterator is opened).
-  	 * The user is responsible for freeing the ::XQC_DynamicContext object returned by calling
-  	 * XQC_DynamicContext::free().
-     *
-  	 * \retval ::XQC_NO_ERROR
-  	 * \retval ::XQP0019_INTERNAL_ERROR
-     *)
-    get_dynamic_context: function(query: XQC_Query; out context: XQC_DynamicContext): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * This function returns the static context that belongs to this query.
-     * The static context is only available if the query has been compiled, otherwise
-     * an error is reported.
-     * The context has all the components and values that have been set by the either
-     * the static context that was passed when creating the query and and those that
-     * were set in the prolog of the query.
-     * Note that after compilation of the query the static context is a read only structure.
-  	 * The user is responsible for freeing the ::XQC_StaticContext object returned by calling
-  	 * XQC_StaticContext::free().
-     *
-  	 * \retval ::XQC_NO_ERROR
-  	 * \retval ::XQP0019_INTERNAL_ERROR
-     *)
-    get_static_context: function(query: XQC_Query; out context: XQC_StaticContext): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Executes the query represented by the XQC_Query object and prints the serialized XML
-    * output to the given FILE pointer. The user remains responsible for closing
-    * the file.
-    *
-    * \param query The XQC_Query that this function pointer is a member of.
-    * \param file The FILE pointer to print the serialized result to.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
-    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY* )
-    *)
-    execute: function(query: XQC_Query; fileptr: pfile): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Executes the query represented by the XQC_Query object and prints the serialized
-    * output to the given FILE pointer. The target format of the serialization is
-    * specified by the passed serializer options.
-    *
-    * \param query The XQC_Query that this function pointer is a member of.
-    * \param options The Zorba_SerializerOptions_t that specifies serializer options.
-    * \param file The FILE pointer to print the serialized result to.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
-    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY* )
-    *)
-    serialize_file: function(query: XQC_Query; options: pZorba_SerializerOptions_t; fileptr: pfile): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Executes the query represented by the XQC_Query object and writes the serialized
-    * output to the given ::XQC_OutputStream. The target format of the serialization is
-    * specified by the passed serializer options.
-    *
-    * \param query The XQC_Query that this function pointer is a member of.
-    * \param options The Zorba_SerializerOptions_t that specifies serializer options.
-    * \param file The XQC_OutputStream to print the serialized result to.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
-    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY*)
-    serialize_stream: function(query: XQC_Query; options: pZorba_SerializerOptions_t; stream: XQC_OutputStream): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Checks if the query is an updating query.
-    *
-    * \param query The XQC_Query that this function pionter is a member of.
-    *
-    * \retval 1 if query is updating query, else 0
-    *)
-    is_update_query: function(query: XQC_Query): cint; extdecl;
-
-
-   (**
-    * Applies the updates declared in the query represented by the XQC_Query object.
-    *
-    * \param query The XQC_Query that this function pointer is a member of.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    * \retval ::API0023_CANNOT_SERIALIZE_UPDATE_QUERY
-    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY*)
-    apply_updates: function(query: XQC_Query): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Executes the query represented by the XQC_Query object.
-    * An ::XQC_Sequence object is returned which can be used to examine the results
-    * of the query execution. The user is responsible for freeing the
-    * ::XQC_Sequence object returned by calling XQC_Sequence::free().
-    *
-    * \param query The XQC_Query that this function pointer is a member of.
-    * \param[out] sequence The newly created XQC_Sequence object.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    * \retval ::API0024_CANNOT_ITERATE_OVER_UPDATE_QUERY
-    * \retval An XQuery dynamic or type error (e.g. XPDY*, XPTY* )
-    *)
-    sequence: function(query: XQC_Query; out sequence: XQC_Sequence): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Sets the error handler whose <code>error</code> function is called
-     * if an error occurs when executing the query.
-     * The user keeps the ownership of this object and is required to freeing
-     * the aquired resources.
-     *)
-    set_error_handler: procedure(query: XQC_Query; handler: XQC_ErrorHandler); extdecl;
-
-
-   (**
-    * Called to free the resources associated with the XQC_Query.
-    *
-    * \param query The XQC_Query that this function pointer is a member of.
-    *)
-    free: procedure(query: XQC_Query); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * The ::XQC_StaticContext struct provides a way to specify values for the static context of 
- * the query to be prepared. An ::XQC_StaticContext object is not thread-safe - threads should 
- * each use their own instance of a ::XQC_StaticContext object (see create_child_context).
- *
- * ::XQC_StaticContext objects are created by calling the XQC_Implementation::create_context() 
- * function. Once created, the user is responsible for freeing the object by calling
- * the free() function. 
- * The ::XQC_StaticContext object should be freed before the ::XQC_Implementation object that
- * created it.
- *)
-  XQC_StaticContext_s = record
-   (**
-    * Creates a child context of the given static context.
-    * A child context contains the same information as it's parent context but
-    * it allows the user to override and add information.
-    * The user is responsible for freeing the ::XQC_StaticContext object returned by calling
-    * XQC_StaticContext::free().
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] child_context The newly created XQC_StaticContext object which is
-    *             a child of the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQP0019_INTERNAL_ERROR
-    *)
-    create_child_context: function(context: XQC_StaticContext; out child_context: XQC_StaticContext): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Adds a (prefix, uri) pair to the set of statically known namespaces of
-    * the given context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of.
-    * \param prefix The prefix of the namespace to add to the given XQC_StaticContext.
-    * \param uri    The uri of the namespace to add to the given XQC_StaticContext.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    declare_ns: function(context: XQC_StaticContext; const prefix: pchar; const uri: ppchar): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the namespace uri that belongs to the given prefix.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param prefix The prefix of the namespace to add to the given XQC_StaticContext.
-    * \param[out] result_ns The namespace uri of the namespace registered with the given prefix.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_ns_by_prefix: function(context: XQC_StaticContext; const prefix: pchar; out result_ns: ppchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Sets the value of the default namespace for elements and types.
-     *
-  	 * \param context The XQC_StaticContext that this function pointer is a member of
-     * \param uri The uri of the default element and type namespace to set in the given context.
-     *
-  	 * \retval ::XQC_NO_ERROR
-  	 * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_default_element_and_type_ns: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the default namespace for elements and types.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] uri The uri of the default element and type namespace that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_default_element_and_type_ns: function(context: XQC_StaticContext; out uri: pchar): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the default namespace for functions.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param uri The uri of the default function namespace to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_default_function_ns: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the default namespace for functions set in this static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] uri The uri of the default function namespace that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_default_function_ns: function(context: XQC_StaticContext; out uri: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Add a collation URI.
-     * The URI specifies the locale and collation strength of the collation that is added.
-     * A valid collation URI must begin with http://www.flworfound.org/collations/.
-     * This prefix is followed by a collation strength (i.e. PRIMARY, SECONDARY, TERTIARY,
-     * QUATTERNARY, or IDENTICAL) followed by a '/'.
-     * After the strength a lower-case two- or three-letter ISO-639 language code must follow.
-     * The URI may end with an upper-case two-letter ISO-3166.
-     * For example, http://www.flworfound.org/collations/PRIMARY/en/US
-     * specifies an english language with US begin the country..
-     *
-     * Internally, ICU is used for comparing strings. For detailed description see
-     * http://www.icu-project.org/apiref/icu4c/classCollator.html
-     * and http://www.icu-project.org/apiref/icu4c/classLocale.html
-     *
-     * \param context The XQC_StaticContext that this function pointer is a member of
-     * \param uri The URI of the collation to add.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQST0038
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    add_collation: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Set the URI of the default collation.
-     * (see http://www.w3.org/TR/xquery/#static_context)
-     *
-     * \param context The XQC_StaticContext that this function pointer is a member of
-     * \param uri The URI of the default collation to set
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQST0038
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_default_collation: function(context: XQC_StaticContext; const uri: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Get the URI of the default collation. The uri returned is valid
-     * as long as the corresponding XQC_StaticContext object is valid.
-     *
-     * \param context The XQC_StaticContext that this function pointer is a member of
-     * \param[out] uri The URI of the default collation that is currently set in the given context.
-     *)
-    get_default_collation: function(context: XQC_StaticContext; out uri: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-    * Sets the XQuery processor's version to either xquery_version_1_0 or xquery_version_1_1.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param mode The xquery_version_t to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_xquery_version: function(context: XQC_StaticContext; mode: xquery_version_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the XQuery processor's version that is set in the given static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] mode The xquery_version_t that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_xquery_version: function(context: XQC_StaticContext; out mode: xquery_version_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the XPath 1.0 compatibility mode to either xpath1_0 or xpath2_0.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param mode The xpath1_0compatib_mode_t to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_xpath1_0_mode: function(context: XQC_StaticContext; mode: xpath1_0compatib_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the XPath 1.0 compatibility that is set in the given static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] mode The xpath1_0compatib_mode_t that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_xpath1_0_mode: function(context: XQC_StaticContext; out mode: xpath1_0compatib_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the construction mode to either preserve_cons or strip_cons.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param mode The construction_mode_t to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_construction_mode: function(context: XQC_StaticContext; mode: construction_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the construction mode that is set in the given static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] mode The construction_mode_t that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_construction_mode: function(context: XQC_StaticContext; out mode: construction_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the ordering mode to either order or unordered.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param mode The ordering_mode_t to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_ordering_mode: function(context: XQC_StaticContext; mode: ordering_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the ordering mode that is set in the given static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] mode The ordering_mode_t that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_ordering_mode: function(context: XQC_StaticContext; out mode: ordering_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the default order mode for empty sequences to either empty_least or
-    * empty_greatest
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param mode The order_empty_mode_t to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_default_order_empty_sequences: function(context: XQC_StaticContext; mode: order_empty_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the default order mode for empty sequences that is set in the given
-    * static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] mode The order_empty_mode_t that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_default_order_empty_sequences: function(context: XQC_StaticContext; out mode: order_empty_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the boundary space policy to either preserve_space or strip_space.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param mode The boundary_space_mode_t to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_boundary_space_policy: function(context: XQC_StaticContext; mode: boundary_space_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the boundary space policy that is set in the given static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] mode The boundary_space_mode_t that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_boundary_space_policy: function(context: XQC_StaticContext; out mode: boundary_space_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the copy namespace mode which consists of the preserve and the inherit mode.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param preserve The preserve_mode_t to set in the given context.
-    * \param inherit The inherit_mode_t to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_copy_ns_mode: function(context: XQC_StaticContext; mode: preserve_mode_t; inherit: inherit_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the copy namespace mode as a pair consisting of the preserve and the inherit
-    * mode.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] preserve The preserve_mode_t that is set in the given context.
-    * \param[out] inherit The inherit_mode_t that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_copy_ns_mode: function(context: XQC_StaticContext; out mode: preserve_mode_t; out inherit: inherit_mode_t): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Sets the base uri in the given static context.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param base_uri The base uri to set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    set_base_uri: function(context: XQC_StaticContext; const base_uri: pchar): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Returns the base uri that is set in the given static context.
-    * The returned base uri is only valid as long as the corresponding static context
-    * is valid.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    * \param[out] base_uri The base uri that is set in the given context.
-    *
-    * \retval ::XQC_NO_ERROR
-    * \retval ::XQC_INTERNAL_ERROR
-    *)
-    get_base_uri: function(context: XQC_StaticContext; out base_uri: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Register an external function that can be called within a query.
-     * One external function consists of three function parameters, i.e. init, next, and release.
-     *
-     * \param context The XQC_StaticContext that this function pointer is a member of
-     * \param uri The URI of the external function to add.
-     * \param localname The localname of the function to add.
-     * \param init A callback function pointer that is called once when the external function
-     *             is initialized. The init function gets the global_user_data pointer
-     *             as parameter.
-     * \param next A callback function pointer that is called each time the corresponding
-     *             XQuery function is executed.
-     * \param release A callback function pointer that is called once when the external function
-     *                is deinitialized.
-     * \param global_user_data User specific data that is passed to the init function as a parameter.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::API0019_FUNCTION_ALREADY_REGISTERED,
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    register_external_function: function(context: XQC_StaticContext; const uri, localname: pchar; init: external_function_init;
-      next: external_function_next; release: external_function_release; global_user_data: pointer): XQUERY_ERROR; extdecl;
-
-
-   (**
-    * Called to free the resources associated with the XQC_StaticContext.
-    *
-    * \param context The XQC_StaticContext that this function pointer is a member of
-    *)
-    free: procedure(context: XQC_StaticContext); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: Pointer;
-  end;
-
-
-(**
- * An object of the type ::XQC_DynamicContext contains the information that is available at the 
- * time the query is executed.  It contains the information that is defined in the %XQuery 
- * specification (see http://www.w3.org/TR/xquery/#eval_context).
- * An instance of this struct can be retrieved by calling the <code>get_dynamic_context</code> function
- * of an ::XQC_Query object.
- *)
-  XQC_DynamicContext_s = record
-    (**
-     * Sets the context item to the given ::XQC_Item.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     * \param value The XQC_Item for the context item.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_context_item: function(context: XQC_DynamicContext; value: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Sets the context item to the document given by the FILE pointer.
-     * The provided document is accessible by the provided doc_uri.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     * \param doc_uri The URI referencing the given document
-     * \param document The document to which the context item should be set as a FILE pointer.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0016_LOADER_IO_ERROR,
-     * \retval ::XQP0017_LOADER_PARSING_ERROR,
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_context_document: function(context: XQC_DynamicContext; const doc_uri: pchar; document: pfile): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Sets the external variable to the value given.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     * \param qname The qname of the external variable to set
-     * \param value The XQC_Item value for the variable.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_variable_item: function(context: XQC_DynamicContext; const qname: pchar; value: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Sets the external variable to the sequence given.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     * \param qname The qname of the external variable to set
-     * \param value The XQC_Sequence value for the variable.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_variable_sequence: function(context: XQC_DynamicContext; const qname: pchar; value: XQC_Sequence): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Sets the external variable to the document given by the FILE pointer.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     * \param var_qname The qname of the external variable to set
-     * \param doc_uri The URI referencing the given document
-     * \param document The document to which the context item should be set as a FILE pointer.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0016_LOADER_IO_ERROR,
-     * \retval ::XQP0017_LOADER_PARSING_ERROR,
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_variable_document: function(context: XQC_DynamicContext; const var_qname, doc_uri: pchar; document: pfile): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Sets the implicit timezone parameter.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     * \param timezone The implicit timezone to set
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_implicit_timezone: function(context: XQC_DynamicContext; timezone: cint): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Defines the value of the default collection that is used when calling the
-     * fn:collection function without a parameter.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     * \param collection_uri the URI of the collection used by the fn:collection function.
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    set_default_collection: function(context: XQC_DynamicContext; collection_uri: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Called to free the resources associated with the XQC_DynamicContext.
-     *
-     * \param context The XQC_DynamicContext that this function pointer is a member of
-     *)
-    free: procedure(context: XQC_DynamicContext); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * This struct is Zorba's representation of an Item as defined in the
- * XQuery 1.0 and XPath 2.0 Data Model (XDM); see http://www.w3.org/TR/xpath-datamodel/. 
- * 
- * Instances of the XDM are a sequence, i.e. an ordered collection of zero or more items.
- * In the Zorba API, a sequence is represented by the XQC_Sequence struct.
- *
- * The Item class is the union of all XQuery node and atomic types.
- * The class provides functions to access the information of an Item. Note that not
- * all functions are defined on every Item kind. If a function is called on an Item that
- * does not provide the function called, an XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE error
- * is raised.
- *
- * A new atomic Item can be created using the ItemFactory. A new node Item should be created
- * by the result of a query.
- *)
-  XQC_Item_s = record
-    (**
-     * The string value is the string that is extracted by calling the fn:string function
-     * on the Item (see http://www.w3.org/TR/xpath-functions/#func-string).
-     * Note that this function is available for all types of Items.
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     * \param[out] string_value The string-value of the given item.
-     *             This string is valid as long as the given item is valid.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
-     *)
-    string_value: function(item: XQC_Item; out string_value: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Get the (optional) value of a QName's prefix.
-     * Note that this function is only available for Items of type QName.
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     * \param[out] prefix The prefix of the given QName item.
-     *             This string is valid as long as the given item is valid.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
-     *)
-    prefix: function(item: XQC_Item; out prefix: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Get the (optional) value of a QName's namespace.
-     * Note that this function is only available for Items of type QName.
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     * \param[out] namespace The namespace of the given QName item.
-     *             This string is valid as long as the given item is valid.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
-     *)
-    ns: function(item: XQC_Item; out ns: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Get the value of a QName's localname.
-     * Note that this function is only available for Items of type QName.
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     * \param[out] localname The localname of the given QName item.
-     *             This string is valid as long as the given item is valid.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
-     *)
-    localname: function(item: XQC_Item; out local_name: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Get the bool value of the boolean Item.
-     * Note that this function is only available for Items of type boolean.
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     * \param[out] bool_value 1 if the boolean value of the given item is true, 0 otherwise.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
-     *)
-    boolean_value: function(item: XQC_Item; out bool_value: cint): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Check if the value of the Item is not a number (NaN).
-     * Note that this function is implemented for all item types but may only return
-     * 1 for a numeric item (e.g. Double or Float).
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     * \param[out] is_nan 1 if the given item is not a number, 0 otherwise.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
-     *)
-    nan: function(item: XQC_Item; out is_nan: cint): XQUERY_ERROR; extdecl;
-
-
-    (**
-      Check if the value of the Item is positive or negative infinity.
-     * Note that this function is only available for numeric items (e.g. Double or Float).
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     * \param[out] inf 1 if the given item is +/-INF, 0 otherwise.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0024_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE
-     *)
-    pos_or_neg_inf: function(item: XQC_Item; out pos_or_neg_inf: cint): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Called to free the resources associated with the XQC_Item.
-     *
-     * \param item The XQC_Item that this function pointer is a member of
-     *)
-    free: procedure(item: XQC_Item); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * An instance of this class can be obtained by calling <code>item_factory</code> function
- * of an ::XQC_Implementation object.
- *
- * Each <code>create_XXX</code> function of this struct creates an ::XQC_Item of an XML Schema item.
- * Each of the functions takes either NULL or a valid XQC_Item wrapper. The latter is created
- * by calling <code>XQC_Implementation::create_item</code>. In both cases, the user is responsible 
- * for freeing the object by calling the XQC_Item::free() function.
- *)
-  XQC_ItemFactory_s = record
-    (**
-     * Creates a String Item see [http://www.w3.org/TR/xmlschema-2/#string].
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param str The string as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_string: function(factory: XQC_ItemFactory; const str: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates an AnyURI Item see [http://www.w3.org/TR/xmlschema-2/#anyURI]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param str The uri as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_anyuri: function(factory: XQC_ItemFactory; const str: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a QName Item see [http://www.w3.org/TR/xmlschema-2/#QName]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param str The uri as a char pointer.
-     * \param localname The localname as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_qname2: function(factory: XQC_ItemFactory; const uri, localname: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a QName Item see [http://www.w3.org/TR/xmlschema-2/#QName]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param str The uri as a char pointer.
-     * \param prefix The prefix as a char pointer.
-     * \param localname The localname as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_qname3: function(factory: XQC_ItemFactory; const uri, prefix, localname: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Boolean Item see [http://www.w3.org/TR/xmlschema-2/#bool]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param boolean 0 for a boolean <code>false</code> boolean item, 1 otherwise.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_boolean: function(factory: XQC_ItemFactory; boolean: cint; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a NCName Item see [http://www.w3.org/TR/xmlschema-2/#NCName]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param ncname The NCName as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_ncname: function(factory: XQC_ItemFactory; const ncname: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Base64Binary Item see [http://www.w3.org/TR/xmlschema-2/#base64Binary]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param binary_data The binary data as a char pointer.
-     * \param letter The length of the binary data.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_base64binary: function(factory: XQC_ItemFactory; const binary_data: pchar; length: csize_t; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Decimal Item see [http://www.w3.org/TR/xmlschema-2/#decimal]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The value as a doule
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_decimal: function(factory: XQC_ItemFactory; value: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Decimal Item see [http://www.w3.org/TR/xmlschema-2/#decimal]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The value as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_decimal_char: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates an Integer Item see [http://www.w3.org/TR/xmlschema-2/#integer]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param integer_value The value as a long long.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_integer: function(factory: XQC_ItemFactory; const integer_value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates an Integer Item see [http://www.w3.org/TR/xmlschema-2/#integer]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param integer_value The value as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_integer_char: function(factory: XQC_ItemFactory; const integer_value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Long Item see [http://www.w3.org/TR/xmlschema-2/#long]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param long_value The value as a long long.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_long: function(factory: XQC_ItemFactory; const long_value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Int Item see [http://www.w3.org/TR/xmlschema-2/#int]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param int_value The value as an int.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_int: function(factory: XQC_ItemFactory; const int_value: cint; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Short Item see [http://www.w3.org/TR/xmlschema-2/#short]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param short_value The value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_short: function(factory: XQC_ItemFactory; const short_value: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Byte Item see [http://www.w3.org/TR/xmlschema-2/#byte]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param byte_value The byte value as a char.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_byte: function(factory: XQC_ItemFactory; const byte_value: cchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Date Item see [http://www.w3.org/TR/xmlschema-2/#date]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param date_value The date value as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_date_char: function(factory: XQC_ItemFactory; const date_value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Date Item see [http://www.w3.org/TR/xmlschema-2/#date]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param year The year value as a short.
-     * \param month The month value as a short.
-     * \param day The day value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_date: function(factory: XQC_ItemFactory; const year, month, day: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a DateTime Item see [http://www.w3.org/TR/xmlschema-2/#dateTime]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param year The year value as a short.
-     * \param month The month value as a short.
-     * \param day The day value as a short.
-     * \param hour The hour value as a short.
-     * \param minute The minute value as a short.
-     * \param seconds The seconds value as a short.
-     * \param timezone_hours The timezone as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_datetime: function(factory: XQC_ItemFactory; const year, month, day, hour, minute: cshort;
-      seconds: cdouble; timezone_hours: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a DateTime Item see [http://www.w3.org/TR/xmlschema-2/#dateTime]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param datetime_value The string representation of the datetime value as a char pointer
-     *                       (for example, 2002-10-10T12:00:00-05:00).
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_datetime_char: function(factory: XQC_ItemFactory; const datetime_value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Double Item see [http://www.w3.org/TR/xmlschema-2/#double]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_double: function(factory: XQC_ItemFactory; const value: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Double Item see [http://www.w3.org/TR/xmlschema-2/#double]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The value as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_double_char: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Duration Item see [http://www.w3.org/TR/xmlschema-2/#duration]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param year The year value as a short.
-     * \param month The month value as a short.
-     * \param day The day value as a short.
-     * \param hour The hour value as a short.
-     * \param minute The minute value as a short.
-     * \param seconds The seconds value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_duration: function(factory: XQC_ItemFactory; const year, month, day, hour, minute: cshort;
-      seconds: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Float Item see [http://www.w3.org/tr/xmlschema-2/#float]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The float value as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_float: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a gDay Item see [http://www.w3.org/TR/xmlschema-2/#gDay]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param day The day value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_gday: function(factory: XQC_ItemFactory; day: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a gMonth Item see [http://www.w3.org/TR/xmlschema-2/#gMonth]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param month The month value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_gmonth: function(factory: XQC_ItemFactory; month: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a gMonthDay Item see [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param month The month value as a short.
-     * \param day The day value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_gmonthday: function(factory: XQC_ItemFactory; month, day: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a gYear Item see [http://www.w3.org/TR/xmlschema-2/#gYear]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param year The year value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_gyear: function(factory: XQC_ItemFactory; year: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a gYearMonth Item see [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param year The year value as a short.
-     * \param month The month value as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_gyearmonth: function(factory: XQC_ItemFactory; year, month: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a HexBinary Item see [http://www.w3.org/TR/xmlschema-2/#hexBinary]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param hex_data The hex data as a char pointer.
-     * \param size The size of the hex data.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_hexbinary: function(factory: XQC_ItemFactory; const hex_data: pchar; size: csize_t; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a negativeInteger Item see [http://www.w3.org/TR/xmlschema-2/#negativeInteger]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The negative integer as a long long value.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_negativeinteger: function(factory: XQC_ItemFactory; value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a nonNegativeInteger Item see [http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The non-negative integer as an unsigned long long value.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_nonnegativeinteger: function(factory: XQC_ItemFactory; value: culonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a nonPositiveInteger Item see [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The non-positive integer as a long long value.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_nonpositiveinteger: function(factory: XQC_ItemFactory; value: clonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a positiveInteger Item see [http://www.w3.org/TR/xmlschema-2/#positiveInteger]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The positive integer as an unsigned long long value.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_positiveinteger: function(factory: XQC_ItemFactory; value: culonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Time Item see [http://www.w3.org/TR/xmlschema-2/#time]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The time as a char pointer.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_time_char: function(factory: XQC_ItemFactory; const value: pchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Time Item see [http://www.w3.org/TR/xmlschema-2/#time]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param hour The hour as a short.
-     * \param minute The minute as a short.
-     * \param second The second as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_time: function(factory: XQC_ItemFactory; hour, minute: cshort; second: cdouble; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a Time Item see [http://www.w3.org/TR/xmlschema-2/#time]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param hour The hour as a short.
-     * \param minute The minute as a short.
-     * \param second The second as a double.
-     * \param timezone_hours The timezone hours as a short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_time_timezone: function(factory: XQC_ItemFactory; hour, minute: cshort; second: cdouble;
-      timezone_hours: cshort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates an Unsigned Byte Item see [http://www.w3.org/TR/xmlschema-2/#unsignedByte]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The unsigned byte value as an unsigned char.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_unsignedbyte: function(factory: XQC_ItemFactory; value: cuchar; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates an unsigned int Item see [http://www.w3.org/TR/xmlschema-2/#unsignedInt]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The unsigned int value as an unsigned int.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_unsignedint: function(factory: XQC_ItemFactory; value: cuint; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates an unsignedLong Item see [http://www.w3.org/TR/xmlschema-2/#unsignedLong]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The unsigned long value as an unsigned long long.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_unsignedlong: function(factory: XQC_ItemFactory; value: culonglong; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Creates a unsignedShort Item see [http://www.w3.org/TR/xmlschema-2/#unsignedShort]
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param value The unsigned short value as an unsigned short.
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::XQP0025_COULD_NOT_CREATE_ITEM
-     *)
-    create_unsignedshort: function(factory: XQC_ItemFactory; value: cushort; out item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Called to free the resources associated with the XQC_ItemFactory.
-     *
-     * \param factory The XQC_ItemFactory that this function pointer is a member of
-     * \param[out] item The item to create. This can either be a wrapper created using
-     *                 ::XQC_ItemFactory::create_item or a pointer initialized to 0.
-     *)
-    free: procedure(factory: XQC_ItemFactory); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * This struct represents an instance of the XQuery 1.0 and XPath 2.0 Data Model (XDM).
- *
- * See http://www.w3.org/TR/xpath-datamodel/.
- *)
-  XQC_Sequence_s = record
-    (**
-     * Get the next item of the sequence.
-     *
-     * \param sequence The XQC_Sequence_s that this function pointer is a member of
-     * \param[out] item The item wrapper that should contain the next item if XQ_NO_ERROR is returned
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval any XQuery type or dynamic error
-     *)
-    next: function(sequence: XQC_Sequence; item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * called to free the resources associated with the xqc_itemfactory.
-     *
-     * \param sequence the XQC_Sequence that this function pointer is a member of
-     *)
-    free: procedure(sequence: XQC_Sequence); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * A Collection is a sequence of Node Items.
- *
- * Each Collection is created by the XmlDataManager and referenced by a URI.
- * The URI can be accessed in a query's fn:collection function.
- *)
-  XQC_Collection_s = record
-    (**
-     * Get the URI of a collection as an anyURI Item.
-     *
-     * \param collection the XQC_Collection_s that this function pointer is a member of
-     * \param[out] uri_item The uri item of the given collection. The user is responsible
-     *             for freeing the object by calling the XQC_Item::free() function.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     *)
-    get_name: function(collection: XQC_Collection; out name_item: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Adds a Node Item to the Collection
-     *
-     * \param collection the XQC_Collection_s that this function pointer is a member of
-     * \param node The node item to add to the given collection.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::API0007_COLLECTION_ITEM_MUST_BE_A_NODE
-     *)
-    add_node: function(collection: XQC_Collection; node: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Deletes a Node Item from the given Collection
-     *
-     * \param collection the XQC_Collection_s that this function pointer is a member of
-     * \param node The node item to delete from the given collection.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::API0007_COLLECTION_ITEM_MUST_BE_A_NODE
-     *)
-    delete_node: function(collection: XQC_Collection; node: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Adds a sequence of Node Items to the Collection
-     *
-     * \param collection the XQC_Collection_s that this function pointer is a member of
-     * \param sequence The sequence of node items to add to the given collection.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0019_INTERNAL_ERROR
-     * \retval ::API0007_COLLECTION_ITEM_MUST_BE_A_NODE
-     *)
-    add_sequence: function(collection: XQC_Collection; sequence: XQC_Sequence): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Adds a document given by the FILE pointer to this collection.
-     *
-     * \param collection the XQC_Collection_s that this function pointer is a member of
-     * \param doc The document to add as a FILE pointer.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0016_LOADER_IO_ERROR,
-     * \retval ::XQP0017_LOADER_PARSING_ERROR,
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    add_document: function(collection: XQC_Collection; doc: pfile): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Adds a document given by the char pointer to this collection.
-     *
-     * \param collection the XQC_Collection_s that this function pointer is a member of
-     * \param doc The document to add as a char pointer.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0016_LOADER_IO_ERROR,
-     * \retval ::XQP0017_LOADER_PARSING_ERROR,
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    add_document_char: function(collection: XQC_Collection; const doc: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * called to free the resources associated with the xqc_itemfactory.
-     *
-     * \param collection the XQC_Collection that this function pointer is a member of
-     *)
-    free: procedure(collection: XQC_Collection); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * Using the XmlDataManager one can manage documents and collections.
- * 
- * The XmlDataManager is a singelton instance. The instance can be accessed by calling 
- * XQC_Implementation::data_manager. The XmlDataManager is thread-safe.
- *)
-  XQC_DataManager_s = record
-    (**
-     * This function loads a document from the given FILE pointer. The document
-     * is identified by the given URI.
-     *
-     * \param data_manager The XQC_DataManager that this function pointer is a member of
-     * \param doc_uri The URI of the document to load.
-     * \param document The document to load as a FILE pointer.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0016_LOADER_IO_ERROR,
-     * \retval ::XQP0017_LOADER_PARSING_ERROR,
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    load_document: function(data_manager: XQC_DataManager; const doc_uri: pchar; document: pfile): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * This function loads a document that is retrieved from the given URI location. The document
-     * is identified by the given URI.
-     *
-     * \param data_manager The XQC_DataManager that this function pointer is a member of
-     * \param location The URI of the document to load.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQP0016_LOADER_IO_ERROR,
-     * \retval ::XQP0017_LOADER_PARSING_ERROR,
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    load_document_uri: function(data_manager: XQC_DataManager; const location: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Get the document identified by the given URI.
-     *
-     * \param data_manager The XQC_DataManager that this function pointer is a member of
-     * \param document_uri The URI of the document to retrieve.
-     * \param[out] doc The Item of the document to get.  The user is responsible
-     *                 for freeing the object by calling the XQC_Item::free() function.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    get_document: function(data_manager: XQC_DataManager; const document_uri: pchar; out doc: XQC_Item): XQUERY_ERROR; extdecl;
-
-
-    (*
-     * Delete the document identified by the given URI.
-     *
-     * \param data_manager The XQC_DataManager that this function pointer is a member of
-     * \param document_uri The URI of the document to delete.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    delete_document: function(data_manager: XQC_DataManager; const document_uri: pchar): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Create a new collection that is identified by the given URI.
-     *
-     * \param data_manager The XQC_DataManager that this function pointer is a member of
-     * \param document_uri The URI of the collection to create.
-     * \param[out] col The collection to create. The user is responsible
-     *                 for freeing the object by calling the XQC_Item::free() function.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    create_collection: function(data_manager: XQC_DataManager; const collection_uri: pchar; out col: XQC_Collection): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Get the collection that is identified by the given URI.
-     *
-     * \param data_manager The XQC_DataManager that this function pointer is a member of
-     * \param document_uri The URI of the collection to retrieve.
-     * \param[out] col The collection to retrieve. The user is responsible
-     *                 for freeing the object by calling the XQC_Item::free() function.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    get_collection: function(data_manager: XQC_DataManager; const collection_uri: pchar; out col: XQC_Collection): XQUERY_ERROR; extdecl;
-
-
-    (**
-     * Delete the collection that is identified by the given URI.
-     *
-     * \param data_manager The XQC_DataManager that this function pointer is a member of
-     * \param document_uri The URI of the collection to delete.
-     *
-     * \retval ::XQC_NO_ERROR
-     * \retval ::XQC_INTERNAL_ERROR
-     *)
-    delete_collection: function(data_manager: XQC_DataManager; const collection_uri: pchar): XQUERY_ERROR; extdecl;
-
-    (**
-     * Called to free the resources associated with the XQC_DataManager.
-     *
-     * \param context The XQC_DataManager that this function pointer is a member of
-     *)
-    free: procedure(data_manager: XQC_DataManager); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * The ::XQC_OutputStream struct is designed to be passed to an XQC implementation in order
- * to return streaming data (i.e. the result of a query).
- *)
-  XQC_OutputStream_s = record
-    (**
-     * The function is called to provide the streaming result of a query
-     * in the buffer provided.
-     *
-     * \param stream The XQC_OutputStream that this function pointer is a member of
-     * \param buf The buffer that contains the data
-     * \param length The length of the contents in the buffer
-     *)
-    write: procedure(stream: XQC_OutputStream; const buf: pchar; length: cuint); extdecl;
-
-
-    (**
-     * Called to free the resources associated with the XQC_OutputStream.
-     * Free is called by the implementation if it finished writing to the stream.
-     *
-     * \param stream The XQC_OutputStream that this function pointer is a member of
-     *
-     *)
-    free: procedure(stream: XQC_OutputStream); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * The ::XQC_InputStream struct is designed to be populated by users for the purpose
- * of streaming data into an XQC implementation.
- *)
-  XQC_InputStream_s = record
-     (**
-      * The function called to read more of the input (e.g. the query). The function should read
-      * the next chunk of input into the buffer provided, returning the length of the
-      * data read.
-      *
-      * \param stream The XQC_InputStream that this function pointer is a member of
-      * \param[out] buffer The buffer to read the data into
-      * \param length The length of the buffer
-      *
-      * \return The number of bytes read - this will be less than length if the end of the input is reached
-      *         or -1 if an error occured
-      *
-      *)
-    read: function(stream: XQC_InputStream; const buf: pchar; length: cuint): cint; extdecl;
-
-
-    (**
-     * Called to free the resources associated with the XQC_InputStream.
-     * The free function is called by the implementation if it finished reading from the stream.
-     * This allows for lazy evaluation without the user needing to know when reading from the
-     * stream has finished.
-     *
-     * \param stream The XQC_InputStream that this function pointer is a member of
-     *
-     *)
-    free: procedure(stream: XQC_InputStream); extdecl;
-
-
-    (**
-     * for internal use only
-     *)
-    data: pointer;
-  end;
-
-
-(**
- * The ::XQC_ErrorHandler struct is designed to be populated by users for the purpose
- * of collecting more detailed error messages from an XQC implementation. An XQC_ErrorHandler
- * can be set for a query using the XQC_Query::set_error_handler() function.
- *
- * The XQC_ErrorHandler struct has no free() function pointer because the user remains 
- * responsible for freeing the resources associated with this struct.
- *)
-  XQC_ErrorHandler_s = record
-    (**
-     * The function is called when an error occurs. The function receives the components of the
-     * error as arguments. When this function returns, the implementation will exit query parsing or
-     * execution with the error enumeration value passed as an argument.
-     *
-     * \param handler The XQC_ErrorHandler that this function pointer is a member of
-     * \param error The error as a value of the XQUERY_ERROR enum.
-     * \param local_name The local name of the error or an empty string if no local_name is given 
-     *                   (e.g. for errors not defined in the spec).
-     * \param description A detailed description of the error or an empty string if no description is available.
-     * \param query_uri The uri of the query causing the error or an empty string if no uri is available for the query.
-     * \param line The line number of the query where the error occured.
-     * \param components The column number in the line in the query where the error occured.
-     *)
-    error: procedure(handler: XQC_ErrorHandler; error: XQUERY_ERROR; const local_name, description,
-      query_uri: pchar; line, column: cuint); extdecl;
-
-
-    (**
-     * Can be used for user specific purposes.
-     *)
-    data: pointer;
-  end;
-
 
 (**
  * The zorba_implementation function creates a new ::XQC_Implementation object.

+ 1 - 1
packages/zorba/src/zorba_options.inc

@@ -14,7 +14,7 @@
  * limitations under the License.
  *)
 
-
+type
 (** \brief The optimization level used for optimizing the query. *)
   Zorba_opt_level_t = (
     ZORBA_OPT_LEVEL_O0, (**< Don't use any optimization. *)

+ 2 - 1
rtl/darwin/arm/sighnd.inc

@@ -33,7 +33,8 @@ begin
           Else
             Res:=207; {coprocessor error}
         end;
-        SigContext^.uc_mcontext^.__fs.__fpscr := SigContext^.uc_mcontext^.__fs.__fpscr and not($1fff);
+        { clear "exception happened" flags }
+        SigContext^.uc_mcontext^.__fs.__fpscr := SigContext^.uc_mcontext^.__fs.__fpscr and not($df);
       end;
     SIGBUS:
         res:=214;

+ 17 - 2
rtl/solaris/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/12]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2009/11/17]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
@@ -411,6 +411,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes strings objpas macpas heaptrc lineinfo lnfodwrf baseunix unixutil termio unix initc cmem crt printer sysutils typinfo math fgl classes matrix varutils charset ucomplex getopts errors sockets terminfo dl dynlibs video mouse keyboard variants types dateutils sysconst strutils fmtbcd rtlconsts cthreads dos objects cwstring fpintres $(CPU_UNITS)
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes strings objpas macpas heaptrc lineinfo lnfodwrf baseunix unixutil termio unix initc cmem crt printer sysutils typinfo math fgl classes matrix varutils charset ucomplex getopts errors sockets terminfo dl dynlibs video mouse keyboard variants types dateutils sysconst strutils fmtbcd rtlconsts cthreads dos objects cwstring fpintres $(CPU_UNITS)
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_UNITS+=$(SYSTEMUNIT) unixtype ctypes strings objpas macpas heaptrc lineinfo lnfodwrf baseunix unixutil termio unix initc cmem crt printer sysutils typinfo math fgl classes matrix varutils charset ucomplex getopts errors sockets terminfo dl dynlibs video mouse keyboard variants types dateutils sysconst strutils fmtbcd rtlconsts cthreads dos objects cwstring fpintres $(CPU_UNITS)
 endif
@@ -585,6 +588,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_IMPLICITUNITS+=exeinfo
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_IMPLICITUNITS+=exeinfo
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_IMPLICITUNITS+=exeinfo
 endif
@@ -759,6 +765,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst rtlconst
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst rtlconst
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_RSTS+=math varutils typinfo classes variants dateutils sysconst rtlconst
 endif
@@ -934,6 +943,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(OSPROCINC)
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(OSPROCINC)
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(OSPROCINC)
 endif
@@ -1108,6 +1120,9 @@ endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(COMMON)
 endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(COMMON)
+endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(UNIXINC) $(COMMON)
 endif

+ 13 - 5
rtl/solaris/ostypes.inc

@@ -35,32 +35,40 @@ CONST
     ST_FSTYPSZ = 16;           {* array size for file system type name *}
 
 TYPE
-    blksize_t = longint;
-    blkcnt_t = longint;
+    blksize_t = clong;
+    blkcnt_t = clong;
 
    { file characteristics services }
    stat = packed record { verify the alignment of the members }
      st_dev : dev_t;
+{$ifndef CPU64}
      st_pad1 : array[1..3] of longint;  { reserve for dev expansion }
+{$endif ndef CPU64}
      st_ino : ino_t;
      st_mode : mode_t;
      st_nlink : nlink_t;
      st_uid : uid_t;
      st_gid : gid_t;
      st_rdev : dev_t;
+{$ifndef CPU64}
      st_pad2 : array[1..2] of longint;
+{$endif ndef CPU64}
      st_size : off_t;
+{$ifndef CPU64}
      st_pad3 : longint;   {* reserve pad for future off_t expansion *}
+{$endif ndef CPU64}
      st_atime : time_t;
-     st_atimens : longint;    { access time nanosecond field         }
+     st_atimens : clong;    { access time nanosecond field         }
      st_mtime : time_t;
-     st_mtimens : longint;    { modification time nanosecond field   }
+     st_mtimens : clong;    { modification time nanosecond field   }
      st_ctime : time_t;
-     st_ctimens : longint;    { modification time nanosecond field   }
+     st_ctimens : clong;    { modification time nanosecond field   }
      st_blksize : blksize_t;
      st_blocks : blkcnt_t;
      st_fstype : array[0..ST_FSTYPSZ-1] of char;
+{$ifndef CPU64}
      st_pad4 : array[1..8] of longint;
+{$endif ndef CPU64}
    end;
    TStat             = Stat;
    PStat             = ^Stat;

+ 1 - 1
rtl/solaris/ptypes.inc

@@ -33,7 +33,7 @@ introduction)
 
 Type
 
-    dev_t    = cuint;          { used for device numbers      }
+    dev_t    = culong;          { used for device numbers      }
     TDev     = dev_t;
     pDev     = ^dev_t;
 

+ 84 - 0
rtl/solaris/x86_64/sighnd.inc

@@ -0,0 +1,84 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    Signal handler is arch dependant due to processor to language
+    exception conversion.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program 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.
+
+ **********************************************************************}
+
+const
+  FPE_INTDIV = 1;
+  FPE_INTOVF = 2;
+  FPE_FLTDIV = 3;
+  FPE_FLTOVF = 4;
+  FPE_FLTUND = 5;
+  FPE_FLTRES = 6;
+  FPE_FLTINV = 7;
+  FPE_FLTSUB = 8;
+
+
+procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);public name '_FPC_DEFAULTSIGHANDLER';cdecl;
+var
+  res : word;
+  addr : pointer;
+  frame : pointer;
+begin
+  res:=0;
+  if assigned(sigcontext) then
+    begin
+      addr := pointer(sigcontext^.uc_mcontext.gregs[REG_PC]);
+      frame := pointer(sigcontext^.uc_mcontext.gregs[REG_FP])
+    end
+  else
+    begin
+      addr := nil;
+      frame := nil;
+    end;
+  case sig of
+    SIGFPE :
+        begin
+          case  siginfo^.si_code of
+            FPE_INTDIV:
+              res:=200;
+            FPE_INTOVF:
+              res:=205;
+            FPE_FLTDIV:
+              res:=200;
+            FPE_FLTOVF:
+              res:=205;
+            FPE_FLTUND:
+              res:=206;
+            else
+              res:=207;
+          end;
+        end;
+    SIGILL,
+    SIGSEGV :
+        begin
+          res:=216;
+        end;
+    SIGBUS :
+      begin
+        res:=214;
+      end;
+    SIGINT:
+        res:=217;
+    SIGQUIT:
+        res:=233;
+  end;
+  reenable_signal(sig);
+  { give runtime error at the position where the signal was raised }
+  if res<>0 then
+    HandleErrorAddrFrame(res,addr,frame);
+end;
+
+

+ 251 - 0
rtl/solaris/x86_64/sighndh.inc

@@ -0,0 +1,251 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2009 by Pierre Muller,
+    member of the Free Pascal development team.
+
+    Sigcontext and Sigaction for amd64/i386 CPUs
+
+    Adapted from
+    http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/intel/sys/regset.h
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program 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.
+
+ **********************************************************************}
+
+{$packrecords C}
+
+{$packrecords C}
+
+const
+{ i386/amd64 definition }
+
+{
+    #if defined(__amd64)
+    #define	_NGREG	28
+    #else
+    #define	_NGREG	19
+    #endif
+}
+{$ifdef x86_64 }
+  _NGREG = 28;
+{$else i386 }
+  _NGREG = 19;
+{$endif i386 }
+  _NGREG32 = 19;
+  _NGREG64 = 28;
+
+{$ifdef x86_64}
+(* AMD64 layout
+      #define REG_GSBASE      27
+      #define	REG_FSBASE	26
+      #define	REG_DS		25
+      #define	REG_ES		24
+
+      #define	REG_GS		23
+      #define	REG_FS		22
+      #define	REG_SS		21
+      #define	REG_RSP		20
+      #define	REG_RFL		19
+      #define	REG_CS		18
+      #define	REG_RIP		17
+      #define	REG_ERR		16
+      #define	REG_TRAPNO	15
+      #define	REG_RAX		14
+      #define	REG_RCX		13
+      #define	REG_RDX		12
+      #define	REG_RBX		11
+      #define	REG_RBP		10
+      #define	REG_RSI		9
+      #define	REG_RDI		8
+      #define	REG_R8		7
+      #define	REG_R9		6
+      #define	REG_R10		5
+      #define	REG_R11		4
+      #define	REG_R12		3
+      #define	REG_R13		2
+      #define	REG_R14		1
+      #define	REG_R15		0
+*)
+  REG_R15    = 0;
+  REG_R14    = 1;
+  REG_R13    = 2;
+  REG_R12    = 3;
+  REG_R11    = 4;
+  REG_R10    = 5;
+  REG_R9     = 6;
+  REG_R8     = 7;
+  REG_RDI    = 8;
+  REG_RSI    = 9;
+  REG_RBP    = 10;
+  REG_RBX    = 11;
+  REG_RDX    = 12;
+  REG_RCX    = 13;
+  REG_RAX    = 14;
+  REG_TRAPNO = 15;
+  REG_ERR    = 16;
+  REG_RIP    = 17;
+  REG_CS     = 18;
+  REG_RFL    = 19;
+  REG_RSP    = 20;
+  REG_SS     = 21;
+  REG_FS     = 22;
+  REG_GS     = 23;
+  REG_ES     = 24;
+  REG_DS     = 25;
+  REG_FSBASE = 26;
+  REG_GSBASE = 27;
+
+{$else i386}
+(* I386 layout
+    #define     SS              18	/* only stored on a privilege transition */
+    #define	UESP		17	/* only stored on a privilege transition */
+    #define	EFL		16
+    #define	CS		15
+    #define	EIP		14
+    #define	ERR		13
+    #define	TRAPNO		12
+    #define	EAX		11
+    #define	ECX		10
+    #define	EDX		9
+    #define	EBX		8
+    #define	ESP		7
+    #define	EBP		6
+    #define	ESI		5
+    #define	EDI		4
+    #define	DS		3
+    #define	ES		2
+    #define	FS		1
+    #define	GS		0
+*)
+  REG_GS     = 0;
+  REG_FS     = 1;
+  REG_ES     = 2;
+  REG_DS     = 3;
+  REG_EDI    = 4;
+  REG_ESI    = 5;
+  REG_EBP    = 6;
+  REG_ESP    = 7;
+  REG_EBX    = 8;
+  REG_EDX    = 9;
+  REG_ECX    = 10;
+  REG_EAX    = 11;
+  REG_TRAPNO = 12;
+  REG_ERR    = 13;
+  REG_EIP    = 14;
+  REG_CS     = 15;
+  REG_EFL    = 16;
+  REG_UESP   = 17; (* only stored on a privilege transition *)
+  REG_SS     = 18;   (* only stored on a privilege transition *)
+{$endif i386}
+
+
+{$ifdef x86_64 }
+  REG_PC  = REG_RIP;
+  REG_FP  = REG_RBP;
+  REG_SP  = REG_RSP;
+  REG_PS  = REG_RFL;
+  REG_R0  = REG_RAX;
+  REG_R1  = REG_RDX;
+{$else	/* __i386 */ }
+  REG_PC  = REG_EIP;
+  REG_FP  = REG_EBP;
+  REG_SP  = REG_UESP;
+  REG_PS  = REG_EFL;
+  REG_R0  = REG_EAX;
+  REG_R1  = REG_EDX;
+{$endif }
+
+type
+{$ifdef x86_64}
+  TGReg = cint64;
+{$else}
+  TGReg = cint32;
+{$endif}
+  TGReg32 = cint32;
+  TGReg64 = cint64;
+
+  TGRegSet = array[0.._NGREG-1] of TGReg;
+  TGRegSet32 = array[0.._NGREG32-1] of TGReg32;
+  TGRegSet64 = array[0.._NGREG64-1] of TGReg64;
+
+
+
+type
+  FPU_SAVE_TYPE = (fnsave_type, fxsave_type);
+
+  TFPURegs = record
+    case longint of
+      0: ( fpuregs: array[0..31] of cardinal);
+      1: ( fpudregs: array[0..15] of double);
+  end;
+
+  PFQ = ^TFQ;
+  TFQ = record
+    fpq_addr : ^cuint;
+    fpq_instr : cuint;
+  end;
+
+(*  struct fpchip_state {
+    uint32_t state[27];	/* 287/387 saved state */
+    uint32_t status;	/* saved at exception */
+    uint32_t mxcsr;		/* SSE control and status */
+    uint32_t xstatus;	/* SSE mxcsr at exception */
+    uint32_t __pad[2];	/* align to 128-bits */
+    upad128_t xmm[8];	/* %xmm0-%xmm7 */
+    } fpchip_state;
+*)
+  TUpad128 = record
+   case longint of
+   0: (_q : extended;);
+   1: (_l : array [0..4-1] of cuint32;);
+  end;
+
+  TFPChip_State = record
+    state   : array [0..27-1] of cuint32;
+    status  : cuint32;
+    mxcsr   : cuint32;
+    xstatus : cuint32;
+    __pad   : array [0..1] of cuint32;
+    xmm   : array [0..8-1] of TUpad128;
+  end;
+
+  TFP_emul_space = record
+    fp_emul : array [0..248-1] of cuint8;
+    fp_epad : array [0..1] of cuint8;
+  end;
+
+  TFPU = record
+  case longint of
+   0: (fpchip_state : TFPChip_state;);
+   1: (fp_emul_space : TFP_emul_space;);
+   2: (f_fpregs : Array[0..130-1] of cuint32;);
+  end;
+
+  TFPRegSet = TFPU;
+
+  TMContext = record
+    gregs    : TGRegSet;
+    fpregs   : TFPRegSet;
+  end;
+
+  TStack = record
+    ss_sp     : pointer;
+    ss_size  : size_t;
+    ss_flags : cint;
+  end;
+
+  PSigContext = ^TSigContext;
+  TSigContext = record
+    uc_flags    : cuint;
+    uc_link     : PSigContext;
+    uc_sigmask  : sigset_t;
+    uc_stack    : TStack;
+    uc_mcontext : TMContext;
+    __uc_filler : array[0..5-1] of clong;
+  end;
+

+ 254 - 0
rtl/solaris/x86_64/start.inc

@@ -0,0 +1,254 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2009 by Pierre Muller,
+    member of the Free Pascal development team.
+
+    Program startup
+    Adapted from source code on opensolaris 2.11
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program 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.
+
+ **********************************************************************}
+
+(*
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+*)
+
+(*
+/*
+ * This crt1.o module is provided as the bare minimum required to build
+ * a 64-bit executable with gcc.  It is installed in /usr/lib/amd64
+ * where it will be picked up by gcc, along with crti.o and crtn.o
+ */
+
+	.ident	"%Z%%M%	%I%	%E% SMI"
+
+	.file	"crt1.s"
+
+	.globl	_start
+
+/* global entities defined elsewhere but used here */
+	.globl	main
+	.globl	__fpstart
+	.globl	exit
+	.globl	_exit
+	.weak	_DYNAMIC
+*)
+type
+   TCdeclProcedure = procedure; cdecl;
+function atexit(proc:TCdeclProcedure):longint;cdecl;external 'c' name 'atexit'{ @plt };
+procedure C_exit;cdecl;external 'c' name 'exit';
+procedure _exit;cdecl;external 'c' name '_exit';
+//procedure _fini;cdecl;external 'c' name '_fini';
+//procedure __fpstart;cdecl;external 'c' name '__fpstart'{ @plt };
+//procedure __fsr;cdecl;external 'c' name '__fsr';
+//procedure _init;cdecl;external 'c' name '_init';
+procedure PascalMain;cdecl;external name 'PASCALMAIN';
+
+
+{vars are not correctly transformed :(
+var
+  _DYNAMIC : longint; cvar; external;
+  __Argv : pointer; cvar; external;
+  environ : pointer; cvar; external;
+  __get_exit_frame_monitor_ptr : pointer; cvar; external;
+  __do_exit_code_ptr : pointer; cvar; external;
+}
+
+(*
+	.section	.data
+
+	.weak	environ
+	.set	environ,_environ
+	.globl	_environ
+	.type	_environ,@object
+	.size	_environ,8
+	.align	8
+_environ:
+	.8byte	0x0
+
+	.globl	__environ_lock
+	.type	__environ_lock,@object
+	.size	__environ_lock,24
+	.align	8
+__environ_lock:
+	.zero	24
+
+	.globl	___Argv
+	.type	___Argv,@object
+	.size	___Argv,8
+	.align	8
+___Argv:
+	.8byte	0x0
+
+
+	.globl	__longdouble_used
+	.section	.data
+	.align	8
+	.type	__longdouble_used,@object
+	.size	__longdouble_used,4
+__longdouble_used:
+	.4byte	0
+
+*)
+var
+  _environ : pointer; cvar;
+  __environ_lock : Array[0..24-1] of byte; cvar;
+  ___Argv : pointer;cvar;
+  __longdouble_used : longint; cvar;
+
+procedure _DYNAMIC;cdecl;external 'c' name '_DYNAMIC'; { should be weak }
+
+(*
+/*
+ *   The SVR4/i386 ABI (pages 3-29) says that when the entry
+ *   point runs registers' %rbp, %rsp, %rdx values are specified
+ *   the following:
+ *
+ *	%rbp The content of this register is unspecified at
+ *		process initialization time, but the user code should mark
+ *		the deepest stack frame by setting the frame pointer to zero.
+ *		No other frame's %ebp should have a zero value.
+ *
+ *	%rsp Performing its usual job, the stack pointer holds the address
+ *	of the bottom of the stack, which is guaranteed to be
+ *	quadword aligned.
+ *
+ *		The stack contains the arguments and environment:
+ *        ...
+ *        envp[0]		(16+(8*argc))(%rsp)
+ *        NULL			(8+(8*argc))(%rsp)
+ *        ...
+ *        argv[0]		8(%rsp)
+ *        argc			0(%rsp)
+ *
+ *	%rdx In a conforming program, this register contains a function
+ *		pointer that the application should register with atexit(BA_OS).
+ *		This function is used for shared object termination code
+ *		[see Dynamic Linking in Chapter 5 of the System V ABI].
+ *
+ */
+*)
+procedure _start;assembler;nostackframe;public name '_start';
+asm
+(*
+/*
+ * Allocate a NULL return address and a NULL previous %rbp as if
+ * there was a genuine call to _start.
+ */
+*)
+   pushq  $0x0
+   pushq  $0x0
+   movq   %rsp,%rbp
+(*
+/*
+ * The stack now is
+ *
+ *        envp[0]		(32+(8*argc))(%rsp)      - (A)
+ *        NULL			(24+(8*argc))(%rsp)
+ *        ...
+ *        argv[0]		24(%rbp)		 - (B)
+ *        argc			16(%rbp)
+ *	  0			8(%rbp)
+ *	  0			0(%rbp)
+ */
+*)
+   movq   $_DYNAMIC,%rax
+   testq  %rax,%rax
+   je     .Label1
+   movq   %rdx,%rdi { register rt_do_exit }
+   call   atexit
+.Label1:
+(* What should we do about this?
+   movq   $_fini,%rdi
+   call   atexit *)
+(*
+/*
+ * Calculate the location of the envp array by adding the size of
+ * the argv array to the start of the argv array.
+ */
+*)
+   movq   0x10(%rbp),%rax
+   movl   %eax,argc
+   movq   _environ,%rcx
+   testq  %rcx,%rcx
+   jne    .Label3
+   lea    0x20(%rbp,%rax,8),%rcx
+.Label3:
+   movq   %rcx,_environ
+   // Specificc to Free Pascal
+   movq   %rcx,envp
+(*
+/*
+ * Force stack alignment - below here there must have been an even
+ * number of un-popped pushq instructions whenever a call is reached
+ */
+*)
+   andq   $-16,%rsp
+   pushq  %rdx
+   leaq   24(%rbp),%rdx   { argv (B) }
+   movq   %rdx,___Argv
+   mov    %rdx,argv
+   pushq   %rcx
+   pushq   %rdx
+   pushq   %rax
+   (* Should this be done, and where?
+   call   __fpstart
+   call   _init *)
+   popq   %rdi
+   popq   %rsi
+   popq   %rdx
+   popq   %rcx
+   call   PASCALMAIN      { main(argc,argv,envp) }
+   pushq  %rax
+   pushq  %rax
+   movq   %rax,%rdi	  { and call exit }
+   call   C_exit
+   popq   %rdi
+   popq   %rdi
+   call   _exit		  { if user redefined exit, call _exit }
+   hlt
+end;
+
+(*
+/*
+ * The following is here in case any object module compiled with cc -p
+ *	was linked into this module.
+ */
+	.globl	_mcount
+	.section	.text
+	.align	8
+	.type	_mcount,@function
+_mcount:
+	ret
+	.size	_mcount, .-_mcount
+*)

+ 1 - 1
tests/webtbs/tw9089c.pp

@@ -9,7 +9,7 @@ const
 {$if defined(windows) or defined(mswindows)}
   libname='tw9089b.dll';
 {$else}
-  libname='tw9089a';
+  libname='tw9089b';
   {$linklib tw9089b}
 {$ifend}
 

+ 36 - 35
utils/fpcm/fpcmmain.pp

@@ -63,7 +63,7 @@ interface
 
     type
       TCpu=(
-        c_i386,c_m68k,c_powerpc,c_sparc,c_x86_64,c_arm,c_powerpc64,c_avr,c_armeb
+        c_i386,c_m68k,c_powerpc,c_sparc,c_x86_64,c_arm,c_powerpc64,c_avr,c_armeb,c_armel,c_mips,c_mipsel,c_mips64,c_mips64el
       );
 
       TOS=(
@@ -77,15 +77,15 @@ interface
 
     const
       CpuStr : array[TCpu] of string=(
-        'i386','m68k','powerpc','sparc','x86_64','arm','powerpc64','avr','armeb'
+        'i386','m68k','powerpc','sparc','x86_64','arm','powerpc64','avr','armeb', 'armel', 'mips', 'mipsel', 'mips64', 'mips64el'
       );
 
       CpuSuffix : array[TCpu] of string=(
-        '_i386','_m68k','_powerpc','_sparc','_x86_64','_arm','_powerpc64','avr','_armeb'
+        '_i386','_m68k','_powerpc','_sparc','_x86_64','_arm','_powerpc64','avr','_armeb', '_armel', '_mips', '_mipsel', '_mips64', '_mips64el'
       );
 
       ppcSuffix : array[TCpu] of string=(
-        '386','m68k','ppc','sparc','x86_64','arm','ppc64','avr','armeb'
+        '386','m68k','ppc','sparc','x86_64','arm','ppc64','avr','armeb', 'armel', 'mips', 'mipsel', 'mips64', 'mips64el'
       );
 
       OSStr : array[TOS] of string=(
@@ -104,35 +104,35 @@ interface
 
       { This table is kept OS,Cpu because it is easier to maintain (PFV) }
       OSCpuPossible : array[TOS,TCpu] of boolean = (
-        { os          i386    m68k  ppc    sparc  x86_64 arm    ppc64  avr    armeb}
-        { linux }   ( true,  true,  true,  true,  true,  true,  true,  false, true ),
-        { go32v2 }  ( true,  false, false, false, false, false, false, false, false),
-        { win32 }   ( true,  false, false, false, false, false, false, false, false),
-        { os2 }     ( true,  false, false, false, false, false, false, false, false),
-        { freebsd } ( true,  true,  false, false, true,  false, false, false, false),
-        { beos }    ( true,  false, false, false, false, false, false, false, false),
-        { haiku }    ( true,  false, false, false, false, false, false, false, false),
-        { netbsd }  ( true,  true,  true,  true,  false, false, false, false, false),
-        { amiga }   ( false, true,  true,  false, false, false, false, false, false),
-        { atari }   ( false, true,  false, false, false, false, false, false, false),
-        { solaris } ( true,  false, false, true,  false, false, false, false, false),
-        { qnx }     ( true,  false, false, false, false, false, false, false, false),
-        { netware } ( true,  false, false, false, false, false, false, false, false),
-        { openbsd } ( true,  true,  false, false, false, false, false, false, false),
-        { wdosx }   ( true,  false, false, false, false, false, false, false, false),
-        { palmos }  ( false, true,  false, false, false, true,  false, false, false),
-        { macos }   ( false, false, true,  false, false, false, false, false, false),
-        { darwin }  ( true,  false, true,  false, true,  true,  true,  false, false),
-        { emx }     ( true,  false, false, false, false, false, false, false, false),
-        { watcom }  ( true,  false, false, false ,false, false, false, false, false),
-        { morphos } ( false, false, true,  false ,false, false, false, false, false),
-        { netwlibc }( true,  false, false, false, false, false, false, false, false),
-        { win64   } ( false, false, false, false, true,  false, false, false, false),
-        { wince    }( true,  false, false, false, false, true,  false, false, false),
-        { gba    }  ( false, false, false, false, false, true,  false, false, false),
-        { nds    }  ( false, false, false, false, false, true,  false, false, false),
-        { embedded }( true,  true,  true,  true,  true,  true,  true,  true,  true ),
-        { symbian } ( true,  false, false, false, false, true,  false, false, false)
+        { os          i386    m68k  ppc    sparc  x86_64 arm    ppc64  avr    armeb  armel  mips   mipsel mips64 misp64el}
+        { linux }   ( true,  true,  true,  true,  true,  true,  true,  false, true,  false, false, true,  false, false),
+        { go32v2 }  ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { win32 }   ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { os2 }     ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { freebsd } ( true,  true,  false, false, true,  false, false, false, false, false, false, false, false, false),
+        { beos }    ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { haiku }   ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { netbsd }  ( true,  true,  true,  true,  false, false, false, false, false, false, false, false, false, false),
+        { amiga }   ( false, true,  true,  false, false, false, false, false, false, false, false, false, false, false),
+        { atari }   ( false, true,  false, false, false, false, false, false, false, false, false, false, false, false),
+        { solaris } ( true,  false, false, true,  true,  false, false, false, false, false, false, false, false, false),
+        { qnx }     ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { netware } ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { openbsd } ( true,  true,  false, false, false, false, false, false, false, false, false, false, false, false),
+        { wdosx }   ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { palmos }  ( false, true,  false, false, false, true,  false, false, false, false, false, false, false, false),
+        { macos }   ( false, false, true,  false, false, false, false, false, false, false, false, false, false, false),
+        { darwin }  ( true,  false, true,  false, true,  true,  true,  false, false, false, false, false, false, false),
+        { emx }     ( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { watcom }  ( true,  false, false, false ,false, false, false, false, false, false, false, false, false, false),
+        { morphos } ( false, false, true,  false ,false, false, false, false, false, false, false, false, false, false),
+        { netwlibc }( true,  false, false, false, false, false, false, false, false, false, false, false, false, false),
+        { win64   } ( false, false, false, false, true,  false, false, false, false, false, false, false, false, false),
+        { wince    }( true,  false, false, false, false, true,  false, false, false, false, false, false, false, false),
+        { gba    }  ( false, false, false, false, false, true,  false, false, false, false, false, false, false, false),
+        { nds    }  ( false, false, false, false, false, true,  false, false, false, false, false, false, false, false),
+        { embedded }( true,  true,  true,  true,  true,  true,  true,  true,  true , false, false, false, false, false),
+        { symbian } ( true,  false, false, false, false, true,  false, false, false, false, false, false, false, false)
       );
 
     type
@@ -714,8 +714,10 @@ implementation
 
 
     procedure TFPCMake.LoadMakefileFPC;
+{$ifdef SupportLCL}
       var
         s : string;
+{$endif SupportLCL}
       begin
         LoadSections;
         { Parse all sections }
@@ -835,8 +837,7 @@ implementation
 
     procedure TFPCMake.LoadPackageSection;
       var
-        hs,s : string;
-        t : TOS;
+        s : string;
       begin
         { Get package info from package section }
         FPackageSec:=TFPCMakeSection(FSections['package']);