2005/5/10

     
 

Foreign Types

artefaktur

| Basic Types | Enum Types | Object Types | Array Types | Interface Types | Exception Types | Member Types | Method Types | Namespace Types | Foreign Types |



The rich type system of the C++-Language can be used in ACDK. Because these types are unkown to the ACDK meta info system they are called foreign types.


Content of this chapter:

   Foreign types
     Foreign basic types
     Functions
     compound types
   Foreign types inside ACDK classes
     Class members
     Class methods
     Base classes/interfaces



 Foreign types

Because the core of ACDK is implemented with normal C++, the rich type system can be used to implement an application.

For more detailed configuration of Metainfo of ACDK classes you can also use  acdk_hb_mi_attributes.

 Foreign basic types

Following classes are foreign basic types:
  • 'const' types
  • 'unsigned' types (int, char, short, etc).
  • 'wchar'
  • pointer, including 'const char*'
  • references ('Type& t')

 Functions

Functions, which are not members (static or dynamic) of an ACDK class are foreign types.

 compound types

  • 'struct'
  • 'union'
  • 'class' are foreign, if there are not legal ACDK classes or interfaces.

 Foreign types inside ACDK classes

Legal ACDK classes have members and methods, which has foreign types. Then these members and methods become also foreign.

 Class members


class LegalAcdkClass
: extends ::acdk::lang::Object
{
private:
  MyOtherClass class; // is foreign, because no 'R'Class
  const char* tagname; // foreign, because foreign type
  const RString label; // foreign, because const
};
In same cases ACDK asumes a type as legal ACDK class, it can be marked with keyword foreign:


/* declares the type 'struct RType' */
#include <RType.h>
class LegalAcdkClass
: extends ::acdk::lang::Object
{
private:
  foreign RType type; // is foreign, although 'R'Class
};
The foreign attribute should also be used to mark foreign class/members to avoid warning messages using acdkmc.

 Class methods

A class method becomes foreign if:
  • one argument is foreign
  • the return value is foreign
  • there is a special calling convection like __stdcall
  • the method itself is const
  • one class delcared in the throw() is foreign


class LegalAcdkClass
: extends ::acdk::lang::Object
{
public:
  void doIt(RString name, const std::vector<int>& nums); // foreign because second 
                                                         // argument is foreign
  wchar getWchar(); // foreign because return value is foreign
  __stdcall void externCall(); // foreign because unknown calling convention
  RString getName() const; // foreign because method is const
  void tryCompute() trow (std::exception);
};

Methods can be also marked explicitly as foreign:

class LegalAcdkClass
: extends ::acdk::lang::Object
{
public:
  foreign void foo();
};

 Base classes/interfaces

In case a ACDK class should be derived by a non-ACDK class this should tagged with the foreign keyword.


class LegalAcdkClass
: extends ::acdk::lang::Object
, foreign public MyNotCompatibleBaseClass // foreign marks this base class as foreign class
{
  //...
};