SophiaFramework UNIVERSE 5.3 |
Table 25.1. Macro to change SophiaFramework behavior
Macro | Description |
---|---|
TARGET_EXTENSION_KDDI | The BREW Japan Extension Package provided by KDDI is used. |
TARGET_BUILD_DEBUG | Build is done for debugging. |
By default, the [Using KDDI Extension Interface] option is not set.
To use the BREW Japan Extension Package, TARGET_EXTENSION_KDDI macro need to be defined by the #define directive before including the SophiaFramework.hpp header file.
When the TARGET_BUILD_DEBUG macro is defined, all macros of Macro for Debugging becomes valid.
Furthermore, the TARGET_BUILD_DEBUG macro will be automatically defined when building modules for the BREW Simulator.
The following macros are for using the proper code depending on the kind of BREW version or compiler, etc.
Table 25.2. Macro to declare code object
Macro | Description |
---|---|
TARGET_COMPILER_MSVCPP | The target compiler is Visual C++. |
TARGET_COMPILER_ARMCPP | The target compiler is ARM. |
TARGET_COMPILER_GNUCPP | The target compiler is GNU g++. |
TARGET_COMPILER_VERSION | The version of target compiler. |
TARGET_ENDIAN_BIG | Big endian. |
TARGET_ENDIAN_LITTLE | Little endian. |
TARGET_ENVIRONMENT_SIMULATOR | BREW Simulator. |
TARGET_ENVIRONMENT_PHYSICAL | Physical device. |
TARGET_VERSION_MAJOR | BREW SDK Major version. |
TARGET_VERSION_MINOR | BREW SDK Minor version. |
TARGET_VERSION_REVISION | BREW SDK Revision. |
TARGET_VERSION_BUILD | BREW SDK Build number. |
TARGET_VERSION_EQ | Defined BREW SDK version and given version are identical. |
TARGET_VERSION_NE | Defined BREW SDK version and given version are different. |
TARGET_VERSION_LT | Defined BREW SDK version is less than given version. |
TARGET_VERSION_LE | Defined BREW SDK version is not greater than given version. |
TARGET_VERSION_GT | Defined BREW SDK version is greater than given version. |
TARGET_VERSION_GE | Defined BREW SDK version is not less than given version. |
TARGET_BUILD_RELEASE | Build is done for release. |
Note | |
---|---|
The above are macros for SophiaFramework only, which cannot be redefined by the developer. |
TARGET_COMPILER_MSVCPP, TARGET_COMPILER_ARMCPP, and TARGET_COMPILER_GNUCPP are the macros for using the proper code depending on the kind of compiler.
UInt32 test(Void) { #if defined TARGET_COMPILER_ARMCPP UInt32 temp; asm { LDR temp, [pc, #-8] } return temp; #endif return 0; }
TARGET_ENDIAN_BIG and TARGET_ENDIAN_LITTLE are the macros for using the proper code depending on the kind of endian.
TARGET_ENVIRONMENT_SIMULATOR and TARGET_ENVIRONMENT_PHYSICAL are the macros for using the proper code depending on the simulator or the kind of runtime device.
TARGET_VERSION_MAJOR, TARGET_VERSION_MINOR, TARGET_VERSION_REVISION, and TARGET_VERSION_BUILD are the macros for displaying the BREW SDK version, which is automatically set depending on the kind of BREW SDK to be used for compilation.
For instance, if the BREW SDK version is 2.1.0 and the Build Number is 20, the values are set as follows:
TARGET_VERSION_MINOR = 1, TARGET_VERSION_REVISION = 0, TARGET_VERSION_BUILD = 20.
TARGET_VERSION_EQ, TARGET_VERSION_NE, TARGET_VERSION_LT, TARGET_VERSION_LE, TARGET_VERSION_GT, and TARGET_VERSION_GE are the macros for comparing the BREW SDK version with the specified arguments, which are Major version, Minor version, and Revision in this order.
#if TARGET_VERSION_GE(2,1,0) // for BREW SDK 2.1.0 or over ... #else // for under BREW SDK 2.1.0 ... #endif
Table 25.3. Macro to show maximum and minimum values
Macro | Meaning |
---|---|
BOOL_MAXIMUM | maximum value of the Bool type |
BOOL_MINIMUM | minimum value of the Bool type |
SINTN_MAXIMUM | maximum value of the SIntN type |
SINTN_MINIMUM | minimum value of the SIntN type |
UINTN_MAXIMUM | maximum value of the UIntN type |
UINTN_MINIMUM | minimum value of the UIntN type |
SINT08_MAXIMUM | maximum value of the SInt08 type |
SINT08_MINIMUM | minimum value of the SInt08 type |
UINT08_MAXIMUM | maximum value of the UInt08 type |
UINT08_MINIMUM | minimum value of the UInt08 type |
SINT16_MAXIMUM | maximum value of the SInt16 type |
SINT16_MINIMUM | minimum value of the SInt16 type |
UINT16_MAXIMUM | maximum value of the UInt16 type |
UINT16_MINIMUM | minimum value of the UInt16 type |
SINT32_MAXIMUM | maximum value of the SInt32 type |
SINT32_MINIMUM | minimum value of the SInt32 type |
UINT32_MAXIMUM | maximum value of the UInt32 type |
UINT32_MINIMUM | minimum value of the UInt32 type |
SINT64_MAXIMUM | maximum value of the SInt64 type |
SINT64_MINIMUM | minimum value of the SInt64 type |
UINT64_MAXIMUM | maximum value of the UInt64 type |
UINT64_MINIMUM | minimum value of the UInt64 type |
FLOAT32_MAXIMUM | maximum value of the Float32 type |
FLOAT32_MINIMUM | minimum value of the Float32 type |
FLOAT64_MAXIMUM | maximum value of the Float64 type |
FLOAT64_MINIMUM | minimum value of the Float64 type |
Reference: Type
Reference: Error Type
The pseudo exception handling mechanism similar to the exception handling mechanism in standard C++ language is provided with SophiaFramework.
Table 25.4. Pseudo exception mechanism
Function | Description |
---|---|
static_catch | Get the current error. |
static_try | Confirm whether the error is set or not. |
static_throw | Set the error. |
The static_throws is available as a mark of function where errors might be set using this pseudo exception handling mechanism. (No processing will be done.)
Pseudo exception mechanism is provided as the static_exception class.
template <typename T> class static_exception { public: T const& static_catch(Void) const; protected: Bool static_try(Void) const; Void static_throw(static_exception<T> const& param); Void static_throw(T const& param); };
The above pseudo exception mechanism can be used in the classes such as SFCApplication or SFRApplication, which are derived from the static_exception<T> class.
The difference with the standard C++ exception handling mechanism | |
---|---|
The execution control will not exit the function at which the static_throw statement is executed. To exit there, set the return statement immediately after the static_throw statement. |
class MyApp : public SFCApplication { SFMSEALCOPY(MyApp) private: Void SubFunc(Void) static_throws; SFCError MyAllocation(Void) { ... } // function where errors might occur public: Void MainFunc(Void); ... }; Void SubFunc(Void) static_throws { // confirm current error if (static_try()) { // when no error is set static_throw(MyAllocation()); // set error } ... } Void MainFunc(Void) { ... SubFunc(); switch (static_catch()) { // error handling ... } ... }
The SFMTYPEDEFBASE macro declares the reference, pointer, and handle types.
SFMTYPEDEFBASE(Base)
The SFMTYPEDEFBASE macro takes the type name as an argument, and generates the following type declarations.
typedef Base& BaseRef; typedef Base* BasePtr; typedef Base** BaseHandle;
The SFMTYPEDEFVOLATILE macro declares the reference, pointer, handle types with the volatile modifier.
SFMTYPEDEFVOLATILE(Base)
The SFMTYPEDEFVOLATILE macro takes the type name as an argument, and generates the following type declarations.
typedef Base volatile BaseVolatile; typedef BaseVolatile& BaseVolatileRef; typedef BaseVolatile* BaseVolatilePtr; typedef BaseVolatile** BaseVolatileHandle;
The SFMTYPEDEFCONST macro declares the reference, pointer, handle types with the const modifier.
SFMTYPEDEFCONST(Base)
The SFMTYPEDEFCONST macro takes the type name as an argument, and generates the following type declarations.
typedef Base const BaseConst; typedef BaseConst& BaseConstRef; typedef BaseConst* BaseConstPtr; typedef BaseConst** BaseConstHandle;
The SFMTYPEDEFVOLATILECONST macro declares the reference, pointer, handle types with the volatile const modifier.
SFMTYPEDEFVOLATILECONST(Base)
The SFMTYPEDEFVOLATILECONST macro takes the type name as an argument, and generates the following type declarations.
typedef Base volatile const BaseVolatileConst; typedef BaseVolatileConst& BaseVolatileConstRef; typedef BaseVolatileConst* BaseVolatileConstPtr; typedef BaseVolatileConst** BaseVolatileConstHandle;
The SFMTYPEDEFPACK macro calls the SFMTYPEDEFBASE macro for a certain type, its type with volatile modifier, its type with const modifier, and its type with volatile const modifier.
SFMTYPEDEFPACK(Base)
The SFMTYPEDEFPACK macro takes the type name as an argument, and declares the types equivalent to the following macros.
SFMTYPEDEFBASE(Base) SFMTYPEDEFVOLATILE(Base) SFMTYPEDEFCONST(Base) SFMTYPEDEFVOLATILECONST(Base)
The SFMTYPEDEFTYPE macro calls the SFMTYPEDEFPACK macro for a certain type, its pointer type, and its handle type.
SFMTYPEDEFTYPE(Base)
The SFMTYPEDEFTYPE macro takes the type name as an argument, and declares the types equivalent to the following macros.
SFMTYPEDEFPACK(Base) SFMTYPEDEFPACK(BasePtr) SFMTYPEDEFPACK(BaseHandle)
The SFMTYPEDEFALIAS macro calls the SFMTYPEDEFTYPE macro for the pre-defined alias of a certain type.
SFMTYPEDEFALIAS(Type, Alias)
The SFMTYPEDEFALIAS macro takes the type name and its alias as arguments, and declares the types equivalent to the following macros.
typedef Type Alias; SFMTYPEDEFTYPE(Alias);
The SFMTYPEDEFCLASS macro declares a class and its related types.
SFMTYPEDEFCLASS(Class)
The SFMTYPEDEFCLASS macro takes the class name as an argument, and declares the types equivalent to the following macros.
class Class; SFMTYPEDEFTYPE(Class);
SFMTYPEDEFCLASS(A) class A { ... }
The SFMTYPEDEFTYPE macro is expanded as follows:
SFMTYPEDEFCLASS(MyClass); class MyClass { private: ... };
class MyClass; typedef MyClass& MyClassRef; typedef MyClass* MyClassPtr; typedef MyClass** MyClassHandle; typedef MyClass volatile MyClassVolatile; typedef MyClass volatile& MyClassVolatileRef; typedef MyClass volatile* MyClassVolatilePtr; typedef MyClass volatile** MyClassVolatileHandle; typedef MyClass const MyClassConst; typedef MyClass const& MyClassConstRef; typedef MyClass const* MyClassConstPtr; typedef MyClass const** MyClassConstHandle; typedef MyClass volatile const MyClassVolatileConst; typedef MyClass volatile const& MyClassVolatileConstRef; typedef MyClass volatile const* MyClassVolatileConstPtr; typedef MyClass volatile const** MyClassVolatileConstHandle; typedef (MyClass*)& MyClassPtrRef; typedef (MyClass*)* MyClassPtrPtr; typedef (MyClass*)** MyClassPtrHandle; typedef MyClass* volatile MyClassPtrVolatile; typedef MyClass* volatile& MyClassPtrVolatileRef; typedef MyClass* volatile* MyClassPtrVolatilePtr; typedef MyClass* volatile** MyClassPtrVolatileHandle; typedef MyClass* const MyClassPtrConst; typedef MyClass* const& MyClassPtrConstRef; typedef MyClass* const* MyClassPtrConstPtr; typedef MyClass* const** MyClassPtrConstHandle; typedef MyClass* volatile const MyClassPtrVolatileConst; typedef MyClass* volatile const& MyClassPtrVolatileConstRef; typedef MyClass* volatile const* MyClassPtrVolatileConstPtr; typedef MyClass* volatile const** MyClassPtrVolatileConstHandle; typedef (MyClass**)& MyClassHandleRef; typedef (MyClass**)* MyClassHandlePtr; typedef (MyClass**)** MyClassHandleHandle; typedef MyClass** volatile MyClassHandleVolatile; typedef MyClass** volatile& MyClassHandleVolatileRef; typedef MyClass** volatile* MyClassHandleVolatilePtr; typedef MyClass** volatile** MyClassHandleVolatileHandle; typedef MyClass** const MyClassHandleConst; typedef MyClass** const& MyClassHandleConstRef; typedef MyClass** const* MyClassHandleConstPtr; typedef MyClass** const** MyClassHandleConstHandle; typedef MyClass** volatile const MyClassHandleVolatileConst; typedef MyClass** volatile const& MyClassHandleVolatileConstRef; typedef MyClass** volatile const* MyClassHandleVolatileConstPtr; typedef MyClass** volatile const**MyClassHandleVolatileConstHandle; class MyClass { private: ... };
The SFMTYPEDEFWRAPPER macro declares a wrapper class name and its related types.
SFMTYPEDEFWRAPPER(Class)
The SFMTYPEDEFWRAPPER macro takes the class name as an argument, and declares the types equivalent to the following macros.
SFMTYPEDEFCLASS(Class) SFMTYPEDEFALIAS(SFXBrewPointer<Class>, Class##Smp) SFMTYPEDEFALIAS(SFXBrewPointer<Class volatile>, Class##VolatileSmp) SFMTYPEDEFALIAS(SFXBrewPointer<Class const>, Class##ConstSmp) SFMTYPEDEFALIAS(SFXBrewPointer<Class volatile const>, Class##VolatileConstSmp)
The SFMTYPEDEFRESPONDER macro declares a Responder class and its related types.
SFMTYPEDEFRESPONDER(Class)
The SFMTYPEDEFRESPONDER macro takes the class name as an argument, and declare the types equivalent to the following macros.
SFMTYPEDEFCLASS(Class) SFMTYPEDEFALIAS(SFXResponderPointer<Class>, Class##Smp) SFMTYPEDEFALIAS(SFXResponderPointer<Class volatile>, Class##VolatileSmp) SFMTYPEDEFALIAS(SFXResponderPointer<Class const>, Class##ConstSmp) SFMTYPEDEFALIAS(SFXResponderPointer<Class volatile const>, Class##VolatileConstSmp)
The SFMTYPEDEFREFOBJECT macro declares a reference-counted object class and its related types.
SFMTYPEDEFREFOBJECT(Class)
The SFMTYPEDEFREFOBJECT macro takes the class name as an argument, and declare the types equivalent to the following macros.
SFMTYPEDEFCLASS(Class) SFMTYPEDEFALIAS(SFXRefObjectPointer<Class>, Class##Smp) SFMTYPEDEFALIAS(SFXRefObjectPointer<Class volatile>, Class##VolatileSmp) SFMTYPEDEFALIAS(SFXRefObjectPointer<Class const>, Class##ConstSmp) SFMTYPEDEFALIAS(SFXRefObjectPointer<Class volatile const>, Class##VolatileConstSmp)
The SFMTYPEDEFSTRUCT macro declares a structure and its related types.
SFMTYPEDEFSTRUCT(Struct)
The SFMTYPEDEFSTRUCT macro takes the structure name as an argument, and declare the types equivalent to the following macros.
struct Struct; SFMTYPEDEFTYPE(Struct);
The SFMTYPEDEFUNION macro declares a union and its related types.
SFMTYPEDEFUNION(Union)
The SFMTYPEDEFUNION macro takes the union name as an argument, and declares the types equivalent to the following macros.
union Union; SFMTYPEDEFTYPE(Union);
This macro is for declaring the implicit type conversion operator from the AtomRec struct into its corresopnding class or structure.
SFMUTILITYATOMDECLARE(Class)
This macro takes a class name or a structure name as an argument and then generates the declaration of the implicit type conversion operator from the AtomRec struct into its corresponding class or structure as below.
operator Class&(void); operator Class const&(void) const;
AtomRec struct | |
---|---|
The AtomRec struct is the POD(Plain Old Data) struct in C language which has the same memory layout with the corresponding class or structure. For more details, see Optimize ARM RealView Compilation Tool for BREW(at the Sophia Cradle Web site). If you define the AtomRec struct for a class or structure, you can optimize class or structure initialization with regard to size and speed. In this case, you must not use virtual function, multiple inheritance, and virtual inheritance for the class where the AtomRec struct is defined. To use the AtomRec struct, you have to implement the implicit type conversion operator from the AtomRec struct into the class or structure with the SFMUTILITYATOMDECLARE macro and the SFMUTILITYATOMIMPLEMENT macro, and the mutual type conversion function between the AtomRec struct and its corresopnding class or structure (atomic_cast operator) with SFMUTILITYATOMICCASTDECLARE macro and SFMUTILITYATOMICCASTIMPLEMENT macro. The AtomRec struct is used in SFXEvent, SFXEventRange, and classes of Shape and Color. |
Caution | |
---|---|
When you use the SFMUTILITYATOMDECLARE for declaration macro, you also have to use the SFMUTILITYATOMIMPLEMENT macro for implementation. |
In general, this macro is used together with the SFMUTILITYATOMICCASTDECLARE / SFMUTILITYATOMICCASTIMPLEMENT macros for declaring and implementing the mutual type conversion function between the AtomRec struct and its corresopnding class or structure (atomic_cast operator)
class Class { public: SFMTYPEDEFSTRUCT(AtomRec) struct AtomRec { SFMUTILITYATOMDECLARE(Class) ... } SFMUTILITYATOMICCASTDECLARE(Class, AtomRec) SFMUTILITYATOMIMPLEMENT(Class, AtomRec) SFMUTILITYATOMICCASTIMPLEMENT(Class, AtomRec)
This macro is for implementing the implicit type conversion operator from the AtomRec struct into its corresopnding class or structure.
SFMUTILITYATOMIMPLEMENT(Class, AtomicRec)
This macro takes a class name or a structure name as an argument and then generates the implementation of the implicit type conversion operator from the AtomRec struct into its corresponding class or structure as below.
inline Class::AtomicRec::operator Class&(void) { return *reinterpret_cast<Class*>(this); } inline Class::AtomicRec::operator Class const&(void) const { return *reinterpret_cast<Class const*>(this); }
Caution | |
---|---|
The SFMUTILITYATOMIMPLEMENT macro is used for implementation together with the SFMUTILITYATOMDECLARE macro. |
class Class { public: SFMTYPEDEFSTRUCT(AtomRec) struct AtomRec { SFMUTILITYATOMDECLARE(Class) ... } SFMUTILITYATOMICCASTDECLARE(Class, AtomRec) SFMUTILITYATOMIMPLEMENT(Class, AtomRec) SFMUTILITYATOMICCASTIMPLEMENT(Class, AtomRec)
This macro is for declaring the mutual type conversion function between the AtomRec struct and its corresopnding class or structure (atomic_cast operator).
SFMUTILITYATOMICCASTDECLARE(Class, AtomRec)
This macro takes a class name or a structure name and its coresponding AtomRec struct as arguments and then generates the declaration of the mutual type conversion function between the AtomRec struct and its corresopnding class or structure (atomic_cast operator) as blow.
extern Class* atomic_cast(Class::AtomRec* param); extern Class const* atomic_cast(Class::AtomRec const* param); extern Class::AtomRec* atomic_cast(Class* param); extern Class::AtomRec const* atomic_cast(Class const* param);
Caution | |
---|---|
When you use the SFMUTILITYATOMICCASTDECLARE macro, you also have to use the SFMUTILITYATOMICCASTIMPLEMENT macro. |
In general, this macro is used together with the SFMUTILITYATOMDECLARE / SFMUTILITYATOMIMPLEMENT macros which are for declaring and implementing the implicit type conversion operator from the AtomRec struct into its corresponding class or structure.
class Class { public: SFMTYPEDEFSTRUCT(AtomRec) struct AtomRec { SFMUTILITYATOMDECLARE(Class) ... } SFMUTILITYATOMICCASTDECLARE(Class, AtomRec) SFMUTILITYATOMIMPLEMENT(Class, AtomRec) SFMUTILITYATOMICCASTIMPLEMENT(Class, AtomRec)
This macro is for implementing the mutual type conversion function between the AtomRec struct and its corresopnding class or structure (atomic_cast operator).
SFMUTILITYATOMICCASTIMPLEMENT(Class, AtomicRec)
This macro takes a class name or a structure name and its coresponding AtomRec struct as arguments and then generates the implementaion of the mutual type conversion function between the AtomRec struct and its corresopnding class or structure (atomic_cast operator) as blow.
inline Class::AtomicRec* atomic_cast(Class* param) { return reinterpret_cast<Class::AtomicRec*>(param); } inline Class::AtomicRec const* atomic_cast(Class const* param) { return reinterpret_cast<Class::AtomicRec const*>(param); } inline Class* atomic_cast(Class::AtomicRec* param) { return reinterpret_cast<Class*>(param); } inline Class const* atomic_cast(Class::AtomicRec const* param) { return reinterpret_cast<Class const*>(param); }
Caution | |
---|---|
The SFMUTILITYATOMICCASTIMPLEMENT macro is used for implementation together with the SFMUTILITYATOMICCASTDECLARE macro. |
class Class { public: SFMTYPEDEFSTRUCT(AtomRec) struct AtomRec { SFMUTILITYATOMDECLARE(Class) ... } SFMUTILITYATOMICCASTDECLARE(Class, AtomRec) SFMUTILITYATOMIMPLEMENT(Class, AtomRec) SFMUTILITYATOMICCASTIMPLEMENT(Class, AtomRec)
There are macros that prohibit the developer from copying or assigning an instance.
The SFMSEALCONSTRUCT macro prohibits the developer from creating an instance.
SFMSEALCONSTRUCT(Class)
You cannot create the instance of class which consists of static members only.
The SFMSEALCONSTRUCT macro takes the class name as an argument, and is expanded as follows:
private: explicit Class(void); Class(Class const&); ~Class(void); const Class& operator=(Class const&);
SFMTYPEDEFCLASS(A) class A { SFMSEALCONSTRUCT(A) ... }
The SFMSEALWRAPPER macro prohibits the developer from copying an instance of wrapper class.
SFMSEALWRAPPER(Class)
For a wrapper class, use the SFMSEALWRAPPER macro instead of SFMSEALCONSTRUCT.
The SFMSEALRESPONDER macro prohibits the developer from copying an instance of Responder class.
SFMSEALRESPONDER(Class)
In the Responder class, use the SFMSEALRESPONDER macro instead of the SFMSEALCONSTRUCT macro.
The SFMSEALCOPY macro prohibits the developer from copying an instance, and define a copy constructor and an assign operator both of which are private.
SFMSEALCOPY(Class)
In the classes such as for buffer management, the problem on copying an instance can be avoided.
The SFMSEALCOPY macro takes the class name as an argument, and is expanded as follows:
private: Class(Class const&); Class& operator=(Class const&);
The SFMSEALASSIGN macro prohibits the developer from assigning an instance, and defines an assign operator of private.
SFMSEALASSIGN(Class)
The problem on assigning an instance can be avoided.
The SFMSEALASSIGN macro takes the class name as an argument, and is expanded as follows:
private: Class& operator=(Class const&);
SFMRESPONDERINSTANTIATE is a macro that describes the inherihance relation on responder classes.
Tip | |
---|---|
This maro is needed only for building your applet using RealView Compilation Tools for BREW 1.2. |
SFMRESPONDERINSTANTIATEFOUR(MyWindow, SFZWindow, SFYContainer, SFYWidget, SFYResponder)
When a responder class defined newly, you have to describe the inherihance relation from SFYResponder to newly defined class using SFMRESPONDERINSTANTIATEZERO, SFMRESPONDERINSTANTIATEONE, SFMRESPONDERINSTANTIATETWO, SFMRESPONDERINSTANTIATETHREE, SFMRESPONDERINSTANTIATEFOUR, SFMRESPONDERINSTANTIATEFIVE, SFMRESPONDERINSTANTIATESIX, SFMRESPONDERINSTANTIATESEVEN depending on the number of inheritance layers.
For instance, think of the MyWindow as below. MyWindow, SFZWindow, SFYContainer, and SFYWidget inherit from SFZWindow, SFYContainer, SFYWidget, and SFYWidget respectively. Since there is four layers from SFYResponder to MyWindow, use the SFMRESPONDERINSTANTIATEFOUR macro.
If the number of inheritance layers from SFYResponder is three, use the SFMRESPONDERINSTANTIATETHREE macro. If five layers, use the SFMRESPONDERINSTANTIATEFIVE macro. This macro is provided with up to the SFMRESPONDERINSTANTIATESEVEN macro which is used in inheriting from seven layers.
Bug on RealView Compilation Tools for BREW 1.2 | |
---|---|
This macro is necessary for avoiding a bug of RealView Compilation Tools for BREW 1.2 compiler. This macro is ignored in compilers other than RealView Compilation Tools for BREW 1.2. |
SFMWRAPPERINSTANTIATE is a macro that describes the inherihance relation on wrapper classes.
Tip | |
---|---|
This maro is needed only for building your applet using RealView Compilation Tools for BREW 1.2. |
SFMWRAPPERINSTANTIATEONE(SFBHash, SFBBase)
When defining a wrapper class newly, you have to describe the inherihance relation from the SFBBase class to newly defined class using SFMWRAPPERINSTANTIATEZERO, SFMWRAPPERINSTANTIATEONE, SFMWRAPPERINSTANTIATETWO, SFMWRAPPERINSTANTIATETHREE, SFMWRAPPERINSTANTIATEFOUR, SFMWRAPPERINSTANTIATEFIVE, SFMWRAPPERINSTANTIATESIX, SFMWRAPPERINSTANTIATESEVEN depending on the number of inheritance layers.
Since the IHash interface inherits from the IBase interface, when the wrapper class for the IBase interface is the SFBBase class and the wrapper class for the IHash interface is the SFBHash class, declare the SFMWRAPPERINSTANTIATEONE(SFBHash, SFBBase) macro.
In the SFBBase class, since this class is the highest in the inheritance relation, declare SFMWRAPPERINSTANTIATEZERO(SFBBase) using the SFMWRAPPERINSTANTIATEZERO macro.
There are three warpper classes called A, B, and C. B inherits from A and C inherits from B respectively. Then declare SFMWRAPPERINSTANTIATETWO(C, B, A) using the SFMWRAPPERINSTANTIATETWO macro.
In case of four wrapper classes of A, B, C, amd D, declare the SFMWRAPPERINSTANTIATETHREE(D, C, B, A) macro.
Bug on RealView Compilation Tools for BREW 1.2 | |
---|---|
This macro is necessary for avoiding a bug of RealView Compilation Tools for BREW 1.2 compiler. This macro is ignored in compilers other than RealView Compilation Tools for BREW 1.2. |
SFMREFOBJECTINSTANTIATE is a macro that describes the inherihance relation on reference-counted classes.
Tip | |
---|---|
This maro is needed only for building your applet using RealView Compilation Tools for BREW 1.2. |
SFMREFOBJECTINSTANTIATETWO(MyTableCellReactor, SFOTableCellReactor, SFORefObject)
When a reference-counted class defined newly, you have to describe the inherihance relation from SFORefObject to newly defined class using SFMREFOBJECTINSTANTIATEZERO, SFMREFOBJECTINSTANTIATEONE, SFMREFOBJECTINSTANTIATETWO, SFMREFOBJECTINSTANTIATETHREE, SFMREFOBJECTINSTANTIATEFOUR, SFMREFOBJECTINSTANTIATEFIVE, SFMREFOBJECTINSTANTIATESIX, SFMREFOBJECTINSTANTIATESEVEN depending on the number of inheritance layers.
For instance, think of the MyTableCellReactor as below. MyTableCellReactor and SFOTableCellReactor inherit from SFOTableCellReactor and SFORefObject respectively. Since there is two layers from SFORefObject to MyTableCellReactor, use the SFMREFOBJECTINSTANTIATETWO macro.
If the number of inheritance layers from SFORefObject is three, use the SFMREFOBJECTINSTANTIATETHREE macro. If four layers, use the SFMREFOBJECTINSTANTIATEFOUR macro. This macro is provided with up to the SFMREFOBJECTINSTANTIATESEVEN macro which is used in inheriting from seven layers.
Bug on RealView Compilation Tools for BREW 1.2 | |
---|---|
This macro is necessary for avoiding a bug of RealView Compilation Tools for BREW 1.2 compiler. This macro is ignored in compilers other than RealView Compilation Tools for BREW 1.2. |
The type conversion operators available in Visual C++ such as reinterpret_cast, static_cast, dynamic_cast, and const_cast cannot be used in the ARM compiler such as RealView Compilation Tools for BREW 1.2.
Note | |
---|---|
SophiaFramework replaces these type conversion operators with the type conversion operators of C language, though these operators depend on variable and function as the table below. |
Table 25.5. Standard C++ and SophiaFramework Type Conversion Operators
Standard C++ | For SophiaFramework variable | For SophiaFramework function |
---|---|---|
reinterpret_cast | reinterpret_cast | reinterpret_function_cast |
static_cast | static_cast | static_function_cast |
dynamic_cast | dynamic_cast | dynamic_function_cast |
const_cast | const_cast | const_function_cast |
The dynamic_cast operator on handset device | |
---|---|
Although the ARM compiler replaces the dynamic_cast with the type cast operator of C language, there is no guarantee that a type will downcast to the correct type. |
Type conversion macro for constants | |
---|---|
When the type conversion macro is used for constants, its binary file after compilation tends to be bigger. |
The interface_cast operator is the type conversion operator to convert a pointer to the BREW interface into a pointer to the corresponding SophiaFramework class, and vice versa.
More specifically, the interface_cast operator casts between the I????? interface of BREW and the SFB????? class of SophiaFramework, and between the AEE????? interface of BREW and the SFX????? class of SophiaFramework regarding color, shape, callback.
The code to use the interface_cast operator is as below.
SFBFileMgrSmp xfilemgr; // SFBFileMgr class(smart pointer)
IFileMgr* ifilemgr; // IFileMgr interface
ifilemgr = interface_cast(xfilemgr.Get()); // SFBFileMgr class -> IFileMgr interface
SFBFileMgrSmp xfilemgr; // SFBFileMgr class(smart pointer)
IFileMgr* ifilemgr; // IFileMgr interface
xfilemgr.Set(interface_cast(ifilemgr)); // IFileMgr interface -> SFBFileMgr class
The static_pointer_cast operator is for downcasting the smart pointer type.
The static_pointer_cast operator takes a class name as an argument. For instance, to downcast the return value of SFYResponderSmp type of the SFYResponder::GetChildFront into the SFZTextButtonControlSmp type, specify not SFZTextButtonControlSmp but SFZTextButtonControl as an argument of the static_pointer_cast operator.
// downcast from SFYResponderSmp type to SFZTextButtonControlSmp type SFZTextButtonControlSmp pair = static_pointer_cast<SFZTextButtonControl>(GetThis()->GetChildFront(pairID)); // * GetChildFront() returns value of SFYResponderSmp type
The atomic_cast operator is the type conversion operator to convert a pointer to the class such as Shape and Color where the AtomRec structure is defined into a pointer to its AtomRec structure, and vice versa.
The code to use the atomic_cast operator is as below.
Void my_func(SFXRectangleConst rects[2]) { // do something. ...... } SFXRectangle::AtomRecConst rects[] = { {0, 0, 100, 100}, {0, 0, 50, 50} }; my_func(atomic_cast(rects));
AtomRec struct | |
---|---|
The AtomRec struct is the POD(Plain Old Data) struct in C language which has the same memory layout with the corresponding class or structure. For more details, see Optimize ARM RealView Compilation Tool for BREW(at the Sophia Cradle Web site). If you define the AtomRec struct for a class or structure, you can optimize class or structure initialization with regard to size and speed. In this case, you must not use virtual function, multiple inheritance, and virtual inheritance for the class where the AtomRec struct is defined. |
The lengthof macro is for getting the length of array.
#define lengthof(Array) (sizeof((Array)) / sizeof((Array)[0]))
The align64of macro is for calculating the size of type aligned at the 8-bytes boundary.
Beside the align64of macro, there are the align08of, align16of, and align32of macros for 1-byte, 2-byte, and 4-byte boundaries respectively.
#define align08of(type) ((sizeof(type) + 0) & ~0) #define align16of(type) ((sizeof(type) + 1) & ~1) #define align32of(type) ((sizeof(type) + 3) & ~3) #define align64of(type) ((sizeof(type) + 7) & ~7)
The cluster64of macro is for calculating how many 8-bytes clusters are neccessary for the type aligned at 8-bytes boundary.
Beside the cluster64of macro, there are the cluster08of, cluster16of, and cluster32of macros for 1-byte, 2-byte, and 4-byte boundaries respectively.
#define cluster08of(type) ((sizeof(type) + 0) > 0) #define cluster16of(type) ((sizeof(type) + 1) > 1) #define cluster32of(type) ((sizeof(type) + 3) > 2) #define cluster64of(type) ((sizeof(type) + 7) > 3)
The following are the macros for generating the character literal as an identifier for object such as responder type or responder attribute.
Table 25.6. Macro for generating literal
Macro | Description |
---|---|
one_char_code(x) | Generate 1-character literal. |
two_char_code(x, y) | Generate 2-characters literal. |
four_char_code(w, x, y, z) | Generate 4-character literal. |
Each argument is a value of AChar type (a value of binary type can be also specified).
For four_char_code macro | |
---|---|
The 4-character literals of lower-case alphabet are reserved for SophiaFramework. |
Generate the 4-character literal.
SFCType val = four_char_code('A', 'b', 'c', 'd'); ACharPtr p = reinterpret_cast<ACharPtr>(&val);
The alignment on the memory of these generated values is the same regardless of endian.
In the example above, the value of *p will be 'A'.
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |