|  | April 2000
| More Information About The Magic Gateway for CORBA Version 8-2 for VisiBroker. |
| Dear Developer, We are happy to introduce The Magic Gateway for CORBA. This version is a bug-fix release for Magic Versions 8.20 and above. We hope you will enjoy working with Magic Version 8.30. |
| Changes in the current release: |  |
8.2 1. Fix of a memory leak.
8.1
1. | The new CORBA gateway does not need an Interface Repository (IR), or an IDL file, when Magic-to-Magic requests are issued. Nevertheless, the CORBA gateway definition (MGSRVR04) should still be defined in the MGREQ.INI so that the gateway can be loaded. Note that the IR may still be defined and used as before. The main difference is that the Magic application server looks for the IR when starting up. If no IR is found, or no IR was defined at all, Magic automatically instantiates one CORBA server object per each defined magic application. For example, if there is an application called APP1, then the CORBA server object is labeled APP1 and is initiated in the application. To make use of the new behavior, do not define the IR settings in the MGREQ.INI file. Also, change the service definitions for the client. The Remote Application definition for a service needs to be changed to: Application_name::Application_Name and not Module_name::Interface_name This change is required because no module and interface definitions are available. If the IR is defined and located at startup, then the former behavior is maintained. The IR is still required in one of this two cases: The Magic engine is used as a server which accepts requests from non-magic CORBA clients. When the Magic engine sends requests to non-Magic CORBA servers.
2. | A support for sending a structure/sequence/array has been added.
The following table describes the conversions that occur when converting from Magic to CORBA. The plus/minus signs (-/+) that appear in the table’s cells indicate whether the conversion is available. The numbers that appear in the cells of the table are references to the remark numbers that are explained below.
Magic à CORBA | Alpha/Memo | Round numeric/ Data/ Time | Fraction numeric | Logical | Blob |  |
Short | + (6),(7) | + (7) | + (7) | + | - |  |
Ushort | + (6) ,(7) | + (7) | + (7) | + | -
Long | + (6) ,(7) | + (7) | + (7) | + | -
Ulong | + (6) ,(7) | + (7) | + (7) | + | -
Float | + (6) ,(7) | + (7) | + (7) | + | -
Double | + (6) ,(7) | + (7) | + (7) | + | -
Boolean | + (6) ,(7) | + (7) | + (7) | + | -
Char | + (6) ,(7) | + (7) | + (7) | + | -
Octet | + (6) ,(7) | + (7) | + (7) | + | -
String | + | + | + | - | -
Sequence <octet/char> | + (3) | + (5) | + (5) | - | + (3)
Other sequences | + (2) | - | - | - | + (2)
Array<octet/char> | + (3) | + (5) | + (5) | - | + (3)
Other Arrays | + (2) | - | - | - | + (2)
Struct | + (1) | - | - | - | + (1)
Objref | + (6),(8) | + (8) | + (8) | - | -
Enum | + (4) | + (4) | + (4) | - | -
Remarks: |
(1) | The Magic programmer needs to enter a value for an Alpha/Memo/Blob Magic variable in a specific format. That variable is later sent as a parameter through the CORBA middle-ware. The CORBA gateway translates the parameter into a CORBA structure as follows: The individual structure items need be inserted into the Magic variable according to their definition order (first one first, and so on). The individual items are saved as strings (for example, the float member type that has a value of 18.87 will be saved as the string "13.87"). The CHR(0) separates one item from the other. For example, the structure struct foo { String str; Long num; String str2; } is saved in the format "first string" & CHR(0) & "120" & CHR(0) & "second str" & CHR(0). If the structure items are a complex type (structure/array or sequence as described below), the process repeats itself, recursively.
(2) | The Magic programmer needs to enter a value for an Alpha/Memo/Blob Magic variable in a specific format. That variable is later sent as a parameter through the CORBA middle-ware. The CORBA gateway translates the parameter into a CORBA sequence/array as follows: First the count of array/sequence cells, are stored inside the Alpha/Memo/Blob variable. Next, the individual cells are stored. As for structures, each cell is stored in its string format, separated from the next one with the CHR(0) character. For example, a CORBA sequence<long> type, which contains 4 cells, is saved as: "4" & CHR(0) & "1" & CHR(0) & "2" & CHR(0) & "3" & CHR(0) & "4" & CHR(0). If the structure/array items are a complex type (a structure/array or sequence as described below), then the process repeats itself, recursively
(3) | The Magic programmer needs to enter a value for an Alpha/Memo/Blob Magic variable in a specific format. That variable is later sent as a parameter through the CORBA middle-ware. The CORBA gateway translates the parameter into a CORBA sequence/array of char/octet items as follows: If a simple Magic Alpha/Memo/Blob variable is translated to a simple sequence/array of octets or chars, then the content of the Magic variable is taken accepted without change, and is translated to CORBA. For example, the string "Hello World" is automatically translated into a sequence/array of characters/octets whose length is 11 (arrays are truncated/filled to match their actual size). If the CORBA sequence/array is a part of a complex type (that is: an item in a structure, a cell in a sequence, or a cell in an array), then the null-terminated cell counter must be a prefix to the sequence/array and the null must be a suffix to the sequence/array. This special requirement is needed to separate the sequence/array content from the content of the following items/cells of the "hosting" complex type.
(4) | Consider the following CORBA Enum type that is defined by using the IDL statement: Enum foo {first, second, last}; A CORBA variable for foo is dual. It may accept numeric values of 0, 1, or 2: where 0=first, 1=second and 2=last. It may also accept string values of ‘first’, ‘second’ and ‘last’. When translating a Magic memo/alpha variable to a CORBA enum, a valid string value must be received (for example, ‘first’ or ‘second’). When translating a Magic number to a CORBA enum, a valid numeric value must be received (for example. "0"or "1").
(5) | It is first converted to a string value, and then from a string value to a sequence/array.
(6) | The string needs to contain a value that can be converted to a number (for example: "1.23" or "3")
(7) |
    Truncation and overflow may occur.
