org.vishia.java2C.test
Interface Ifc

All Known Implementing Classes:
ExtendsImpl, ImplIfc

public interface Ifc

This interface should demonstrate the translation of Java-Interfaces to C. Visit the translated Ifc_Test.c and Ifc_Test.h.
The C-File contains code for:

The Headerfile contains declarations and definitions for: Compilation and linking the C-File: The kept C-File of any translated Java-interfaces should be compiled and provided as object-file maybe in a library outside of a usage of the interface in an implementation. It means, it should not be a part of a implementation library of the interface, but it should be a part of a library providing the interface stand-alone independent of its usage. It is the same like a Java-package with interfaces only. It has its compiled byte code.


Field Summary
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;
 
 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.
 
Method Summary
 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.
 

Field Detail

constValue

static final int constValue
Example for a simple constant declared in java. Because it is fix and constant, it is translated in C as
 #define constValue_Ifc_Test 24
 
In 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.

See Also:
Constant Field Values

constString

static final java.lang.String constString
Example for a simple constant string literal. It is declared as
 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".

See Also:
Constant Field Values

constValue2

static final int constValue2
Example for a calculated constant.At this time this constant is declared in Headerfile as
 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.
This strategy of compiling is limited. A constant defined in this form isn't able to use in C as constant input to built a adequate constant. The compiler may cause an error "initializer is not a constant" though the value is defined before. (testet with visual-Studio-6 C-compilation). Therefore it is better to build a
 #define constValue2_Ifc_Test (constValue_Ifc_Test + 1)/2 +1
 
The behavior should be changed in the next releases of Java2C.

See Also:
Constant Field Values
Method Detail

processIfcMethod

int processIfcMethod(int input)
Example for an interface method. This method is only abstract. In C it is a member of a so named method table. Therefore a method type definition is written in the Java2C-translated Headerfile:
 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).

Parameters:
input - Example
Returns:
Example

anotherIfcmethod

int anotherIfcmethod(int input)
Example for a second interface method, not a recentness, but see next anotherIfcmethod(float).

Parameters:
input -
Returns:

anotherIfcmethod

float anotherIfcmethod(float input)
Example for an interface method with same name as another in the same class, but other parameter set. The ambiguousness of the methods are detect and a unambiguous C-name is build. Therefore the two methods builds several method type declarations in headerfile:
 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.

Parameters:
input -
Returns: