[Erlang Systems]

8 Programming Your Own Composit Function in C

8.1 CORBA_Environment Setting

Here is the complete definition of the CORBA_Environment structure, defined in file "ic.h" :

/* Environment definition */
typedef struct {

  /*----- CORBA compatibility part ------------------------*/
  /* Exception tag, initially set to CORBA_NO_EXCEPTION ---*/
  CORBA_exception_type   _major;          

  /*----- External Implementation part - initiated by the user ---*/
  /* File descriptor                                              */
  int                    _fd;             
  /* Size of input buffer                                         */
  int                    _inbufsz;        
  /* Pointer to always dynamically allocated buffer for input     */
  char                  *_inbuf;         
  /* Size of output buffer                                        */
  int                    _outbufsz;       
  /* Pointer to always dynamically allocated buffer for output    */ 
  char                  *_outbuf;        
 /* Size of memory chunks in bytes, used for increasing the outpuy
    buffer, set to >= 32, should be around >= 1024 for performance
    reasons                                                       */ 
 int                    _memchunk;       
 /* Pointer for registered name                                   */
  char                   _regname[256];   
 /* Process identity for caller                                   */
  erlang_pid            *_to_pid;         
  /* Process identity for callee                                  */ 
  erlang_pid            *_from_pid;      

  /*- Internal Implementation part - used by the server/client ---*/
  /* Index for input buffer                                       */
  int                    _iin;            
  /* Index for output buffer                                      */
  int                    _iout;          
  /* Pointer for operation name                                   */
  char                   _operation[256];
   /* Used to count parameters                                    */
  int                    _received;      
  /* Used to identify the caller                                  */
  erlang_pid             _caller;        
 /* Used to identify the call                                     */
  erlang_ref             _unique;         
  /* Exception id field                                           */
  CORBA_char            *_exc_id;        
  /* Exception value field                                        */
   void                  *_exc_value;           

  
} CORBA_Environment; 
      
    

The structure is semantically divided into three areas :

Observe that the advanced user wishing to write own composit functions must have good knowledge of Erl_interface or/and EI-* functions.

8.2 The CORBA Compatibility Area of CORBA_Environment

Contains only one (1) field, the _major which is defined as a CORBA_Exception_type. The CORBA_Exception type is forced to be an integer type due to implementation details and in the current version can be one of :

The current definition of these values look like :

      
#ifndef CORBA_NO_EXCEPTION
#define CORBA_NO_EXCEPTION      0
#endif

#ifndef CORBA_SYSTEM_EXCEPTION
#define CORBA_SYSTEM_EXCEPTION -1
#endif

    

8.3 The External Implementation Area of CORBA_Environment

This area contains nine (9) fields :

8.4 The Internal Implementation Area of CORBA_Environment

This area contains eight (8) fields :

The advanced user who defines his own composit/switch functions has to update/support these values a way similar to the use of these in the generated code.

8.5 Creating and Initiating the CORBA_Environment Structure

There are two ways to set the CORBA_Environment structure :

Note!

Remember to set the fields _fd, _regname, *_to_pid and/or *_from_pid to the appropriate application values. These are not automatically set by the stubs.

Warning!

Never assign static buffers to the buffer pointers. Never set the _memchunk field to a value less than 32.

8.6 Setting System Exceptions

If the advanced user wishes to set own system exceptions at critical positions on the code, it is strongly recommended to use one of the current values :

The value of the _exc_value field should be then set to a string that explains the problem in an informative way. The user should use the functions CORBA_exc_set/4 and CORBA_exception_free/1 to free the exception. The user has to use CORBA_exception_id/1 and CORBA_exception_value/1 to access exception information. Prototypes for these functions are declared in "ic.h"

8.7 Guidlines for the Advanced User:

Here are some guidelines for the composit function programmer:


Copyright © 1991-2003 Ericsson Utvecklings AB