PrevNextUpHome SophiaFramework UNIVERSE 5.3

26.2. Primitive Type

26.2.1. Bool Type

Definition

#undef          bool
#define         bool                boolean

SFMTYPEDEFALIAS(bool, Bool)

#undef          true
#define         true                (TRUE)
#undef          false
#define         false               (FALSE)

Reference: SFMTYPEDEFALIAS

Example

if (SFXAscii::IsDigit(ch) == true) { ... }   // wrong usage
if (SFXAscii::IsDigit(ch)) { ... }           // correct usage
[Note] Note
The function with return value of the Bool type dose not necessarily return "1" as logical true value. Like C language, the values other than 0 are considered as logical true value in SophiaFramework UNIVERSE.
Bool MyFunction(SIntN flag) {
    return (flag & 0x4000);   // wrong usage
}
[Note] Note

In SophiaFramework UNIVERSE, the Bool type dose not necessarily equal the int type although the logical value is of the int type in C language.

If the Bool type is defined as unsigned char type, the return value is always false (=0).

Bool MyFunction(int flag) {
    return (flag & 0x4000 != 0);   // correct usage
}
        
// or
        
Bool MyFunction(int flag) {
    return !!(flag & 0x4000);      // correct usage
}

26.2.2. Void Type

Definition

typedef     void                     Void, *VoidPtr, **VoidHandle;
typedef     void volatile            VoidVolatile, *VoidVolatilePtr, **VoidVolatileHandle;
typedef     void const               VoidConst, *VoidConstPtr, **VoidConstHandle;
typedef     void volatile const      VoidVolatileConst, *VoidVolatileConstPtr, **VoidVolatileConstHandle;
SFMTYPEDEFPACK(VoidPtr)
SFMTYPEDEFPACK(VoidHandle)

26.2.3. Generic Pointer Type and Generic Handle Type

Definition

typedef     char                                &Ref, *Ptr, **Handle;
typedef     char volatile                       &VolatileRef, *VolatilePtr, **VolatileHandle;
typedef     char const                          &ConstRef, *ConstPtr, **ConstHandle;
typedef     char volatile const                 &VolatileConstRef, *VolatileConstPtr, **VolatileConstHandle;
SFMTYPEDEFPACK(Ptr)
SFMTYPEDEFPACK(Handle)

26.2.4. Integer Type

Definition

// signed integer
SFMTYPEDEFALIAS(signed int, SIntN)

// unsigned integer
SFMTYPEDEFALIAS(unsigned int, UIntN)

// 8-bit signed integer
SFMTYPEDEFALIAS(signed char, SInt08)

// 8-bit unsigned integer
SFMTYPEDEFALIAS(unsigned char, UInt08)

// 16-bit signed integer
SFMTYPEDEFALIAS(signed short, SInt16)

// 16-bit unsigned integer
SFMTYPEDEFALIAS(unsigned short, UInt16)

// 32-bit signed integer
SFMTYPEDEFALIAS(signed long, SInt32)

// 32-bit unsigned integer
SFMTYPEDEFALIAS(unsigned long, UInt32)

// 64-bit signed integer
#if defined TARGET_COMPILER_MSVCPP
SFMTYPEDEFALIAS(signed __int64, SInt64)
#else
SFMTYPEDEFALIAS(signed long long, SInt64)
#endif

// 64-bit unsigned integer
#if defined TARGET_COMPILER_MSVCPP
SFMTYPEDEFALIAS(unsigned __int64, UInt64)
#else
SFMTYPEDEFALIAS(unsigned long long, UInt64)
#endif

26.2.5. Floating Point Type

Definition

SFMTYPEDEFALIAS(float, Float32)
SFMTYPEDEFALIAS(double, Float64)
[Note] Note
Since the C/C++ floating point arithmetic operations can be used in SophiaFramework, the BREW helper functions are unnecessary.
[Caution] Using the floating point arithmetic operations

The applet size increases depending on the kinds of floating point arithmetic operations used, since the applet will be linked with the floating point libraries.

Example

Float64 num1(255);
Float64 num2(123.5);
Float64 num3;

num3 = (num1 + num2) / (num1 - num3);

if (num3 < num1) {
      ...
}
[Note] Note

Trigonometric, exponential, and logarithmic functions not included in the BREW API are available in SophiaFramework UNIVERSE.

The SFXTrigonometric class for fast trigonometric operations can be also used.

Reference: Mathematical functions of RealView Compilation Tools for BREW V1.2

26.2.6. Byte Type

Definition

SFMTYPEDEFALIAS(UInt08, Byte)

26.2.7. Character Type

Definition

SFMTYPEDEFALIAS(char, AChar)
SFMTYPEDEFALIAS(AECHAR, WChar)
[Note] AChar and WChar

AChar is defined as alias of the char type for the single/multi byte character (or the ANSI character).

On the other hand, WChar is defined as alias of the AECHAR type (or the uint16 type) for the double byte character.

By the way, AECHAR is defined as below in the "AEEStdDef.h" header file of BREW SDK:

typedef    uint16   AECHAR;