Left Up Corbascript

Implementing the fixed-types in Corbascript with MICO

Motivation

I think, a important reason old language like COBOL and RPG are still used is that they have the fixed-Type.
Nowerdays, we want to have CORBA-Interfaces on old legacy-Mainframe-Code (for business/economic-Applications).
What is CORBA without CORBASCRIPT as Scripting Language ? So we need to support the fixed-Type !

General Conciderations and Questions

In Business/Economic-Application we need to What can other Implementations (COBOL ?) ?

An other may be numeric-Calculations, when there is a need for exact precission.

Semantics

f1 is a fixed<d1,s1> and f2 is a fixed<d2,s2>
Addition, Subtraction
fe=f1+f2 is then a fixed<max(d1,d2),max(s1,s2));
Multiplication
fe=f2*f3 is then a fixed<d1+d2,s1+s2>

When writing in polyadic Notation, and multiplicate out, one sees, the higest Potenz is (d1-s1)+(d2-s2) and the lowest (-s1-s2), so new scale is s1+s2 and the length is d+s=(d1+d2-s1-s1+s1+s2)=d1+d2.
Example: 0.1*0.1 = 0.01

Divison
I think, that it is impossible, to precalc a type, because 1.0/7.0 is a periodic Decimal-Fractal.

So I take the type of the first operand.

General things in the CORBA-Standard

Chaper 9 of the ORB-Core Specification:
In 9.2.4 DynFixed-Interface : In Corba there is no generic type that can represent fixed type with arbitrary numbers of digit and scale, so the operation use the IDL string type
Chapter 1.11 Mapping for the Fixed-Types
There is a class Fixed defined and this a good basis for CORBA-Script

Because this, we suggest a Operation to get the Value directly, and define a HAVE_FIXED_VALUE_DIRECTLY in Corbatools, if a orb has this.

Protocol handling
in the Mico-Implementation (and surely in other Implementaions too) there is a parameterindependent get_fixed too.
So DynamicAny::DynFixed should have in C/C++-Implemenations the Operations get_fixed and set_fixed.

Usage

The fixed-Value can be used like any other Type. There are coersion-Operations to and from CS_Double and CS_String.
The Constructor can have one, two or three arguments:
CORBA.fixed(value)
converts the value to fixed.
CORBA.fixed(digits,scale)
Makes a fixed with digits and scale
CORBA.fixed(digits,scale,value)
combination of both.

Enhanced Headers and Moduls

The following Modules are new:
cs_CorbaFixedValue.h
Implements the CorbaScript-Fixed
cs_fixed_impl.h
Declaration of the fixed type, now it is the extraction of the MICO-Implementation

Special Remarks

In mico/typecode.h is a Typecode_ptr create_tc_fixed(UShort digits,Short scale). So is no _tc_fixed because it has type-Parameters
in cs_interpreter.cpp
Because fixed-Values with different Precissions are the same kind, but different typecodes, the Constructor is registered.

Critique

Many modules had to be changed. The classes like ProcessSmartDynany seems to be a visitor-Designpattern.
Perhaps a double-dispatch, so that a function is selected after two or more parameter would be good an could save a lot of work.

To Do

In my additions it is needed to see after the abstractions of the orbs.
Informatik- und Netzwerkverein Ravensburg e.V Rudolf Weber