SaxonC 13.0.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
SaxonCGlue.h
Go to the documentation of this file.
1
2// Copyright (c) 2022 - 2023 Saxonica Limited.
3// This Source Code Form is subject to the terms of the Mozilla Public License,
4// v. 2.0. If a copy of the MPL was not distributed with this file, You can
5// obtain one at http://mozilla.org/MPL/2.0/. This Source Code Form is
6// "Incompatible With Secondary Licenses", as defined by the Mozilla Public
7// License, v. 2.0.
9
10#ifndef SAXONCGLUE2_H
11#define SAXONCGLUE2_H
12
13#include "saxonc_export.h"
14#include "saxon_error.h"
15#include <saxonc/saxonc-core.h>
16
17#include <stdint.h>
18#include <stdio.h>
19#if defined __linux__ || defined __APPLE__
20#include <stdlib.h>
21#include <string.h>
22#else
23#include <windows.h>
24#endif
25
26#ifdef __cplusplus
27#define EXTERN_SAXONC extern "C" {
28#define EXTERN_SAXONC_END }
29#else
30#define EXTERN_SAXONC
31#define EXTERN_SAXONC_END
32
33#endif
34
35#ifndef __cplusplus
36#ifndef _BOOL
37#include <stdbool.h>
38/*typedef unsigned char sxn_bool;
39static const sxn_bool sxn_false = 0;
40static const sxn_bool sxn_true = 1;*/
41
42#else
43// typedef bool sxn_bool;
44static const bool false = 0;
45static const bool true = 1;
46#endif
47#endif
48
49#ifndef __cplusplus
50#if defined(LICENSE)
51#define sxn_license 1
52#else
53#define sxn_license 0
54#endif
55#endif
56
57static const int SXN_EXCEPTION = -2;
58static const int SXN_UNSET = -1;
59static const int SXN_PHP = 1;
60static const int SXN_PYTHON = 2;
61static const int SXN_CPP = 0;
62
67
68//#define DEBUG
69
70EXTERN_SAXONC
71
72extern char *dllname;
73static const saxon_error_t SAXON_ERROR_DEFAULT = {SAXON_OK, NULL, NULL, NULL, -1, 0};
74
75extern char *resources_dir;
76
77// Static variable used to track when jvm has been created. Used to prevent
78// creation more than once.
79extern int jvmCreated; // TODO this might not be required in graalvm - remove
80
81//===============================================================================================//
85typedef struct {
86 graal_isolate_t *isolate;
87 graal_isolatethread_t *thread;
88 graal_isolatethread_t *mainthread;
90
91//===============================================================================================//
92
97typedef struct {
98 char *name;
99 int64_t value;
102
103
104
105//===============================================================================================//
106
111typedef struct {
112 char *name;
113 char *value;
116
120typedef struct {
121 int64_t xdmvalue;
122} sxnc_value;
123
127typedef struct {
128 int64_t value;
130
131extern int64_t cpp;
132
133typedef void *(*allocFn)(size_t length);
134//c_nativeCall(char * functionName, void * proc, void * func, int useNativeTypes, int numOfArguments, void ** arguments)
135typedef void * (*nativeFn)(void * t, char * functionName, void * proc, void * pythonFunc, void * func, int php, int useNativeTypes, int numOfArguments, void ** arguments);
136typedef void * (*nativePHPFn)(char * functionName, void * proc, void * func, int useNativeTypes, int numOfArguments, void ** arguments);
137typedef void * (*nativePythonFn)(void * proc, void * func, int useNativeTypes, int numOfArguments, void ** arguments);
138
139extern const char *failure;
140
144
145char *_getResourceDirectory(void);
146
151SAXONC_EXPORT int create_graalvm_isolate(sxnc_environment *env);
152
156SAXONC_EXPORT int attach_graalvm_thread(sxnc_environment *env);
157
161SAXONC_EXPORT graal_isolatethread_t* get_or_attach_thread(sxnc_environment *env);
162
166SAXONC_EXPORT int detach_graalvm_thread(sxnc_environment *env);
167
175SAXONC_EXPORT int64_t createSaxonProcessor2(graal_isolatethread_t *thread, int license);
176
182SAXONC_EXPORT int c_createSaxonProcessor(sxnc_environment *environi,
183 sxnc_processor *processor, int license);
184
189SAXONC_EXPORT const char *checkForException(sxnc_environment *environi);
190
194SAXONC_EXPORT void graal_tear_down(graal_isolatethread_t *thread);
195
199SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name);
200
204SAXONC_EXPORT char *getProperty(sxnc_property *properties, int propLen, const char *name);
205
209SAXONC_EXPORT void setParameter(sxnc_parameter **parameters, int *parLen, int *parCap,
210 const char *name, sxnc_value *value);
211
215SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap,
216 const char *name, const char *value);
217
221SAXONC_EXPORT void clearSettings(sxnc_parameter **parameters, int *parLen,
222 sxnc_property **properties, int *propLen);
223
224EXTERN_SAXONC_END
225
226#endif // SAXONCGLUE_H
SAXONC_EXPORT void setParameter(sxnc_parameter **parameters, int *parLen, int *parCap, const char *name, sxnc_value *value)
Set a parameter.
Definition SaxonCGlue.c:202
SAXONC_EXPORT int c_createSaxonProcessor(sxnc_environment *environi, sxnc_processor *processor, int license)
Create a pointer to the Saxon Processor.
Definition SaxonCGlue.c:145
SAXONC_EXPORT int64_t createSaxonProcessor2(graal_isolatethread_t *thread, int license)
Create and return the ObjectHandle for a Saxon Processor.
Definition SaxonCGlue.c:141
SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name)
Get a parameter from the list.
Definition SaxonCGlue.c:178
SAXONC_EXPORT int create_graalvm_isolate(sxnc_environment *env)
Load dll using the default setting in SaxonC.
Definition SaxonCGlue.c:45
char * _getResourceDirectory(void)
Get resources directory.
Definition SaxonCGlue.c:27
SAXONC_EXPORT int attach_graalvm_thread(sxnc_environment *env)
Attach to the current thread in the loaded GraalVM isolate.
Definition SaxonCGlue.c:74
SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap, const char *name, const char *value)
Set a property.
Definition SaxonCGlue.c:228
SAXONC_EXPORT graal_isolatethread_t * get_or_attach_thread(sxnc_environment *env)
Get or attach to the current thread in the loaded GraalVM isolate.
Definition SaxonCGlue.c:57
SAXONC_EXPORT void graal_tear_down(graal_isolatethread_t *thread)
Clean up and destroy GraalVM to release memory used.
Definition SaxonCGlue.c:167
SAXONC_EXPORT int detach_graalvm_thread(sxnc_environment *env)
Closes down the GraalVM environment used by SaxonC.
Definition SaxonCGlue.c:101
SAXONC_EXPORT char * getProperty(sxnc_property *properties, int propLen, const char *name)
Get a property from the list.
Definition SaxonCGlue.c:190
SAXONC_EXPORT const char * checkForException(sxnc_environment *environi)
Callback to check for exceptions.
Definition SaxonCGlue.c:162
SAXONC_EXPORT void clearSettings(sxnc_parameter **parameters, int *parLen, sxnc_property **properties, int *propLen)
Clear parameters and properties.
Definition SaxonCGlue.c:257
sxnc_environment.
Definition SaxonCGlue.h:85
graal_isolatethread_t * thread
pointer to the current GraalVM isolate thread
Definition SaxonCGlue.h:87
graal_isolate_t * isolate
Structure representing a GraalVM isolate.
Definition SaxonCGlue.h:86
graal_isolatethread_t * mainthread
pointer to the main GraalVM isolate thread
Definition SaxonCGlue.h:88
sxnc_parameter.
Definition SaxonCGlue.h:97
char * name
The parameter name.
Definition SaxonCGlue.h:98
int64_t value
Definition SaxonCGlue.h:99
!
Definition SaxonCGlue.h:127
int64_t value
The ObjectHandle of the processor object.
Definition SaxonCGlue.h:128
sxnc_property.
Definition SaxonCGlue.h:111
char * value
Definition SaxonCGlue.h:113
char * name
The property name.
Definition SaxonCGlue.h:112
!
Definition SaxonCGlue.h:120
int64_t xdmvalue
Definition SaxonCGlue.h:121