2
* File: sidl_Loader_jniStub.c
3
* Symbol: sidl.Loader-v0.9.1
5
* Babel Version: 0.10.2
7
* Revision: @(#) $Id: $
8
* Description: Client-side JNI glue code for sidl.Loader
10
* Copyright (c) 2000-2002, The Regents of the University of California.
11
* Produced at the Lawrence Livermore National Laboratory.
12
* Written by the Components Team <components@llnl.gov>
13
* All rights reserved.
15
* This file is part of Babel. For more information, see
16
* http://www.llnl.gov/CASC/components/. Please read the COPYRIGHT file
17
* for Our Notice and the LICENSE file for the GNU Lesser General Public
20
* This program is free software; you can redistribute it and/or modify it
21
* under the terms of the GNU Lesser General Public License (as published by
22
* the Free Software Foundation) version 2.1 dated February 1999.
24
* This program is distributed in the hope that it will be useful, but
25
* WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
27
* conditions of the GNU Lesser General Public License for more details.
29
* You should have recieved a copy of the GNU Lesser General Public License
30
* along with this program; if not, write to the Free Software Foundation,
31
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33
* WARNING: Automatically generated; changes will be lost
35
* babel-version = 0.10.2
38
#include "sidl_Java.h"
39
#include "sidl_Loader.h"
40
#include "sidl_String.h"
41
#include "sidl_Loader_IOR.h"
42
#include "babel_config.h"
45
* Convert between jlong and void* pointers.
48
#if (SIZEOF_VOID_P == 8)
49
#define JLONG_TO_POINTER(x) ((void*)(x))
50
#define POINTER_TO_JLONG(x) ((jlong)(x))
52
#define JLONG_TO_POINTER(x) ((void*)(int32_t)(x))
53
#define POINTER_TO_JLONG(x) ((jlong)(int32_t)(x))
61
* External reference to IOR methods.
64
static const struct sidl_Loader__external* s_external = NULL;
67
* External reference to static EPV.
70
static const struct sidl_Loader__sepv* s_sepv = NULL;
73
* Create object instance and return reference.
76
static jlong jni__create_ior(
82
return POINTER_TO_JLONG((*s_external->createObject)());
86
* Load the specified library if it has not already been loaded.
87
* The URI format is defined in class <code>DLL</code>. The search
88
* path is not searched to resolve the library name.
90
* @param uri the URI to load. This can be a .la file
91
* (a metadata file produced by libtool) or
92
* a shared library binary (i.e., .so,
93
* .dll or whatever is appropriate for your
95
* @param loadGlobally <code>true</code> means that the shared
96
* library symbols will be loaded into the
97
* global namespace; <code>false</code>
98
* means they will be loaded into a
99
* private namespace. Some operating systems
100
* may not be able to honor the value presented
102
* @param loadLazy <code>true</code> instructs the loader to
103
* that symbols can be resolved as needed (lazy)
104
* instead of requiring everything to be resolved
106
* @return if the load was successful, a non-NULL DLL object is returned.
114
jboolean _arg_loadGlobally,
115
jboolean _arg_loadLazy)
118
* Declare return and temporary variables.
121
char* _tmp_uri = (char*) NULL;
122
sidl_bool _tmp_loadGlobally = FALSE;
123
sidl_bool _tmp_loadLazy = FALSE;
124
struct sidl_DLL__object* _ior_res = (struct sidl_DLL__object*) NULL;
125
jobject _res = (jobject) NULL;
128
* Preprocess Java types and convert into IOR.
131
_tmp_uri = sidl_Java_J2I_string(env, _arg_uri);
132
_tmp_loadGlobally = (sidl_bool) _arg_loadGlobally;
133
_tmp_loadLazy = (sidl_bool) _arg_loadLazy;
136
* Call the IOR method through the EPV.
139
_ior_res = (*(s_sepv->f_loadLibrary))(
145
* Postprocess OUT, INOUT, returns, and exceptions.
148
sidl_String_free(_tmp_uri);
149
_res = sidl_Java_I2J_cls(env, _ior_res, "sidl.DLL");
155
* Append the specified DLL to the beginning of the list of already
166
* Declare return and temporary variables.
169
struct sidl_DLL__object* _tmp_dll = (struct sidl_DLL__object*) NULL;
172
* Preprocess Java types and convert into IOR.
175
_tmp_dll = (struct sidl_DLL__object*) sidl_Java_J2I_cls(env, _arg_dll);
178
* Call the IOR method through the EPV.
181
(*(s_sepv->f_addDLL))(
185
* Postprocess OUT, INOUT, returns, and exceptions.
191
* Unload all dynamic link libraries. The library may no longer
192
* be used to access symbol names. When the library is actually
193
* unloaded from the memory image depends on details of the operating
203
* Declare return and temporary variables.
208
* Preprocess Java types and convert into IOR.
213
* Call the IOR method through the EPV.
216
(*(s_sepv->f_unloadLibraries))();
219
* Postprocess OUT, INOUT, returns, and exceptions.
225
* Find a DLL containing the specified information for a sidl
226
* class. This method searches SCL files in the search path looking
227
* for a shared library that contains the client-side or IOR
228
* for a particular sidl class.
230
* This call is implemented by calling the current
231
* <code>Finder</code>. The default finder searches the local
232
* file system for <code>.scl</code> files to locate the
233
* target class/interface.
235
* @param sidl_name the fully qualified (long) name of the
236
* class/interface to be found. Package names
237
* are separated by period characters from each
238
* other and the class/interface name.
239
* @param target to find a client-side binding, this is
240
* normally the name of the language.
241
* To find the implementation of a class
242
* in order to make one, you should pass
243
* the string "ior/impl" here.
244
* @param lScope this specifies whether the symbols should
245
* be loaded into the global scope, a local
246
* scope, or use the setting in the SCL file.
247
* @param lResolve this specifies whether symbols should be
248
* resolved as needed (LAZY), completely
249
* resolved at load time (NOW), or use the
250
* setting from the SCL file.
251
* @return a non-NULL object means the search was successful.
252
* The DLL has already been added.
259
jstring _arg_sidl_name,
265
* Declare return and temporary variables.
268
char* _tmp_sidl_name = (char*) NULL;
269
char* _tmp_target = (char*) NULL;
270
enum sidl_Scope__enum _tmp_lScope = (enum sidl_Scope__enum) 0;
271
enum sidl_Resolve__enum _tmp_lResolve = (enum sidl_Resolve__enum) 0;
272
struct sidl_DLL__object* _ior_res = (struct sidl_DLL__object*) NULL;
273
jobject _res = (jobject) NULL;
276
* Preprocess Java types and convert into IOR.
279
_tmp_sidl_name = sidl_Java_J2I_string(env, _arg_sidl_name);
280
_tmp_target = sidl_Java_J2I_string(env, _arg_target);
281
_tmp_lScope = (enum sidl_Scope__enum) _arg_lScope;
282
_tmp_lResolve = (enum sidl_Resolve__enum) _arg_lResolve;
285
* Call the IOR method through the EPV.
288
_ior_res = (*(s_sepv->f_findLibrary))(
295
* Postprocess OUT, INOUT, returns, and exceptions.
298
sidl_String_free(_tmp_sidl_name);
299
sidl_String_free(_tmp_target);
300
_res = sidl_Java_I2J_cls(env, _ior_res, "sidl.DLL");
306
* Set the search path, which is a semi-colon separated sequence of
307
* URIs as described in class <code>DLL</code>. This method will
308
* invalidate any existing search path.
310
* This updates the search path in the current <code>Finder</code>.
317
jstring _arg_path_name)
320
* Declare return and temporary variables.
323
char* _tmp_path_name = (char*) NULL;
326
* Preprocess Java types and convert into IOR.
329
_tmp_path_name = sidl_Java_J2I_string(env, _arg_path_name);
332
* Call the IOR method through the EPV.
335
(*(s_sepv->f_setSearchPath))(
339
* Postprocess OUT, INOUT, returns, and exceptions.
342
sidl_String_free(_tmp_path_name);
346
* Return the current search path. The default
347
* <code>Finder</code> initializes the search path
348
* from environment variable SIDL_DLL_PATH.
358
* Declare return and temporary variables.
361
char* _ior_res = (char*) NULL;
362
jstring _res = (jstring) NULL;
365
* Preprocess Java types and convert into IOR.
370
* Call the IOR method through the EPV.
373
_ior_res = (*(s_sepv->f_getSearchPath))();
376
* Postprocess OUT, INOUT, returns, and exceptions.
379
_res = sidl_Java_I2J_string(env, _ior_res);
380
sidl_String_free(_ior_res);
386
* Append the specified path fragment to the beginning of the
387
* current search path. This method operates on the Loader's
388
* current <code>Finder</code>. This will add a path to the
389
* current search path. Normally, the search path is initialized
390
* from the SIDL_DLL_PATH environment variable.
397
jstring _arg_path_fragment)
400
* Declare return and temporary variables.
403
char* _tmp_path_fragment = (char*) NULL;
406
* Preprocess Java types and convert into IOR.
409
_tmp_path_fragment = sidl_Java_J2I_string(env, _arg_path_fragment);
412
* Call the IOR method through the EPV.
415
(*(s_sepv->f_addSearchPath))(
419
* Postprocess OUT, INOUT, returns, and exceptions.
422
sidl_String_free(_tmp_path_fragment);
426
* This method sets the <code>Finder</code> that
427
* <code>Loader</code> will use to find DLLs. If no
428
* <code>Finder</code> is set or if NULL is passed in, the Default
429
* Finder <code>DFinder</code> will be used.
431
* Future calls to <code>findLibrary</code>,
432
* <code>addSearchPath</code>, <code>getSearchPath</code>, and
433
* <code>setSearchPath</code> are deligated to the
434
* <code>Finder</code> set here.
444
* Declare return and temporary variables.
447
struct sidl_Finder__object* _tmp_f = (struct sidl_Finder__object*) NULL;
450
* Preprocess Java types and convert into IOR.
453
_tmp_f = (struct sidl_Finder__object*) sidl_Java_J2I_ifc(env, _arg_f,
457
* Call the IOR method through the EPV.
460
(*(s_sepv->f_setFinder))(
464
* Postprocess OUT, INOUT, returns, and exceptions.
470
* This method gets the <code>Finder</code> that <code>Loader</code>
480
* Declare return and temporary variables.
483
struct sidl_Finder__object* _ior_res = (struct sidl_Finder__object*) NULL;
484
jobject _res = (jobject) NULL;
487
* Preprocess Java types and convert into IOR.
492
* Call the IOR method through the EPV.
495
_ior_res = (*(s_sepv->f_getFinder))();
498
* Postprocess OUT, INOUT, returns, and exceptions.
501
_res = sidl_Java_I2J_ifc(env, _ior_res, "sidl.Finder");
507
* Register JNI methods with the Java JVM.
510
void sidl_Loader__register(JNIEnv* env)
512
JNINativeMethod methods[10];
515
s_external = sidl_Loader__externals();
516
s_sepv = (*(s_external->getStaticEPV))();
518
methods[0].name = "_create_ior";
519
methods[0].signature = "()J";
520
methods[0].fnPtr = (void *)jni__create_ior;
521
methods[1].name = "loadLibrary";
522
methods[1].signature = "(Ljava/lang/String;ZZ)Lsidl/DLL;";
523
methods[1].fnPtr = (void *)jni_loadLibrary;
524
methods[2].name = "addDLL";
525
methods[2].signature = "(Lsidl/DLL;)V";
526
methods[2].fnPtr = (void *)jni_addDLL;
527
methods[3].name = "unloadLibraries";
528
methods[3].signature = "()V";
529
methods[3].fnPtr = (void *)jni_unloadLibraries;
530
methods[4].name = "findLibrary";
531
methods[4].signature = "(Ljava/lang/String;Ljava/lang/String;II)Lsidl/DLL;";
532
methods[4].fnPtr = (void *)jni_findLibrary;
533
methods[5].name = "setSearchPath";
534
methods[5].signature = "(Ljava/lang/String;)V";
535
methods[5].fnPtr = (void *)jni_setSearchPath;
536
methods[6].name = "getSearchPath";
537
methods[6].signature = "()Ljava/lang/String;";
538
methods[6].fnPtr = (void *)jni_getSearchPath;
539
methods[7].name = "addSearchPath";
540
methods[7].signature = "(Ljava/lang/String;)V";
541
methods[7].fnPtr = (void *)jni_addSearchPath;
542
methods[8].name = "setFinder";
543
methods[8].signature = "(Lsidl/Finder;)V";
544
methods[8].fnPtr = (void *)jni_setFinder;
545
methods[9].name = "getFinder";
546
methods[9].signature = "()Lsidl/Finder;";
547
methods[9].fnPtr = (void *)jni_getFinder;
550
cls = (*env)->FindClass(env, "sidl/Loader");
552
(*env)->RegisterNatives(env, cls, methods, 10);
553
(*env)->DeleteLocalRef(env, cls);