SaxonC 12.7.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 <saxonc/saxonc-core.h>
15
16#include <stdint.h>
17#include <stdio.h>
18#if defined __linux__ || defined __APPLE__
19#include <stdlib.h>
20#include <string.h>
21#else
22#include <windows.h>
23#endif
24
25#ifdef __cplusplus
26#define EXTERN_SAXONC extern "C" {
27#define EXTERN_SAXONC_END }
28#else
29#define EXTERN_SAXONC
30#define EXTERN_SAXONC_END
31
32#endif
33
34#ifndef __cplusplus
35#ifndef _BOOL
36#include <stdbool.h>
37/*typedef unsigned char sxn_bool;
38static const sxn_bool sxn_false = 0;
39static const sxn_bool sxn_true = 1;*/
40
41#else
42// typedef bool sxn_bool;
43static const bool false = 0;
44static const bool true = 1;
45#endif
46#endif
47
48#ifndef __cplusplus
49#if defined(LICENSE)
50#define sxn_license 1
51#else
52#define sxn_license 0
53#endif
54#endif
55
56static const int SXN_EXCEPTION = -2;
57static const int SXN_UNSET = -1;
58
64//#define DEBUG
65
66EXTERN_SAXONC
67
68extern char *dllname;
69
70extern char *resources_dir;
71
72// Static variable used to track when jvm has been created. Used to prevent
73// creation more than once.
74extern int jvmCreated; // TODO this might not be required in graalvm - remove
75
76//===============================================================================================//
80typedef struct {
81 graal_isolate_t *isolate;
82 graal_isolatethread_t *thread;
83 graal_isolatethread_t *mainthread;
85
86//===============================================================================================//
87
92typedef struct {
93 char *name;
94 int64_t value;
98
99//===============================================================================================//
100
105typedef struct {
106 char *name;
107 char *value;
110
114typedef struct {
115 int64_t xdmvalue;
116} sxnc_value;
117
121typedef struct {
122 int64_t value;
124
125extern int64_t cpp;
126
127typedef void *(*allocFn)(size_t length);
128
129extern const char *failure;
130
135char *_getResourceDirectory(void);
136
141SAXONC_EXPORT int create_graalvm_isolate(sxnc_environment *env);
142
146SAXONC_EXPORT int attach_graalvm_thread(sxnc_environment *env);
147
151SAXONC_EXPORT int detach_graalvm_thread(sxnc_environment *env);
152
160SAXONC_EXPORT int64_t createSaxonProcessor2(graal_isolatethread_t *thread, int license);
161
167SAXONC_EXPORT int c_createSaxonProcessor(sxnc_environment *environi,
168 sxnc_processor *processor, int license);
169
174SAXONC_EXPORT const char *checkForException(sxnc_environment *environi);
175
179SAXONC_EXPORT void graal_tear_down(graal_isolatethread_t *thread);
180
184SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name);
185
189SAXONC_EXPORT char *getProperty(sxnc_property *properties, int propLen, const char *name);
190
194SAXONC_EXPORT void setParameter(sxnc_parameter **parameters, int *parLen, int *parCap,
195 const char *name, sxnc_value *value);
196
200SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap,
201 const char *name, const char *value);
202
206SAXONC_EXPORT void clearSettings(sxnc_parameter **parameters, int *parLen,
207 sxnc_property **properties, int *propLen);
208
209EXTERN_SAXONC_END
210
211#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:160
SAXONC_EXPORT int c_createSaxonProcessor(sxnc_environment *environi, sxnc_processor *processor, int license)
Create a pointer to the Saxon Processor.
Definition SaxonCGlue.c:103
SAXONC_EXPORT int64_t createSaxonProcessor2(graal_isolatethread_t *thread, int license)
Create and return the ObjectHandle for a Saxon Processor.
Definition SaxonCGlue.c:99
SAXONC_EXPORT int64_t getParameter(sxnc_parameter *parameters, int parLen, const char *name)
Get a parameter from the list.
Definition SaxonCGlue.c:136
SAXONC_EXPORT int create_graalvm_isolate(sxnc_environment *env)
Load dll using the default setting in SaxonC.
Definition SaxonCGlue.c:31
char * _getResourceDirectory(void)
Get resources directory.
Definition SaxonCGlue.c:26
SAXONC_EXPORT int attach_graalvm_thread(sxnc_environment *env)
Attach to the current thread in the loaded GraalVM isolate.
Definition SaxonCGlue.c:46
SAXONC_EXPORT void setProperty(sxnc_property **properties, int *propLen, int *propCap, const char *name, const char *value)
Set a property.
Definition SaxonCGlue.c:186
SAXONC_EXPORT void graal_tear_down(graal_isolatethread_t *thread)
Clean up and destroy GraalVM to release memory used.
Definition SaxonCGlue.c:125
SAXONC_EXPORT int detach_graalvm_thread(sxnc_environment *env)
Closes down the GraalVM environment used by SaxonC.
Definition SaxonCGlue.c:66
SAXONC_EXPORT char * getProperty(sxnc_property *properties, int propLen, const char *name)
Get a property from the list.
Definition SaxonCGlue.c:148
SAXONC_EXPORT const char * checkForException(sxnc_environment *environi)
Callback to check for exceptions.
Definition SaxonCGlue.c:120
SAXONC_EXPORT void clearSettings(sxnc_parameter **parameters, int *parLen, sxnc_property **properties, int *propLen)
Clear parameters and properties.
Definition SaxonCGlue.c:215
sxnc_environment.
Definition SaxonCGlue.h:80
graal_isolatethread_t * thread
pointer to the current GraalVM isolate thread
Definition SaxonCGlue.h:82
graal_isolate_t * isolate
Structure representing a GraalVM isolate.
Definition SaxonCGlue.h:81
graal_isolatethread_t * mainthread
pointer to the main GraalVM isolate thread
Definition SaxonCGlue.h:83
sxnc_parameter.
Definition SaxonCGlue.h:92
char * name
The parameter name.
Definition SaxonCGlue.h:93
int64_t value
Definition SaxonCGlue.h:94
! sxnc_processor.
Definition SaxonCGlue.h:121
int64_t value
The ObjectHandle of the processor object.
Definition SaxonCGlue.h:122
sxnc_property.
Definition SaxonCGlue.h:105
char * value
Definition SaxonCGlue.h:107
char * name
The property name.
Definition SaxonCGlue.h:106
! sxnc_value.
Definition SaxonCGlue.h:114
int64_t xdmvalue
Definition SaxonCGlue.h:115