Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Creating a dynamic module

To create a dynamic module, follow these steps:

  • Identify the objects based on functionality, and allocate ClassIDs.
  • Identify the interfaces, and either re-use or inherit existing interfaces, or define new interfaces and allocate interface IDs.
  • Determine the host process for each class. Some objects live in the user process with the caller, others may be allocated to the kernel process. For objects that live in a remote server process, allocate service IDs.
  • Identify privileges to access the objects and services.
  • Compose interface headers using the IDL compiler. Write test code, using the component test framework (CTF).
  • Write CIF files and implement objects. If any of the objects are remotable, stubs and skeletons need to implemented. Use IDL (interface definition language) to define remotable interfaces.
  • To build a module in its simplest form, the required items are:
    • A MIF file.
    • C code, including a CIF and a makefile. A class must be declared in the code.
    • Libraries for linking.

For more information on IDL and the QIDL compiler, see the QIDL Reference and the Tools Referencein http://developer.brewmp.com/resources on the Brew MP website.

Building a module

  1. Generate MIF and .c files using the cifc.exe tool.

    The .c file generated by cifc.exe associates the ClassID with the New function for the module. The MIF contains resources such as strings and images.

    For example, this is the Class definition from the SimpleIOEcho.cif file in the samplecode\c_service directory in the Brew MP SDK:
    Class {
       classid = AEECLSID_SimpleIOEcho,
       newfunc = SimpleIOEcho_New
    };
    

    The following shows an example of the c_service_CIFS_d.c file generated by cifc.exe after running the make myinstall command for the c_service example in the samplecode\c_service directory in the Brew MP SDK:

    #include "AEEStdErr.h"
    #include "AEEIEnv.h"
    #include "AEEIPrivSet.h"
    #include "AEEIRemoteInterface.h"
    typedef int RemoteStubNewFunc(IEnv*, IRemoteObject*, IQI**);
    typedef int RemoteSkelNewFunc(IEnv*, IQI*, IRemoteSkel**);
    extern int RemoteInterface_New(IEnv*, RemoteStubNewFunc*, RemoteSkelNewFunc*,
             void**);
    
    extern int Service_NewPrivs(IEnv *piEnv, AEECLSID cls, IPrivSet *piPrivSet,
             void **ppif);
    extern int SimpleIOEcho_New(IEnv *piEnv, AEECLSID cls, void **ppif);
    extern int ISimpleIOStub_New(IEnv *_piEnv, IRemoteObject *_piro, IQI **_ppif);
    extern int ISimpleIOSkel_New(IEnv *_piEnv, IQI *_piObj, IRemoteSkel **_ppif);
    
    
    
    static int c_serviceModCreateInstance(IEnv* piEnv, AEECLSID cls,
             IPrivSet* piPrivSet, void** ppif)
    {
       switch (cls) {
          case 0x1046f24:
             {
                return Service_NewPrivs(piEnv, cls, piPrivSet, ppif);
             }
    
          case 0x1046f23:
             {
                return SimpleIOEcho_New(piEnv, cls, ppif);
             }
    
          case 0x1046f22:
             {
                return RemoteInterface_New(piEnv, ISimpleIOStub_New,
                         ISimpleIOSkel_New, ppif);
             }
    
       }
    
       return AEE_ECLASSNOTSUPPORT;
    }
    
    
    #include "AEEmod.h"
    
    #ifdef _MSC_VER
    __declspec(dllexport)
    #endif
    int IMod_New(IEnv *piEnv, AEEIID iid, void** ppiModOut)
    {
       return mod_NewIMod(piEnv, iid, ppiModOut, c_serviceModCreateInstance);
    }
  2. Run the make command to create the module.

    A Makefile using the OS Services make.d build system specifies which module to build, and which libraries and source files must be compiled and linked together to construct the module. The OS Services build system automatically compiles the IDL files, CIF files, and C/C++ source files, and then links the libraries and .o files into a loadable module. The makefile generates either a .dll1 or .elf file, depending on the target. For a makefile example, see the makefile in the samplecode\c_service directory in the Brew MP SDK.