Statistics
| Branch: | Revision:

root / ide / org.omnetpp.ide.nativelibs / commondefs.i @ 9d023582

History | View | Annotate | Download (2.8 KB)

1
%{
2
#include "bigdecimal.h"
3
#include "jprogressmonitor.h"
4
%}
5

    
6
%exception {
7
    try {
8
        $action
9
    } catch (std::exception& e) {
10
        SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, const_cast<char*>(e.what()));
11
        return $null;
12
    }
13
}
14

    
15
/*--------------------------------------------------------------------------
16
 * int32 <--> int mapping
17
 *--------------------------------------------------------------------------*/
18
%include "intxtypes.h"
19

    
20
%typemap(jni)    int32_t "jint"
21
%typemap(jtype)  int32_t "int"
22
%typemap(jstype) int32_t "int"
23
%typemap(javain) int32_t "$javainput"
24
%typemap(javaout) int32_t {
25
   return $jnicall;
26
}
27

    
28
/*--------------------------------------------------------------------------
29
 * int64 <--> long mapping
30
 *--------------------------------------------------------------------------*/
31
%typemap(jni)    int64_t "jlong"
32
%typemap(jtype)  int64_t "long"
33
%typemap(jstype) int64_t "long"
34
%typemap(javain) int64_t "$javainput"
35
%typemap(javaout) int64_t {
36
   return $jnicall;
37
}
38

    
39
/*--------------------------------------------------------------------------
40
 * IProgressMonitor
41
 *--------------------------------------------------------------------------*/
42
%typemap(jni)    IProgressMonitor * "jobject"
43
%typemap(jtype)  IProgressMonitor * "org.eclipse.core.runtime.IProgressMonitor"
44
%typemap(jstype) IProgressMonitor * "org.eclipse.core.runtime.IProgressMonitor"
45
%typemap(javain) IProgressMonitor * "$javainput"
46
%typemap(in) IProgressMonitor * (JniProgressMonitor jProgressMonitor) {
47
   if ($input)
48
   {
49
      jProgressMonitor = JniProgressMonitor($input, jenv);
50
      $1 = &jProgressMonitor;
51
   }
52
   else
53
   {
54
      $1 = NULL;
55
   }
56
}
57

    
58
/*
59
 * Macro to add equals() and hashCode() to generated Java classes
60
 */
61
%define ADD_CPTR_EQUALS_AND_HASHCODE(CLASS)
62
%typemap(javacode) CLASS %{
63
  public boolean equals(Object obj) {
64
    if (this == obj)
65
      return true;
66
    if (obj == null || this.getClass() != obj.getClass())
67
      return false;
68
    return getCPtr(this) == getCPtr((CLASS)obj);
69
  }
70

    
71
  public int hashCode() {
72
    return (int)getCPtr(this);
73
  }
74
%}
75
%enddef
76

    
77
/*
78
 * ILock
79
 */
80
%define USE_COMMON_ENGINE_ILOCK()
81
class ILock;
82
%typemap(jstype) ILock "org.omnetpp.common.engine.ILock";
83
%typemap(javaout) ILock {
84
    long cPtr = $jnicall;
85
    return (cPtr == 0) ? null : new org.omnetpp.common.engine.ILock(cPtr, $owner);
86
}
87

    
88
%typemap(jstype) ILock* "org.omnetpp.common.engine.ILock";
89
%typemap(javaout) ILock* {
90
    long cPtr = $jnicall;
91
    return (cPtr == 0) ? null : new org.omnetpp.common.engine.ILock(cPtr, $owner);
92
}
93

    
94
%typemap(jstype) ILock& "org.omnetpp.common.engine.ILock";
95
%typemap(javaout) ILock& {
96
    long cPtr = $jnicall;
97
    return (cPtr == 0) ? null : new org.omnetpp.common.engine.ILock(cPtr, $owner);
98
}
99

    
100
%enddef