Issue 3701: narrowing of valuetypes (ada-rtf) Source: (, ) Nature: Revision Severity: Minor Summary: Paragraph 5.2.6 of CORBA v2.3.1 specifies that "value type instances may be widened/narrowed to other value types. Each language mapping is responsible for specifying how these operations are made available to the programmer." Ada mapping v1.2 specifies a To_Abstract_Value function to widen a value type to an abstract value type (paragraph 1.10.2.2). The same document reads that concrete value types may be widened to other concrete value types using ada's view conversion (paragraph 1.10.2.3). However, nothing is specified to support narrowing of value types (concrete or abstract) to inheriting concrete value types. Proposed solution: We propose the definition of a To_Value_Ref function in the helper package associated with the value type, with the following signature: function To_Value_Ref (From : in CORBA.Value.Base'Class) return Value_Ref; The semantic of this function would be to cast the object reference passed as a paramater to a reference of the current interface, if it is legal. Otherwise, this function would raise CORBA.Bad_Param. Resolution: Proposed solution: We propose the definition of a To_Value_Ref function in the helper package associated with the value type, with the following signature: function To_Value_Ref (From : in CORBA.Value.Base'Class) return Value_Ref; The semantic of this function would be to cast the object reference passed as a parameter to a reference of the current interface, if it is legal. Otherwise, this function would raise CORBA.Bad_Param. Resolution: Accept as suggested. Revised Text: Add the following as a third bullet in number 3 under section 1.10.2.1: • A narrowing function capable of converting an instance of another Value_Ref type to the target Value_Ref type, if the input Value_Ref refers to an instance of an implementation of the target Value_Ref type or of a more derived type. Replace the fourth paragraph of Section 1.10.2.2: “In order to support widening from concrete value types that may inherit from the abstract value type, the .Helper child package will contain a To_Abstract_Value_Ref function that will widen a reference to any concrete or abstract value that inherits from it to a valid reference of the abstract type. ” with “In order to support widening from other value types that may inherit from the value type, the .Helper child package will contain a To_Value_Ref function that will widen a reference to any concrete or abstract value that inherits from it to a valid reference of the abstract type. ” Insert the following as new Section 4.6.4: 4.6.4 Widening and Narrowing ValueTypes Valuetypes may be related by inheritance. Any abstract valuetype may have any number of abstract parent valuetypes. Any stateful valuetype may have one stateful parent valuetype in addition to any number of abstract parent valuetypes. In order to support type-safe conversion among valuetypes, the helper package will contain a conversion function. The value helper package for each valuetype shall contain the following function: function To_Value_Ref (From : in CORBA.Value.Base'Class) return Value_Ref; The To_Value_Ref function shall return a valuetype of the Value_Ref type if either: • (widening) Any of the parents of the type of From is Value_Ref • (narrowing) The implementation instance referred to by From is either • null or • an implementation of a valuetype that is either Value_Ref or is derived from Value_Ref. Otherwise, it will raise the CORBA.BAD_PARAM exception. Actions taken: June 13, 2000: received issue January 12, 2010: closed issue Discussion: End of Annotations:===== Date: Tue, 13 Jun 2000 11:21:53 -0400 (EDT) Message-Id: <200006131521.LAA20608@emerald.omg.org> From: fabien.azavant@adabroker.eu.org To: juergen@omg.org, web-incoming@omg.org Subject: Issue Report Content-Type: text X-UIDL: I=Be99>,!!i~nd98M To: ada-rtf@omg.org Subject: Proposed Resolution for Date: Fri, 27 Jun 2008 14:19:59 -0400 Cc: Nick Roberts X-Mailer: Apple Mail (2.924) OMG Issue No: 3701 Title: Narrowing of valuetypes Source: École Nationale Supérieure des Télécommunications Fabien Azavant fabien.azavant@adabroker.eu.org Summary: Narrowing of valuetypes. Description: Paragraph 5.2.6 of CORBA v2.3.1 specifies that "value type. instances may be widened/narrowed to other value types. Each language mapping is responsible for specifying how these operations are made available to the programmer." Ada mapping v1.2 specifies a To_Abstract_Value function to widen a value type to an abstract value type (paragraph 1.10.2.2). The same document reads that concrete value types may be widened to other concrete value types using ada's view conversion (paragraph 1.10.2.3). However, nothing is specified to support narrowing of value types (concrete or abstract) to inheriting concrete value types. Proposed solution: We propose the definition of a To_Value_Ref function in the helper package associated with the value type, with the following signature: function To_Value_Ref (From : in CORBA.Value.Base'Class) return Value_Ref; The semantic of this function would be to cast the object reference passed as a parameter to a reference of the current interface, if it is legal. Otherwise, this function would raise CORBA.Bad_Param. Resolution: Accept as suggested. Revised Text: Add the following as a third bullet in number 3 under section 1.10.2.1: A narrowing function capable of converting an instance of another Value_Ref type to the target Value_Ref type, if the input Value_Ref refers to an instance of an implementation of the target Value_Ref type or of a more derived type. Replace the fourth paragraph of Section 1.10.2.2: .In order to support widening from concrete value types that may inherit from the abstract value type, the .Helper child package will contain a To_Abstract_Value_Ref function that will widen a reference to any concrete or abstract value that inherits from it to a valid reference of the abstract type. . with .In order to support widening from other value types that may inherit from the value type, the .Helper child package will contain a To_Value_Ref function that will widen a reference to any concrete or abstract value that inherits from it to a valid reference of the abstract type. . Insert the following as new Section 4.6.4: 4.6.4 Widening and Narrowing ValueTypes Valuetypes may be related by inheritance. Any abstract valuetype may have any number of abstract parent valuetypes. Any stateful valuetype may have one stateful parent valuetype in addition to any number of abstract parent valuetypes. In order to support type-safe conversion among valuetypes, the helper package will contain a conversion function. The value helper package for each valuetype shall contain the following function: function To_Value_Ref (From : in CORBA.Value.Base'Class) return Value_Ref; The To_Value_Ref function shall return a valuetype of the Value_Ref type if either: (widening) Any of the parents of the type of From is Value_Ref (narrowing) The implementation instance referred to by From is either null or an implementation of a valuetype that is either Value_Ref or is derived from Value_Ref. Otherwise, it will raise the CORBA.BAD_PARAM exception. Disposition: Resolved Victor Giddings victor_giddings@omg.org submit: Submit Issue Report