Additional Structures

From Apache OpenOffice Wiki
Jump to: navigation, search



Whether a complete type mapping can be achieved depends on the capabilities of a target environment. UNOIDL attributes which have no counterpart in the CLI are mapped to custom attributes. Hence no information becomes lost in the mapping. The attributes can be evaluated by:

  • The CLI - UNO bridge
  • Tools that generated source code files or documentation
  • Tools that use CLI assemblies to dynamically provide type information to UNO.

ExceptionAttribute Attribute

The uno.ExceptionAttribute can be applied to interface methods, property methods (get or set) or service constructor methods. It contains the information about what exceptions can be thrown by the method. The source code can be found at cli_ure/source/basetypes/uno/ExceptionAttribute.cs.

OnewayAttribute

The uno.OnewayAttribute is applied to those interface methods that UNOIDL declarations have tapplied he oneway attribute to. The source code can be found at cli_ure/source/basetypes/uno/OnewayAttribute.cs.

BoundPropertyAttribute

The uno.BoundPropertyAttribute is applied to properties whose respective UNOIDL declarations have the bount attibute applied to it. The source code can be found at cli_ure/source/basetypes/uno/BoundPropertyAttribute.cs.

TypeParametersAttribute

The uno.TypeParametersAttribute is applied to polymorphic structs. It keeps the information of the names in the type list of the struct. For example, a struct may be named com.sun.star.Foo<T, C>. Then the attribute containes the information, that the name of the first type in the type list is “T” and the second is “C”.

This attribute will become obsolete when the CLI supports templates and the CLI-UNO language binding has adopted them. The source code can be found at cli_ure/source/basetypes/uno/TypeParametersAttribute.cs.

ParameterizedTypeAttribute

The uno.ParameterizedTypeAttribute is applied to fields of polymorphic structs whose type is specified in the type list. For example, the struct may be declared as com.sun.star.Foo<T,C> and member is of type “T”. The member of the CLI struct would then be of type System.Object and the applied ParameterizeTypeAttribute would declare that the actual type is “T”.

This attribute will become obsolete when the CLI supports templates and the CLI-UNO language binding has adopted them. The source code can be found at cli_ure/source/basetypes/uno/ParameterizedTypeAttribute.cs.

TypeArgumentsAttribute

The uno.TypeArgumentsAttribute is applied to instantiations of the polymorphic struct. That is, it appears when a polymorphic struct is used as return value, parameter or field. It contains the information about the actual types in the type list. For example, a function has a parameter of type com.sun.star.StructFoo<char, long>. Then the CLI parameter has the attribute which contains the list of types, in this case System.Char and System.Int32.

This attribute will become obsolete when the CLI supports templates and the CLI-UNO language binding has adopted them. The source code can be found at cli_ure/source/basetypes/uno/TypeArgumentsAttribute.cs.

PolymorphicType

The uno.PolymorphicType is derived from System.Type. It is used whenever a type from a polymorphic struct is needed. For example:

  //UNOIDL
  void func1([in] type t);
  void func2([in]any a);
  type func3();
  any func4();

If the caller intends to pass the type of polymorphic struct in func1, then they cannot use typeof(structname). Instead, a uno.PolymorphicType must be created. The same goes for func2, when the any contains a polymorphic struct. If a UNO method returns the type of polymorphic struct, then the bridge ensures that a PolymorphicType is returned rather than System.Type.

The PolymorphicType is constructed by a static function:

 public static PolymorphicType GetType(Type type, string name)

The function ensures that there exist only one instance for the given combination of type and name.

This attribute will become obsolete when the CLI supports templates and the CLI-UNO language binding has adopted them. The source code can be found at cli_ure/source/basetypes/uno/PolymorphicType.cs.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages