Statistics
| Branch: | Revision:

root / src / org.omnetpp.ide.nativelibs / common.i @ 79bb12dc

History | View | Annotate | Download (3.09 KB)

1
%module Common
2

    
3
// covariant return type warning disabled
4
#pragma SWIG nowarn=822
5

    
6
%{
7
#include "stringutil.h"
8
#include "patternmatcher.h"
9
#include "unitconversion.h"
10
#include "bigdecimal.h"
11
#include "rwlock.h"
12
%}
13

    
14
%include "commondefs.i"
15
%include "loadlib.i"
16
%include "std_string.i"
17
%include "std_vector.i"
18

    
19
namespace std {
20
   %template(StringVector) vector<string>;
21
   %template(PStringVector) vector<const char *>;
22
}
23

    
24
#define THREADED
25

    
26
// hide export/import macros from swig
27
#define COMMON_API
28
#define OPP_DLLEXPORT
29
#define OPP_DLLIMPORT
30

    
31
#define NAMESPACE_BEGIN
32
#define NAMESPACE_END
33
#define USING_NAMESPACE
34

    
35
%rename(parseQuotedString)   ::opp_parsequotedstr;
36
%rename(quoteString)         ::opp_quotestr;
37
%rename(needsQuotes)         ::opp_needsquotes;
38
%rename(quoteStringIfNeeded) ::opp_quotestr_ifneeded;
39

    
40
std::string opp_parsequotedstr(const char *txt);
41
std::string opp_quotestr(const char *txt);
42
bool opp_needsquotes(const char *txt);
43
std::string opp_quotestr_ifneeded(const char *txt);
44
int strdictcmp(const char *s1, const char *s2);
45

    
46
%ignore UnitConversion::parseQuantity(const char *, std::string&);
47

    
48
%include "patternmatcher.h"
49
%include "unitconversion.h"
50

    
51

    
52
/* -------------------- BigDecimal -------------------------- */
53

    
54

    
55
%ignore _I64_MAX_DIGITS;
56
%ignore BigDecimal::BigDecimal();
57
%ignore BigDecimal::str(char*);
58
%ignore BigDecimal::parse(const char*,const char*&);
59
%ignore BigDecimal::ttoa;
60
%ignore BigDecimal::Nil;
61
%ignore BigDecimal::isNil;
62
%ignore BigDecimal::operator=;
63
%ignore BigDecimal::operator+=;
64
%ignore BigDecimal::operator-=;
65
%ignore BigDecimal::operator*=;
66
%ignore BigDecimal::operator/=;
67
%ignore BigDecimal::operator!=;
68
%ignore operator+;
69
%ignore operator-;
70
%ignore operator*;
71
%ignore operator/;
72
%ignore operator<<;
73
%immutable BigDecimal::Zero;
74
%immutable BigDecimal::NaN;
75
%immutable BigDecimal::PositiveInfinity;
76
%immutable BigDecimal::NegativeInfinity;
77
%rename(equals) BigDecimal::operator==;
78
%rename(less) BigDecimal::operator<;
79
%rename(greater) BigDecimal::operator>;
80
%rename(lessOrEqual) BigDecimal::operator<=;
81
%rename(greaterOrEqual) BigDecimal::operator>=;
82
%rename(toString) BigDecimal::str;
83
%rename(doubleValue) BigDecimal::dbl;
84

    
85
%extend BigDecimal {
86
   const BigDecimal add(const BigDecimal& x) {return *self + x;}
87
   const BigDecimal subtract(const BigDecimal& x) {return *self - x;}
88
}
89

    
90
SWIG_JAVABODY_METHODS(public, public, BigDecimal)
91

    
92
%typemap(javacode) BigDecimal %{
93
    public boolean equals(Object other) {
94
       return other instanceof BigDecimal && equals((BigDecimal)other);
95
    }
96

    
97
    public int hashCode() {
98
       return (int)getIntValue();
99
    }
100

    
101
    public java.math.BigDecimal toBigDecimal() {
102
       long intVal = getIntValue();
103
       int scale = getScale();
104
       java.math.BigDecimal d = new java.math.BigDecimal(intVal);
105
       return (scale == 0 ? d : d.movePointRight(scale));
106
    }
107
%}
108

    
109
%include "bigdecimal.h"
110

    
111

    
112
/* -------------------- rwlock.h -------------------------- */
113
%ignore ReaderMutex;
114
%ignore WriterMutex;
115
SWIG_JAVABODY_METHODS(public, public, ILock)
116

    
117
%include "rwlock.h"