~ubuntu-branches/ubuntu/raring/babel/raring-proposed

« back to all changes in this revision

Viewing changes to regression/ordering/runJava/sidl_Loader_jniStub.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2008-08-01 07:56:58 UTC
  • mfrom: (3.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080801075658-9ezcrbh8dcs8lg70
Tags: 1.2.0.dfsg-6
Added libparsifal-dev as dependency to libsidl-dev (closes: #483324).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * File:          sidl_Loader_jniStub.c
3
 
 * Symbol:        sidl.Loader-v0.9.1
4
 
 * Symbol Type:   class
5
 
 * Babel Version: 0.10.2
6
 
 * Release:       $Name:  $
7
 
 * Revision:      @(#) $Id: $
8
 
 * Description:   Client-side JNI glue code for sidl.Loader
9
 
 * 
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.
14
 
 * 
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
18
 
 * License.
19
 
 * 
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.
23
 
 * 
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.
28
 
 * 
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
32
 
 * 
33
 
 * WARNING: Automatically generated; changes will be lost
34
 
 * 
35
 
 * babel-version = 0.10.2
36
 
 */
37
 
 
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"
43
 
 
44
 
/*
45
 
 * Convert between jlong and void* pointers.
46
 
 */
47
 
 
48
 
#if (SIZEOF_VOID_P == 8)
49
 
#define JLONG_TO_POINTER(x) ((void*)(x))
50
 
#define POINTER_TO_JLONG(x) ((jlong)(x))
51
 
#else
52
 
#define JLONG_TO_POINTER(x) ((void*)(int32_t)(x))
53
 
#define POINTER_TO_JLONG(x) ((jlong)(int32_t)(x))
54
 
#endif
55
 
 
56
 
#ifndef NULL
57
 
#define NULL 0
58
 
#endif
59
 
 
60
 
/*
61
 
 * External reference to IOR methods.
62
 
 */
63
 
 
64
 
static const struct sidl_Loader__external* s_external = NULL;
65
 
 
66
 
/*
67
 
 * External reference to static EPV.
68
 
 */
69
 
 
70
 
static const struct sidl_Loader__sepv* s_sepv = NULL;
71
 
 
72
 
/*
73
 
 * Create object instance and return reference.
74
 
 */
75
 
 
76
 
static jlong jni__create_ior(
77
 
  JNIEnv* env,
78
 
  jclass  cls)
79
 
{
80
 
  (void) env;
81
 
  (void) cls;
82
 
  return POINTER_TO_JLONG((*s_external->createObject)());
83
 
}
84
 
 
85
 
/*
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.
89
 
 * 
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
94
 
 *                     OS)
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
101
 
 *                     here.
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
105
 
 *                     now.
106
 
 * @return if the load was successful, a non-NULL DLL object is returned.
107
 
 */
108
 
 
109
 
static jobject
110
 
jni_loadLibrary(
111
 
  JNIEnv* env,
112
 
  jclass  cls,
113
 
  jstring _arg_uri,
114
 
  jboolean _arg_loadGlobally,
115
 
  jboolean _arg_loadLazy)
116
 
{
117
 
  /*
118
 
   * Declare return and temporary variables.
119
 
   */
120
 
 
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;
126
 
 
127
 
  /*
128
 
   * Preprocess Java types and convert into IOR.
129
 
   */
130
 
 
131
 
  _tmp_uri = sidl_Java_J2I_string(env, _arg_uri);
132
 
  _tmp_loadGlobally = (sidl_bool) _arg_loadGlobally;
133
 
  _tmp_loadLazy = (sidl_bool) _arg_loadLazy;
134
 
 
135
 
  /*
136
 
   * Call the IOR method through the EPV.
137
 
   */
138
 
 
139
 
  _ior_res = (*(s_sepv->f_loadLibrary))(
140
 
    _tmp_uri,
141
 
    _tmp_loadGlobally,
142
 
    _tmp_loadLazy);
143
 
 
144
 
  /*
145
 
   * Postprocess OUT, INOUT, returns, and exceptions.
146
 
   */
147
 
 
148
 
  sidl_String_free(_tmp_uri);
149
 
  _res = sidl_Java_I2J_cls(env, _ior_res, "sidl.DLL");
150
 
 
151
 
  return _res;
152
 
}
153
 
 
154
 
/*
155
 
 * Append the specified DLL to the beginning of the list of already
156
 
 * loaded DLLs.
157
 
 */
158
 
 
159
 
static void
160
 
jni_addDLL(
161
 
  JNIEnv* env,
162
 
  jclass  cls,
163
 
  jobject _arg_dll)
164
 
{
165
 
  /*
166
 
   * Declare return and temporary variables.
167
 
   */
168
 
 
169
 
  struct sidl_DLL__object* _tmp_dll = (struct sidl_DLL__object*) NULL;
170
 
 
171
 
  /*
172
 
   * Preprocess Java types and convert into IOR.
173
 
   */
174
 
 
175
 
  _tmp_dll = (struct sidl_DLL__object*) sidl_Java_J2I_cls(env, _arg_dll);
176
 
 
177
 
  /*
178
 
   * Call the IOR method through the EPV.
179
 
   */
180
 
 
181
 
  (*(s_sepv->f_addDLL))(
182
 
    _tmp_dll);
183
 
 
184
 
  /*
185
 
   * Postprocess OUT, INOUT, returns, and exceptions.
186
 
   */
187
 
 
188
 
}
189
 
 
190
 
/*
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
194
 
 * system.
195
 
 */
196
 
 
197
 
static void
198
 
jni_unloadLibraries(
199
 
  JNIEnv* env,
200
 
  jclass  cls)
201
 
{
202
 
  /*
203
 
   * Declare return and temporary variables.
204
 
   */
205
 
 
206
 
 
207
 
  /*
208
 
   * Preprocess Java types and convert into IOR.
209
 
   */
210
 
 
211
 
 
212
 
  /*
213
 
   * Call the IOR method through the EPV.
214
 
   */
215
 
 
216
 
  (*(s_sepv->f_unloadLibraries))();
217
 
 
218
 
  /*
219
 
   * Postprocess OUT, INOUT, returns, and exceptions.
220
 
   */
221
 
 
222
 
}
223
 
 
224
 
/*
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.
229
 
 * 
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.
234
 
 * 
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.
253
 
 */
254
 
 
255
 
static jobject
256
 
jni_findLibrary(
257
 
  JNIEnv* env,
258
 
  jclass  cls,
259
 
  jstring _arg_sidl_name,
260
 
  jstring _arg_target,
261
 
  jint _arg_lScope,
262
 
  jint _arg_lResolve)
263
 
{
264
 
  /*
265
 
   * Declare return and temporary variables.
266
 
   */
267
 
 
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;
274
 
 
275
 
  /*
276
 
   * Preprocess Java types and convert into IOR.
277
 
   */
278
 
 
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;
283
 
 
284
 
  /*
285
 
   * Call the IOR method through the EPV.
286
 
   */
287
 
 
288
 
  _ior_res = (*(s_sepv->f_findLibrary))(
289
 
    _tmp_sidl_name,
290
 
    _tmp_target,
291
 
    _tmp_lScope,
292
 
    _tmp_lResolve);
293
 
 
294
 
  /*
295
 
   * Postprocess OUT, INOUT, returns, and exceptions.
296
 
   */
297
 
 
298
 
  sidl_String_free(_tmp_sidl_name);
299
 
  sidl_String_free(_tmp_target);
300
 
  _res = sidl_Java_I2J_cls(env, _ior_res, "sidl.DLL");
301
 
 
302
 
  return _res;
303
 
}
304
 
 
305
 
/*
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.
309
 
 * 
310
 
 * This updates the search path in the current <code>Finder</code>.
311
 
 */
312
 
 
313
 
static void
314
 
jni_setSearchPath(
315
 
  JNIEnv* env,
316
 
  jclass  cls,
317
 
  jstring _arg_path_name)
318
 
{
319
 
  /*
320
 
   * Declare return and temporary variables.
321
 
   */
322
 
 
323
 
  char* _tmp_path_name = (char*) NULL;
324
 
 
325
 
  /*
326
 
   * Preprocess Java types and convert into IOR.
327
 
   */
328
 
 
329
 
  _tmp_path_name = sidl_Java_J2I_string(env, _arg_path_name);
330
 
 
331
 
  /*
332
 
   * Call the IOR method through the EPV.
333
 
   */
334
 
 
335
 
  (*(s_sepv->f_setSearchPath))(
336
 
    _tmp_path_name);
337
 
 
338
 
  /*
339
 
   * Postprocess OUT, INOUT, returns, and exceptions.
340
 
   */
341
 
 
342
 
  sidl_String_free(_tmp_path_name);
343
 
}
344
 
 
345
 
/*
346
 
 * Return the current search path.  The default
347
 
 * <code>Finder</code> initializes the search path
348
 
 * from environment variable SIDL_DLL_PATH.
349
 
 * 
350
 
 */
351
 
 
352
 
static jstring
353
 
jni_getSearchPath(
354
 
  JNIEnv* env,
355
 
  jclass  cls)
356
 
{
357
 
  /*
358
 
   * Declare return and temporary variables.
359
 
   */
360
 
 
361
 
  char* _ior_res = (char*) NULL;
362
 
  jstring _res = (jstring) NULL;
363
 
 
364
 
  /*
365
 
   * Preprocess Java types and convert into IOR.
366
 
   */
367
 
 
368
 
 
369
 
  /*
370
 
   * Call the IOR method through the EPV.
371
 
   */
372
 
 
373
 
  _ior_res = (*(s_sepv->f_getSearchPath))();
374
 
 
375
 
  /*
376
 
   * Postprocess OUT, INOUT, returns, and exceptions.
377
 
   */
378
 
 
379
 
  _res = sidl_Java_I2J_string(env, _ior_res);
380
 
  sidl_String_free(_ior_res);
381
 
 
382
 
  return _res;
383
 
}
384
 
 
385
 
/*
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.
391
 
 */
392
 
 
393
 
static void
394
 
jni_addSearchPath(
395
 
  JNIEnv* env,
396
 
  jclass  cls,
397
 
  jstring _arg_path_fragment)
398
 
{
399
 
  /*
400
 
   * Declare return and temporary variables.
401
 
   */
402
 
 
403
 
  char* _tmp_path_fragment = (char*) NULL;
404
 
 
405
 
  /*
406
 
   * Preprocess Java types and convert into IOR.
407
 
   */
408
 
 
409
 
  _tmp_path_fragment = sidl_Java_J2I_string(env, _arg_path_fragment);
410
 
 
411
 
  /*
412
 
   * Call the IOR method through the EPV.
413
 
   */
414
 
 
415
 
  (*(s_sepv->f_addSearchPath))(
416
 
    _tmp_path_fragment);
417
 
 
418
 
  /*
419
 
   * Postprocess OUT, INOUT, returns, and exceptions.
420
 
   */
421
 
 
422
 
  sidl_String_free(_tmp_path_fragment);
423
 
}
424
 
 
425
 
/*
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.
430
 
 * 
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.
435
 
 */
436
 
 
437
 
static void
438
 
jni_setFinder(
439
 
  JNIEnv* env,
440
 
  jclass  cls,
441
 
  jobject _arg_f)
442
 
{
443
 
  /*
444
 
   * Declare return and temporary variables.
445
 
   */
446
 
 
447
 
  struct sidl_Finder__object* _tmp_f = (struct sidl_Finder__object*) NULL;
448
 
 
449
 
  /*
450
 
   * Preprocess Java types and convert into IOR.
451
 
   */
452
 
 
453
 
  _tmp_f = (struct sidl_Finder__object*) sidl_Java_J2I_ifc(env, _arg_f,
454
 
    "sidl.Finder");
455
 
 
456
 
  /*
457
 
   * Call the IOR method through the EPV.
458
 
   */
459
 
 
460
 
  (*(s_sepv->f_setFinder))(
461
 
    _tmp_f);
462
 
 
463
 
  /*
464
 
   * Postprocess OUT, INOUT, returns, and exceptions.
465
 
   */
466
 
 
467
 
}
468
 
 
469
 
/*
470
 
 * This method gets the <code>Finder</code> that <code>Loader</code>
471
 
 * uses to find DLLs.  
472
 
 */
473
 
 
474
 
static jobject
475
 
jni_getFinder(
476
 
  JNIEnv* env,
477
 
  jclass  cls)
478
 
{
479
 
  /*
480
 
   * Declare return and temporary variables.
481
 
   */
482
 
 
483
 
  struct sidl_Finder__object* _ior_res = (struct sidl_Finder__object*) NULL;
484
 
  jobject _res = (jobject) NULL;
485
 
 
486
 
  /*
487
 
   * Preprocess Java types and convert into IOR.
488
 
   */
489
 
 
490
 
 
491
 
  /*
492
 
   * Call the IOR method through the EPV.
493
 
   */
494
 
 
495
 
  _ior_res = (*(s_sepv->f_getFinder))();
496
 
 
497
 
  /*
498
 
   * Postprocess OUT, INOUT, returns, and exceptions.
499
 
   */
500
 
 
501
 
  _res = sidl_Java_I2J_ifc(env, _ior_res, "sidl.Finder");
502
 
 
503
 
  return _res;
504
 
}
505
 
 
506
 
/*
507
 
 * Register JNI methods with the Java JVM.
508
 
 */
509
 
 
510
 
void sidl_Loader__register(JNIEnv* env)
511
 
{
512
 
  JNINativeMethod methods[10];
513
 
  jclass cls;
514
 
 
515
 
  s_external = sidl_Loader__externals();
516
 
  s_sepv = (*(s_external->getStaticEPV))();
517
 
 
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;
548
 
 
549
 
 
550
 
  cls = (*env)->FindClass(env, "sidl/Loader");
551
 
  if (cls) {
552
 
    (*env)->RegisterNatives(env, cls, methods, 10);
553
 
    (*env)->DeleteLocalRef(env, cls);
554
 
  }
555
 
}