Grouping Definitions in Modules

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 16:14, 23 December 2020 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To avoid name clashes and allow for a better API structure, UNOIDL supports naming scopes. The corresponding instruction is module:

  module mymodule {

Instructions are only known inside the module mymodule for every type defined within the pair of braces of this module {}. Within each module, the type identifiers are unique. This makes an UNOIDL module similar to a Java package or a C++ namespace.

Modules may be nested. The following code shows the interface XUnoUrlResolver contained in the module bridge that is contained in the module star, which is in turn contained in the module sun of the module com.

  module com { module sun { module star { module bridge {
      // interface XUnoUrlResolver in module com::sun::star::bridge
  }; }; }; };

It is customary to write module names in lower case letters. Use your own module hierarchy for your IDL types. To contribute code to, use the org::openoffice namespace or com::sun::star. Discuss the name choice with the leader of the API project on to add to the latter modules. The com::sun::star namespace mirrors the historical roots of in StarOffice and will probably be kept for compatibility purposes.

Types defined in UNOIDL modules have to be referenced using full-type or scoped names, that is, you must enter all modules your type is contained in and separate the modules by the scope operator ::. For instance, to reference XUnoUrlResolver in another idl definition file, write com::sun::star::bridge::XUnoUrlResolver.

Besides, modules have an advantage when it comes to generating language specific files. The tools cppumaker and javamaker automatically create subdirectories for every referenced module, if required. Headers and class definitions are kept in their own folders without any further effort.

One potential source of confusion is that UNOIDL and C++ use “::” to separate the individual identifiers within a name, whereas UNO itself (e.g., in methods like createInstanceWithContext) and Java use “.”.

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