public interface Ifc
Ifc_Test.c
and Ifc_Test.h
.
getMtbl_ObjectJc(...)
and than calls the method dynamically. The user can call this method static linked, this method
organized the dynmically call. ( Elsewhere the user can optimize and call via method table itself,
Java2C translates such calls.)
sign_Mtbl_...
of this interface.
#define ...
typedef struct {...}
of the interface type. The struct contains only
union { ObjectJc object; } base;
#define ...
for all static final values.
MT_
method type of the interface methods.
sign_Mtbl_...
of teh interface.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
constString
Example for a simple constant string literal.
|
static int |
constValue
Example for a simple constant declared in java.
|
static int |
constValue2
Example for a calculated constant.At this time this constant is declared in Headerfile as
extern const int32 constValue2_Ifc_Test; |
Modifier and Type | Method and Description |
---|---|
float |
anotherIfcmethod(float input)
Example for an interface method with same name as another in the same class, but other parameter set.
|
int |
anotherIfcmethod(int input)
Example for a second interface method, not a recentness, but see next
anotherIfcmethod(float) . |
int |
processIfcMethod(int input)
Example for an interface method.
|
static final int constValue
#define constValue_Ifc_Test 24In this form the constant is used as an immediate value. A usage of this value is independent of the content of the interface' C-file. The same behavior is known for java in such cases: A substitution of a class file which contains another value for the same constant doesn't update the value in already-compiled class files.
static final java.lang.String constString
extern const StringJc constString_Ifc_Test;and defined in the C-File. It means, its value is updated if the interface is compiled and supplied newly. The string literal itself is stored only one time in the code. It is better as translating a
#define constString_Ifc_Test "IfcTest"
.static final int constValue2
extern const int32 constValue2_Ifc_Test;and defined in C-file as
const int32 constValue2_Ifc_Test = (constValue_Ifc_Test + 1) / 2 + 1;where the calculation is made at compile time. It is possible because the input values are constants or constants defined per #define.
#define constValue2_Ifc_Test (constValue_Ifc_Test + 1)/2 +1The behavior should be changed in the next releases of Java2C.
int processIfcMethod(int input)
typedef int32 MT_processIfcMethod_Ifc_Test(ObjectJc* ithis, int32 input, ThCxt* _thCxt);The method table is defined one time for all interface methods, containing both methods of this example of Java-interface:
typedef struct Mtbl_Ifc_Test_t { MtblHeadJc head; MT_processIfcMethod_Ifc_Test* processIfcMethod; MT_anotherIfcmethod_i_Ifc_Test* anotherIfcmethod_i; MT_anotherIfcmethod_f_Ifc_Test* anotherIfcmethod_f; Mtbl_ObjectJc ObjectJc; } Mtbl_Ifc_Test;An implementation uses this struct definition inside its more complex method table struct definition, defines a const method table instance and set the implementation of the method at the appropriate position, see
ImplIfc.processIfcMethod(int)
.input
- Exampleint anotherIfcmethod(int input)
anotherIfcmethod(float)
.input
- float anotherIfcmethod(float input)
typedef int32 MT_anotherIfcmethod_i_Ifc_Test(ObjectJc* ithis, int32 input, ThCxt* _thCxt); typedef float MT_anotherIfcmethod_f_Ifc_Test(ObjectJc* ithis, float input, ThCxt* _thCxt);and the adequate positions in the method table.
input
-