(8) | When explicitly binding a CORBA object (CALL UDP operation for ObjectBind. For more information, see The Magic Guide to Application Partitioning and Client/Server), Magic returns a numeric handle that represents the newly bound object. To pass an object as a CORBA parameter (that is, a CORBA objref type), the user must pass the object’s handle. The CORBA gateway will know how to translate the numeric handle into the actual object. For example, consider a CORBA method that accepts exactly one parameter of objref type. If the Magic user explicitly binds that object, then it has a matching numeric handle. When calling the CORBA method, simply pass one magic number that contains this handle, as a parameter. Note that the reverse is also true. When a new CORBA object is received as a result of a CORBA method, then this object will be given a handle number just as if it was explicitly bound. The Magic user may use this handle to directly invoke methods on behalf of the object or to further pass the object as a parameter to other methods calls.
The following table describes the conversions that occur when converting from Magic to CORBA. The plus/minus signs (-/+) that appear in the table’s cells indicate whether the conversion is available. The numbers that appear in the cells of the table are references to the remark numbers that are explained below.
CORBA à Magic | Alpha/Memo | Round numeric/ Data/Time | Fraction numeric | Logical | Blob |  |
Short | + | + (1) | + (1) | + | - |  |
Ushort | + | + (1) | + (1) | + | -
Long | + | + (1) | + (1) | + | -
Ulong | + | + (1) | + (1) | + | -
Float | + | + (1) | + (1) | + | -
Double | + | + (1) | + (1) | + | -
Boolean | + | + (1) | + (1) | + | -
Char | + | + (1) | + (1) | + | -
Octet | + | + (1) | + (1) | + | -
String | + | + (2) | + (2) | - | -
Sequence <octet/char> | + (3) | + (5) | + (5) | - | + (3)
Other sequences | + (4) | - | - | - | + (4)
Array<octet/char> | + (3) | + (5) | + (5) | - | + (3)
Other Arrays | + (4) | - | - | - | + (4)
Struct | + (4) | - | - | - | + (4)
Objref | + (6) | + (6) | + (6) | - | + (6)
Enum | + (7) | + (8) | + (8) | - | -
Remarks:
(1) | Truncation and overflow may occur.
(2) | The string needs to contain a valid number.
(3) | The sequence/array content is translated without change to the Magic Alpha/Memo/Blob variable.
(4) | The sequence content is flattened into a Magic Alpha/Memo/Blob variable in the following way: First a null-terminated cells counter is written, then each cell’s content is added. The CHR(0) character separates the two consecutive cells. Note that (a) the cell content is converted to string (b) if a cell is a complex type (that is. a structure, array or sequence) the flattening process repeats itself recursively. For example, the sequence<long> parameter that contains the values 100,200 & 300 will be returned to the Magic user as a string/blob/memo variable in the format "3" & CHR(0) & "100" & CHR(0) & "200" & CHR(0) & "300" & CHR(0) An array’s content is flattened in the same way, as a sequence. A structure’s content is flattened one member after another. The member order matches the structure definition (that is first one first, and so on). In this case, no cells counter is needed.
(5) | The sequence/array content represents a valid string number (for example, "123" or "12").
(6) | If not already explicitly bound, the object sent from CORBA is automatically given a numeric handle, just as if it was explicitly bounded by using CALL UDP ObjectBind. That numeric handle is returned to the Magic variable, and may further be used for issuing Call Remote operations like any other object handle.
(7) | The string value of the enum is returned. For more information, see the Magic CORBA Table comments.
(8) | The numeric value of the enum is returned. For more information, see the Magic CORBA Table comments.
| Thank you, The Magic Version 8 Team |