Difference between revisions of "Zh/Documentation/DevGuide/ProUNO/CLI/Additional Structures"

From Apache OpenOffice Wiki
Jump to: navigation, search
(New page: {{Documentation/DevGuide/ProUNOTOC/Zh |ProUNO2c=block |CLIBinding=block |TypeMapCLI=block |ShowPrevNext=block |PrevPage=Zh/Documentation/DevGuide/ProUNO/CLI/Type Mappings |NextPage=Zh/Docu...)
 
 
Line 7: Line 7:
 
|NextPage=Zh/Documentation/DevGuide/ProUNO/CLI/Lifetime Management and Obtaining Interfaces
 
|NextPage=Zh/Documentation/DevGuide/ProUNO/CLI/Lifetime Management and Obtaining Interfaces
 
}}
 
}}
[[en:Documentation/DevGuide/ProUNO/CLI/Additional Structures]]
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/CLI/{{SUBPAGENAME}}}}
 
{{DISPLAYTITLE:附加结构}}
 
{{DISPLAYTITLE:附加结构}}
 
__NOTOC__
 
__NOTOC__

Latest revision as of 03:14, 14 May 2009




是否可以实现完整的类型映射取决于目标环境的功能。在 CLI 中没有对应属性的 UNOIDL 属性将被映射成自定义属性。因此,映射过程中不会丢失信息。可以通过以下方法分析属性:

  • The CLI - UNO 桥
  • 生成源代码文件或文档的工具
  • 使用 CLI 汇编为 UNO 动态提供类型信息的工具。


ExceptionAttribute 属性

uno.ExceptionAttribute 可以应用于接口方法、属性方法(get 或 set)或服务构造函数方法。它包含方法可以抛出哪些异常的相关信息。可以在 cli_ure/source/basetypes/uno/ExceptionAttribute.cs 找到源代码。


OnewayAttribute

uno.OnewayAttribute 应用于 UNOIDL 声明已经应用单向属性的接口方法。可以在 cli_ure/source/basetypes/uno/OnewayAttribute.cs 找到源代码。


BoundPropertyAttribute

uno.BoundPropertyAttribute 应用的属性,其相应的 UNOIDL 声明已经应用了 bount 属性。可以在 cli_ure/source/basetypes/uno/BoundPropertyAttribute.cs 找到源代码。


TypeParametersAttribute

uno.TypeParametersAttribute 应用于多态结构。它在结构的类型列表中保留名称信息。例如,结构名称可以为 com.sun.star.Foo<T, C>。属性则包含以下信息:类型列表中第一个类型的名称为“T”、第二个类型的名称为 “C”。


当 CLI 支持模板且 CLI-UNO 语言绑定使用这些模板时,将不再使用此属性。可以在 cli_ure/source/basetypes/uno/TypeParametersAttribute.cs 找到源代码。


ParameterizedTypeAttribute

uno.ParameterizedTypeAttribute 应用于字段类型已经在类型列表中有所指定的多态结构。例如,结构可以声明为 com.sun.star.Foo<T,C>,成员类型为 “T”。CLI 结构成员的类型将为 System.Object,应用的 ParameterizeTypeAttribute 将声明实际类型为 “T”。


当 CLI 支持模板且 CLI-UNO 语言绑定使用这些模板时,将不再使用此属性。可以在 cli_ure/source/basetypes/uno/ParameterizedTypeAttribute.cs 找到源代码。


TypeArgumentsAttribute

uno.TypeArgumentsAttribute 应用于实例化多态结构。也就是说,当将多态结构用作返回值、参 数或字段时,会出现此属性。它包含类型列表中实际类型的相关信息。例如,函数的参数类型为 com.sun.star.StructFoo<char, long>。CLI 参数的属性包含类型列表,在本例中为 System.Char 和 System.Int32。


当 CLI 支持模板且 CLI-UNO 语言绑定使用这些模板时,将不再使用此属性。可以在 cli_ure/source/basetypes/uno/TypeArgumentsAttribute.cs 找到源代码。


PolymorphicType

uno.PolymorphicType 是由 System.Type 派生的。只要需要多态结构中的类型,就可以使用该属 性。例如:

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


如果调用程序要传送 func1 中多态结构的类型,则它们无法使用 typeof(structname)。相反,必须要创建 uno.PolymorphicType。当 any 包含多态结构时,这种情况同样适用于 func2。如果 UNO 方法返回多态结构的类型,则桥会确保返回 PolymorphicType 而不返回 System.Type。


通过静态函数构造 PolymorphicType:

 public static PolymorphicType GetType(Type type, string name)

函数确保仅存在一个给定的类型和名称组合的实例。


当 CLI 支持模板且 CLI-UNO 语言绑定使用这些模板时,将不再使用此属性。可以在 cli_ure/source/basetypes/uno/PolymorphicType.cs 找到源代码。

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