1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771
|
/*
* Copyright (C) 2007-2018 S[&]T, The Netherlands.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
%module codac
%include "typemaps.i"
%include "various.i"
%include "arrays_java.i"
%include "enums.swg"
%javaconst(1);
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef char uint8_t;
typedef short int uint16_t;
typedef int uint32_t;
typedef long long int int64_t;
typedef long long int uint64_t;
%{
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "coda.h"
%}
/*
----------------------------------------------------------------------------------------
- RENAME AND IGNORE -
----------------------------------------------------------------------------------------
*/
/*
Include coda_rename.i. this is a list of %rename directives to
strip the 'coda_' part from the Java declarations. (This is
done because in Java we will already be in the 'coda' package
namespace, so the prefix is redundant.
*/
%include "coda_rename.i"
/*
Rename enums to more Java-like equivalents.
*/
%rename(ArrayOrderingEnum) coda_array_ordering_enum;
%rename(FilefilterStatusEnum) coda_filefilter_status_enum;
%rename(FormatEnum) coda_format_enum;
%rename(NativeTypeEnum) coda_native_type_enum;
%rename(SpecialTypeEnum) coda_special_type_enum;
%rename(TypeClassEnum) coda_type_class_enum;
%rename(ExpressionTypeEnum) coda_expression_type_enum;
/*
Include coda_ignore.i. This is a list of %ignore directives to
stop SWIG from exposing internal constants and #defines at the
Java level. Currently, all #define's starting with 'CODA_' and
'HAVE_' are ignored.
*/
%include "coda_ignore.i"
/*
Declarations not included in coda_ignore.i that nevertheless
should be ignored. these declarations are related to error
reporting, but this is handled through or custom exceptions for
Java.
*/
%ignore coda_errno;
%ignore coda_get_errno;
%ignore coda_set_error;
%ignore coda_errno_to_string;
/*
Functions that are not currently exposed to the Java layer,
because there was not enough time to get them working and/or
they had lower priority. TODO: fix this.
*/
/*
Multiple output values, will probably require some sort of
record class to store properly. Java does not have native (or
even library) support for complex numbers.
*/
%ignore coda_recognize_file;
%ignore cursor_read_complex_double_split;
%ignore cursor_read_complex_double_split_array;
/*
Not yet implemented due to difficulty with callback function.
*/
%ignore coda_match_filefilter;
/*
----------------------------------------------------------------------------------------
- CUSTOM WRAPPERS AND HELPER FUNCTIONS THAT DO NOT NEED THE GLOBAL EXCEPTION MECHANISM -
----------------------------------------------------------------------------------------
*/
/*
Helper function to expose the global 'libcoda_version' variable
as a static method 'version()' at the Java level.
*/
%inline
%{
static const char *helper_version()
{
return libcoda_version;
}
%}
%ignore libcoda_version;
%ignore coda_get_libcoda_version;
/*
Helper functions for creating, deleting, and copying
coda_cursor structs. These structs are treated as an opaque
pointer type (i.e. the underlying C implementation is
unreachable from Java, and you can only pass references to
binary blobs around).
The handwritten nl.stcorp.coda.Cursor class will wrap such a
coda_cursor opaque object, provide constructors, and expose all
CODA functions that act on a coda_cursor struct as methods of
the Cursor object.
Product and Type structs are also opaque objects wrapped by
handwritten Java classes (with appropriate CODA functions
attached as methods), but the allocation and freeing of these
structs is always handled by CODA, so we do not need to create
and expose explicit memory management methods for those.
*/
%{
coda_cursor *new_coda_cursor()
{
return (coda_cursor *)malloc(sizeof(coda_cursor));
}
void delete_coda_cursor(coda_cursor *self)
{
free(self);
}
coda_cursor *deepcopy_coda_cursor(coda_cursor *self)
{
coda_cursor *new_cursor;
new_cursor = (coda_cursor *)malloc(sizeof(coda_cursor));
if( new_cursor != NULL )
{
memcpy(new_cursor, self, sizeof(coda_cursor));
}
return new_cursor;
}
%};
coda_cursor *new_coda_cursor();
void delete_coda_cursor(coda_cursor *self);
coda_cursor *deepcopy_coda_cursor(coda_cursor *self);
/*
Helper functions created to replace those CODA functions that
require pre-allocated strings (i.e. memory management is the
responsiblilty of the caller).
These functions will be wrapped and exposed upwards instead of
the underlying CODA equivalents. The latter must therefore also
be ignored afterwards.
*/
%newobject helper_coda_cursor_read_string; /* make sure free() will be called */
%inline
%{
char *helper_coda_cursor_read_string(const coda_cursor *cursor)
{
long dst_size;
char *dst;
coda_cursor_get_string_length(cursor, &dst_size);
dst = (char *)malloc(dst_size+1);
coda_cursor_read_string(cursor, dst, dst_size+1);
return dst;
}
%}
%ignore coda_cursor_read_string; /* ignore the real method being wrapped */
%newobject helper_coda_time_parts_to_string;
%inline
%{
char *helper_coda_time_parts_to_string(int year, int month, int day, int hour, int minute, int second, int musec,
const char *format)
{
char *dst = (char *)malloc(strlen(format) + 1);
coda_time_parts_to_string(year, month, day, hour, minute, second, musec, format, dst);
return dst;
}
%}
%ignore coda_time_parts_to_string; /* ignore the real method being wrapped */
%newobject helper_coda_time_double_to_string;
%inline
%{
char *helper_coda_time_double_to_string(double datetime, const char *format)
{
char *dst = (char *)malloc(strlen(format) + 1);
coda_time_double_to_string(datetime, format, dst);
return dst;
}
%}
%ignore coda_time_double_to_string; /* ignore the real method being wrapped */
%newobject helper_coda_time_double_to_string_utc;
%inline
%{
char *helper_coda_time_double_to_string_utc(double datetime, const char *format)
{
char *dst = (char *)malloc(strlen(format) + 1);
coda_time_double_to_string_utc(datetime, format, dst);
return dst;
}
%}
%ignore coda_time_double_to_string_utc; /* ignore the real method being wrapped */
%newobject helper_coda_time_to_string;
%inline
%{
char *helper_coda_time_to_string(double datetime)
{
char *dst = (char *)malloc(27);
coda_time_to_string(datetime, dst);
return dst;
}
%}
%ignore coda_time_to_string; /* ignore the real method being wrapped */
%newobject helper_coda_time_to_utcstring;
%inline
%{
char *helper_coda_time_to_utcstring(double datetime)
{
char *dst = (char *)malloc(27);
coda_time_to_utcstring(datetime, dst);
return dst;
}
%}
%ignore coda_time_to_utcstring; /* ignore the real method being wrapped */
/*
----------------------------------------------------------------------------------------
- GLOBAL EXCEPTION MECHANISM -
----------------------------------------------------------------------------------------
*/
/*
First, those declarations to which the exception clause should
not be attached are declared here and subsequently %ignore'd.
(i.e. these declarations are ignored when parsing the coda.h
file; see below). the declarations can be divided into
two classes:
- functions that do not return an int (0/-1) flag
- functions that _do_ return an int, but the return value
does not represent a (0/-1) error flag.
*/
/*
Functions that do not return an int.
*/
void coda_done(void);
double coda_NaN(void);
double coda_PlusInf(void);
double coda_MinInf(void);
const char *coda_type_get_format_name(coda_format format);
const char *coda_type_get_class_name(coda_type_class type_class);
const char *coda_type_get_native_type_name(coda_native_type native_type);
const char *coda_type_get_special_type_name(coda_special_type special_type);
const char *coda_expression_get_type_name(coda_expression_type type);
void coda_expression_delete(coda_expression *expr);
%ignore coda_done;
%ignore coda_NaN;
%ignore coda_PlusInf;
%ignore coda_MinInf;
%ignore coda_type_get_format_name;
%ignore coda_type_get_class_name;
%ignore coda_type_get_native_type_name;
%ignore coda_type_get_special_type_name;
%ignore coda_expression_get_type_name;
%ignore coda_expression_delete;
/*
Functions that return an int that represents a return value
instead of, or in addition to, being an error flag.
*/
int coda_get_option_bypass_special_types(void);
int coda_get_option_perform_boundary_checks(void);
int coda_get_option_perform_conversions(void);
int coda_get_option_use_fast_size_expressions(void);
int coda_get_option_use_mmap(void);
int coda_isNaN(const double x);
int coda_isInf(const double x);
int coda_isPlusInf(const double x);
int coda_isMinInf(const double x);
int coda_expression_is_constant(const coda_expression *expr);
int coda_expression_is_equal(const coda_expression *expr1, const coda_expression *expr2);
%ignore coda_get_option_bypass_special_types;
%ignore coda_get_option_perform_boundary_checks;
%ignore coda_get_option_perform_conversions;
%ignore coda_get_option_use_fast_size_expressions;
%ignore coda_get_option_use_mmap;
%ignore coda_isNaN;
%ignore coda_isInf;
%ignore coda_isPlusInf;
%ignore coda_isMinInf;
%ignore coda_expression_is_constant;
/*
Default exception clause for CODA errors. this will raise a
nl.stcorp.coda.CodaException exception in Java (which is a
handwritten class).
*/
%javaexception("nl.stcorp.coda.CodaException")
{
$action
if (result < 0)
{
int namelen = (int)strlen("$name");
const char *codamsg = coda_errno_to_string(coda_errno);
char *fullMessage = malloc(namelen + 4 + strlen(codamsg) + 1);
jclass clazz = (*jenv)->FindClass(jenv, "nl/stcorp/coda/CodaException");
sprintf(fullMessage, "$name(): %s", codamsg);
(*jenv)->ThrowNew(jenv, clazz, fullMessage);
free(fullMessage);
return $null;
}
}
/*
Turn all the wrappers for int-returning functions into
void-returning functions, because that return int is only the
error flag, and has therefore now been superseded by the
exception mechanism.
NOTE: this should of course not be done for functions that
return an int that actually returns a value. Hence the explicit
inclusion and then %ignoring of these functions earlier in this
section. All remaining int-returning functions are now
implicitly assumed to be error-flag returning ones.
However, this means that those function where the return value
is *both* an error flag and something useful will now not get
the exception handling applied.
TODO: Fix this.
*/
%typemap(out) int;
%typemap(out) int = void;
/*
----------------------------------------------------------------------------------------
- GLOBAL TYPEMAP ASSIGNMENTS -
----------------------------------------------------------------------------------------
*/
/*
Typemap for scalar output arguments of type 'int':
coda_double_to_datetime()::int *year, int *month, int *day,
int *hour, int *minute, int *second, int *musec
coda_double_to_utcdatetime()::int *year, int *month, int *day,
int *hour, int *minute, int *second, int *musec
coda_time_double_to_parts()::int *year, int *month, int *day,
int *hour, int *minute, int *second, int *musec
coda_time_double_to_parts_utc()::int *year, int *month, int *day,
int *hour, int *minute, int *second, int *musec
coda_time_string_to_parts()::int *year, int *month, int *day,
int *hour, int *minute, int *second, int *musec
coda_get_product_version()::int *version
coda_type_has_ascii_content()::int *has_ascii_content
coda_type_has_attributes()::int *has_attributes
coda_cursor_has_attributes()::int *has_attributes
coda_type_get_record_field_hidden_status()::int *hidden
coda_type_get_record_field_available_status()::int *available
coda_cursor_get_record_field_available_status()::int *available
coda_type_get_record_union_status()::int *is_union
coda_type_get_array_num_dims()::int *num_dims
coda_type_get_array_dim()::int *num_dims
coda_cursor_get_depth()::int *depth
coda_recognize_file()::int *product_version
coda_expression_eval_bool():int *value
*/
%apply int *OUTPUT { int *year, int *month, int *day,
int *hour, int *minute, int *second, int *musec,
int *version,
int *has_ascii_content,
int *has_attributes,
int *hidden,
int *available,
int *is_union,
int *num_dims,
int *depth,
int *product_version,
int *value};
/*
Typemap for scalar output arguments of type 'long':
coda_type_get_string_length()::long *length
coda_cursor_get_string_length()::long *length
coda_type_get_num_record_fields()::long *num_fields
coda_type_get_record_field_index_from_name()::long *index
coda_type_get_record_field_index_from_real_name()::long *index
coda_cursor_get_index()::long *index
coda_cursor_get_record_field_index_from_name()::long *index
coda_cursor_get_available_union_field_index()::long *index
coda_cursor_get_num_elements()::long *num_elements
*/
%apply long *OUTPUT { long *length,
long *num_fields,
long *index,
long *num_elements };
/*
Typemap for scalar output arguments of type 'int64_t':
coda_get_product_file_size()::int64_t *file_size
coda_get_product_variable_value()::int64_t *value
coda_type_get_bit_size()::int64_t *bit_size
coda_cursor_get_bit_size()::int64_t *bit_size
coda_cursor_get_byte_size()::int64_t *byte_size
coda_cursor_get_file_bit_offset()::int64_t *bit_size
coda_cursor_get_file_byte_offset()::int64_t *byte_size
coda_recognize_file()::int64_t *file_size
coda_expression_eval_integer()::int64_t *value
*/
%apply int64_t *OUTPUT { int64_t *file_size,
int64_t *bit_size,
int64_t *byte_size,
int64_t *bit_offset,
int64_t *byte_offset,
int64_t *value };
/*
Typemap for scalar output arguments of type 'uint64_t':
*/
%apply uint64_t *OUTPUT { uint64_t *dst };
/*
Typemap for scalar output arguments of type 'double':
coda_cursor_read_complex_double_split()::double *dst_re, double *dst_im
coda_datetime_to_double()::double *datetime
coda_expression_eval_float()::double *value
coda_utcdatetime_to_double()::double *datetime
coda_string_to_time()::double *datetime
coda_time_parts_to_double()::double *datetime
coda_time_parts_to_double_utc()::double *datetime
coda_time_string_to_double()::double *datetime
coda_time_string_to_double_utc()::double *datetime
coda_utcstring_to_time()::double *datetime
*/
%apply double *OUTPUT { double *dst_re, double *dst_im,
double *datetime, double *value };
%apply double *OUTPUT { double *dst };
int coda_cursor_read_double(const coda_cursor *cursor, double *dst);
%ignore coda_cursor_read_double;
%apply uint64_t *OUTPUT { uint64_t *dst };
int coda_cursor_read_uint64(const coda_cursor *cursor, uint64_t *dst);
%ignore coda_cursor_read_uint64;
/* There appears to be no working array typemap for "unsigned
long long" in arrays_java.i, so the following does not work
(it generates the scalar code instead.
%apply unsigned long long[] { uint64_t *dst };
int coda_cursor_read_uint64_array(const coda_cursor *cursor, uint64_t *dst, coda_array_ordering array_ordering);
%ignore coda_cursor_read_uint64_array;
So for now we just ignore the array case.
*/
/*
Typemaps for array output arguments of the primitive types.
Note that these typemaps are implicitly applied only to the
various read_* functions. For the read_*array variants, the
output parameter actually *is* an array. For the read_*
variants, the output parameter could also have used the scalar
OUTPUT maps, but since we will be wrapping these functions
anyway, we save ourselves the trouble and accept the array
variant there as well. (Except for char*, see below, which
needs to be handled separately and explicitly, because the
default SWIG behaviour for that type is to convert it to a
String input parameter.)
TODO: the typemap for the uint64 array reading function does
not work.
*/
%apply float[] { float *dst };
%apply double[] { double *dst };
%apply int8_t[] { int8_t *dst };
%apply int8_t[] { uint8_t *dst };
%apply int16_t[] { int16_t *dst };
%apply uint16_t[] { uint16_t *dst };
%apply int32_t[] { int32_t *dst };
%apply uint32_t[] { uint32_t *dst };
%apply int64_t[] { int64_t *dst };
/* %apply uint64_t[] { int64_t *dst }; */
/*
Typemap for scalar output arguments of type 'char'.
A 'signed char' typemap is applied, because just using 'char'
will cause the default mapping to 'String' to be used.
coda_cursor_read_char()::char *dst
We explicitly mention the full function here and then ignore it
afterwards, so that it will get processed here, and not with
the other functions, which is in turn so that the subsequent
array typemap (used for the char *dst parameter to
read_array_char) will not be applied to the scalar version of
that function.
*/
%apply int8_t *OUTPUT { char *dst };
int coda_cursor_read_char(const coda_cursor *cursor, char *dst);
%ignore coda_cursor_read_char;
%apply int8_t[] { char *dst };
int coda_cursor_read_char_array(const coda_cursor *cursor, char *dst, coda_array_ordering array_ordering);
%ignore coda_cursor_read_char_array;
int coda_cursor_read_char_partial_array(const coda_cursor *cursor, long offset, long length, char *dst);
%ignore coda_cursor_read_char_partial_array;
/*
Typemap for char ** (i.e. string) output arguments that are
memory-managed by CODA itself:
coda_recognize_file()::const char **product_class, const char **product_type
coda_get_product_filename()::const char **filename
coda_get_product_class()::const char **product_class
coda_get_product_type()::const char **product_type
coda_get_product_definition_file()::const char **definition_file
coda_type_get_name()::const char **name
coda_type_get_description()::const char **description
coda_type_get_unit()::const char **unit
coda_type_get_fixed_value()::const char **fixed_value
coda_type_get_record_field_name()::const char **name
coda_type_get_record_field_real_name()::const char **real_name
coda_expression_eval_string()::char **value
*/
%apply char **STRING_OUT { const char **product_class,
const char **product_type,
const char **definition_file,
const char **filename,
const char **name,
const char **description,
const char **unit,
const char **fixed_value,
const char **real_name,
char **value};
/*
Typemap for enum output arguments.
NOTE: this implicit map assumes all 'enum SWIGTYPE *' arguments
are output arguments.
*/
%apply int *OUTPUT { enum SWIGTYPE * };
/*
Typemap for coda_product ** output arguments that are
memory-managed by CODA itself:
coda_open()::coda_product **pf;
coda_open_as()::coda_product **pf;
coda_cursor_get_product_file()::coda_product **pf;
Code adapted from the Java section of the SWIG manual.
TODO: Refactor the duplicate use of these typemaps for Products
and Types into a single macro.
*/
%typemap(jni) coda_product ** "jobject"
%typemap(jtype) coda_product ** "SWIGTYPE_p_coda_product_struct"
%typemap(jstype) coda_product ** "SWIGTYPE_p_coda_product_struct"
%typemap(in) coda_product ** (coda_product *ppcoda_product = 0)
%{
$1 = &ppcoda_product;
%}
%typemap(argout) coda_product **
{
/* Give Java proxy the C pointer (of newly created object) */
jclass clazz = (*jenv)->FindClass(jenv, "nl/stcorp/coda/SWIGTYPE_p_coda_product_struct");
jfieldID fid = (*jenv)->GetFieldID(jenv, clazz, "swigCPtr", "J");
jlong cPtr = 0;
*(coda_product **)&cPtr = *$1;
(*jenv)->SetLongField(jenv, $input, fid, cPtr);
}
%typemap(javain) coda_product ** "$javainput"
/*
Typemap for coda_type ** output arguments that are
memory-managed by CODA itself:
coda_get_product_root_type()::coda_type **type
coda_type_get_attributes()::coda_type **attributes
coda_type_get_record_field_type()::coda_type **field_type
coda_type_get_array_base_type()::coda_type **base_type
coda_type_get_special_base_type()::coda_type **base_type
coda_cursor_get_type()::coda_type **type
Code adapted from the Java section of the SWIG manual.
TODO: Refactor the duplicate use of these typemaps for Products
and Types into a single macro.
*/
%typemap(jni) coda_type ** "jobject"
%typemap(jtype) coda_type ** "SWIGTYPE_p_coda_type_struct"
%typemap(jstype) coda_type ** "SWIGTYPE_p_coda_type_struct"
%typemap(in) coda_type ** (coda_type *ppcoda_type = 0)
%{
$1 = &ppcoda_type;
%}
%typemap(argout) coda_type **
{
/* Give Java proxy the C pointer (of newly created object) */
jclass clazz = (*jenv)->FindClass(jenv, "nl/stcorp/coda/SWIGTYPE_p_coda_type_struct");
jfieldID fid = (*jenv)->GetFieldID(jenv, clazz, "swigCPtr", "J");
jlong cPtr = 0;
*(coda_type **)&cPtr = *$1;
(*jenv)->SetLongField(jenv, $input, fid, cPtr);
}
%typemap(javain) coda_type ** "$javainput"
/*
Typemap for coda_expression ** output arguments that are
memory-managed by CODA itself:
coda_expression_from_string()::coda_expression **expr
Code adapted from the Java section of the SWIG manual.
TODO: Refactor the duplicate use of these typemaps for Products
and Types Expressions into a single macro.
*/
%typemap(jni) coda_expression ** "jobject"
%typemap(jtype) coda_expression ** "SWIGTYPE_p_coda_expression_struct"
%typemap(jstype) coda_expression ** "SWIGTYPE_p_coda_expression_struct"
%typemap(in) coda_expression ** (coda_expression *ppcoda_expression = 0)
%{
$1 = &ppcoda_expression;
%}
%typemap(argout) coda_expression **
{
/* Give Java proxy the C pointer (of newly created object) */
jclass clazz = (*jenv)->FindClass(jenv, "nl/stcorp/coda/SWIGTYPE_p_coda_expression_struct");
jfieldID fid = (*jenv)->GetFieldID(jenv, clazz, "swigCPtr", "J");
jlong cPtr = 0;
*(coda_expression **)&cPtr = *$1;
(*jenv)->SetLongField(jenv, $input, fid, cPtr);
}
%typemap(javain) coda_expression ** "$javainput"
/* This typemap is used to ensure that the **value string
allocated by CODA for the coda_expression_eval_string() method
(see also the STRING_OUT typemaps below) is properly freed
using coda_free.
*/
%typemap(freearg) char **value
{
coda_free(*$1);
}
/*
----------------------------------------------------------------------------------------
- MAIN HEADER FILE INCLUDE (coda.h) -
----------------------------------------------------------------------------------------
*/
/*
Wrap everything in coda.h
*/
%include "coda.h"
|