Kaydet (Commit) fc54915c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Replace reg2unoidl with unoidl-write

...that can also generate an .rdb containing a specific set of entities,
intended to replace idlc (when reading directly from .idl source registries).

Change-Id: I630ce4640828979d7952dc24dbbef80a42a8140a
üst 95e566b9
...@@ -48,7 +48,6 @@ $(eval $(call gb_Helper_register_executables,NONE, \ ...@@ -48,7 +48,6 @@ $(eval $(call gb_Helper_register_executables,NONE, \
pdfunzip \ pdfunzip \
pocheck \ pocheck \
propex \ propex \
reg2unoidl \
regsvrex \ regsvrex \
rsc \ rsc \
saxparser \ saxparser \
...@@ -60,6 +59,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ ...@@ -60,6 +59,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
treex \ treex \
uiex \ uiex \
ulfex \ ulfex \
unoidl-write \
xrmex \ xrmex \
)) ))
......
...@@ -850,11 +850,11 @@ gb_BUILD_HELPER_LIBS := basegfx \ ...@@ -850,11 +850,11 @@ gb_BUILD_HELPER_LIBS := basegfx \
gb_BUILD_HELPER_TOOLS := cppumaker \ gb_BUILD_HELPER_TOOLS := cppumaker \
idlc \ idlc \
reg2unoidl \
regcompare \ regcompare \
regmerge \ regmerge \
rsc \ rsc \
svidl svidl \
unoidl-write \
define gb_LinkTarget__is_build_lib define gb_LinkTarget__is_build_lib
$(if $(filter $(1),$(foreach lib,$(gb_BUILD_HELPER_LIBS),$(call gb_Library_get_linktargetname,$(lib)))),$(true),$(false)) $(if $(filter $(1),$(foreach lib,$(gb_BUILD_HELPER_LIBS),$(call gb_Library_get_linktargetname,$(lib)))),$(true),$(false))
......
...@@ -80,7 +80,7 @@ endif ...@@ -80,7 +80,7 @@ endif
gb_UnoApiTarget_REGCOMPAREDEPS := $(call gb_Executable_get_runtime_dependencies,regcompare) gb_UnoApiTarget_REGCOMPAREDEPS := $(call gb_Executable_get_runtime_dependencies,regcompare)
gb_UnoApiTarget_REGCOMPARECOMMAND := SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(call gb_Executable_get_command,regcompare) gb_UnoApiTarget_REGCOMPARECOMMAND := SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(call gb_Executable_get_command,regcompare)
gb_UnoApiTarget_REGMERGEDEPS := $(call gb_Executable_get_runtime_dependencies,regmerge) $(call gb_Executable_get_runtime_dependencies,reg2unoidl) gb_UnoApiTarget_REGMERGEDEPS := $(call gb_Executable_get_runtime_dependencies,regmerge) $(call gb_Executable_get_runtime_dependencies,unoidl-write)
gb_UnoApiTarget_REGMERGECOMMAND := SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(call gb_Executable_get_command,regmerge) gb_UnoApiTarget_REGMERGECOMMAND := SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin $(call gb_Executable_get_command,regmerge)
gb_UnoApiTarget_TYPESRDB := $(call gb_UnoApiTarget_get_target,types) gb_UnoApiTarget_TYPESRDB := $(call gb_UnoApiTarget_get_target,types)
...@@ -90,7 +90,7 @@ RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,$(1).oldformat $(2) $(3)) ...@@ -90,7 +90,7 @@ RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,$(1).oldformat $(2) $(3))
$(gb_UnoApiTarget_REGMERGECOMMAND) @$${RESPONSEFILE} && \ $(gb_UnoApiTarget_REGMERGECOMMAND) @$${RESPONSEFILE} && \
rm -f $${RESPONSEFILE} && \ rm -f $${RESPONSEFILE} && \
SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin \ SOLARBINDIR=$(OUTDIR_FOR_BUILD)/bin \
$(call gb_Executable_get_command,reg2unoidl) \ $(call gb_Executable_get_command,unoidl-write) \
$(foreach rdb,$(4),$(call gb_UnoApiTarget_get_target,$(rdb))) \ $(foreach rdb,$(4),$(call gb_UnoApiTarget_get_target,$(rdb))) \
$(1).oldformat $(1) $(1).oldformat $(1)
endef endef
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
# #
$(eval $(call gb_Executable_Executable,reg2unoidl)) $(eval $(call gb_Executable_Executable,unoidl-write))
$(eval $(call gb_Executable_add_exception_objects,reg2unoidl, \ $(eval $(call gb_Executable_add_exception_objects,unoidl-write, \
unoidl/source/reg2unoidl \ unoidl/source/unoidl-write \
)) ))
$(eval $(call gb_Executable_use_libraries,reg2unoidl, \ $(eval $(call gb_Executable_use_libraries,unoidl-write, \
sal \ sal \
salhelper \ salhelper \
unoidl \ unoidl \
......
...@@ -14,7 +14,7 @@ $(eval $(call gb_Module_add_targets,unoidl, \ ...@@ -14,7 +14,7 @@ $(eval $(call gb_Module_add_targets,unoidl, \
)) ))
$(eval $(call gb_Module_add_targets_for_build,unoidl, \ $(eval $(call gb_Module_add_targets_for_build,unoidl, \
Executable_reg2unoidl \ Executable_unoidl-write \
)) ))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -8,16 +8,16 @@ for both the new and the old types.rdb formats (unoidl::loadProvider tries both ...@@ -8,16 +8,16 @@ for both the new and the old types.rdb formats (unoidl::loadProvider tries both
implementations in turn for a given file, so the old format is still supported implementations in turn for a given file, so the old format is still supported
transparently for now). transparently for now).
Executable_reg2unoidl is a helper tool to convert from the old to the new Executable_unoidl-write is a helper tool to convert from the old to the new
types.rdb format. It is currently used at build-time. idlc still generates the types.rdb format. It is currently used at build-time. idlc still generates the
old format, and any new-format files (used at build-time only, or included in old format, and any new-format files (used at build-time only, or included in
installation sets in URE or program/types/ or as part of bundled extensions that installation sets in URE or program/types/ or as part of bundled extensions that
are created during the build and not merely included as pre-built .oxt files) are created during the build and not merely included as pre-built .oxt files)
are explicitly generated via reg2unoidl. The SDK is still designed to generate are explicitly generated via unoidl-write. The SDK is still designed to
old-format files exclusively (especially, any non-bundled extensions will only generate old-format files exclusively (especially, any non-bundled extensions
contain old-format files for now; that allows to modify the new format further will only contain old-format files for now; that allows to modify the new format
without having to worry about compatibility with multiple versions of that further without having to worry about compatibility with multiple versions of
format). that format).
== Specification of the new UNOIDL types.rdb format == == Specification of the new UNOIDL types.rdb format ==
...@@ -56,7 +56,7 @@ The following definitions are used throughout: ...@@ -56,7 +56,7 @@ The following definitions are used throughout:
* Map: zero or more Entries * Map: zero or more Entries
The file starts with an 8 byte header, followed by information about the root The file starts with an 8 byte header, followed by information about the root
map (reg2unoidl generates files in a single depth-first pass, so the root map map (unoidl-write generates files in a single depth-first pass, so the root map
itself is at the end of the file): itself is at the end of the file):
* 7 byte magic header "UNOIDL\xFF" * 7 byte magic header "UNOIDL\xFF"
...@@ -65,11 +65,12 @@ itself is at the end of the file): ...@@ -65,11 +65,12 @@ itself is at the end of the file):
* UInt32 number of entries of root Map * UInt32 number of entries of root Map
... ...
Files generated by reg2unoidl follow that by a Files generated by unoidl-write follow that by a
"\0** Created by LibreOffice " LIBO_VERSION_DOTTED " reg2unoidl **\0" "\0** Created by LibreOffice " LIBO_VERSION_DOTTED " unoidl-write **\0"
banner (cf. config_host/config_version.h.in), as a debugging aid. banner (cf. config_host/config_version.h.in), as a debugging aid. (Old versions
used "reg2unoidl" instead of "unoidl-write" in that banner.)
Layout of per-entry payload in the root or a module Map: Layout of per-entry payload in the root or a module Map:
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <new> #include <new>
#include "osl/file.h" #include "osl/file.h"
#include "osl/file.hxx"
#include "osl/thread.h" #include "osl/thread.h"
#include "rtl/character.hxx" #include "rtl/character.hxx"
#include "rtl/ref.hxx" #include "rtl/ref.hxx"
...@@ -86,6 +87,20 @@ private: ...@@ -86,6 +87,20 @@ private:
{ return rtl::Reference<Entity>(); } //TODO { return rtl::Reference<Entity>(); } //TODO
}; };
class SourceModuleEntity: public ModuleEntity {
public:
SourceModuleEntity() {}
private:
virtual ~SourceModuleEntity() throw () {}
virtual std::vector<OUString> getMemberNames() const
{ return std::vector<OUString>(); } //TODO
virtual rtl::Reference< MapCursor > createCursor() const
{ return new Cursor; }
};
} }
SourceProvider::SourceProvider( SourceProvider::SourceProvider(
...@@ -147,53 +162,67 @@ rtl::Reference<Entity> SourceProvider::findEntity(OUString const & name) const { ...@@ -147,53 +162,67 @@ rtl::Reference<Entity> SourceProvider::findEntity(OUString const & name) const {
throw FileFormatException( //TODO throw FileFormatException( //TODO
"", "Illegal UNOIDL identifier \"" + name + "\""); "", "Illegal UNOIDL identifier \"" + name + "\"");
} }
OUString uri(uri_ + buf.makeStringAndClear() + ".idl"); OUString uri(uri_ + buf.makeStringAndClear());
oslFileHandle handle;
oslFileError e = osl_openFile(uri.pData, &handle, osl_File_OpenFlag_Read);
switch (e) {
case osl_File_E_None:
break;
case osl_File_E_NOENT:
cache_.insert(
std::map< OUString, rtl::Reference<Entity> >::value_type(
name, rtl::Reference<Entity>()));
return rtl::Reference<Entity>();
default:
throw FileFormatException(uri, "cannot open: " + OUString::number(e));
}
sal_uInt64 size;
e = osl_getFileSize(handle, &size);
if (e != osl_File_E_None) {
oslFileError e2 = osl_closeFile(handle);
SAL_WARN_IF(
e2 != osl_File_E_None, "unoidl",
"cannot close " << uri << ": " << +e2);
throw FileFormatException(
uri, "cannot get size: " + OUString::number(e));
}
void * address;
e = osl_mapFile(handle, &address, size, 0, osl_File_MapFlag_RandomAccess);
if (e != osl_File_E_None) {
oslFileError e2 = osl_closeFile(handle);
SAL_WARN_IF(
e2 != osl_File_E_None, "unoidl",
"cannot close " << uri << ": " << +e2);
throw FileFormatException(uri, "cannot mmap: " + OUString::number(e));
}
rtl::Reference<Entity> ent; rtl::Reference<Entity> ent;
try { osl::DirectoryItem item;
ent = parse(manager_, name, uri, address, size); osl::FileStatus status(osl_FileStatus_Mask_Type);
} catch (...) { if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None
&& item.getFileStatus(status) == osl::FileBase::E_None
&& status.getFileType() == osl::FileStatus::Directory)
{
ent = new SourceModuleEntity;
} else {
uri += ".idl";
oslFileHandle handle;
oslFileError e = osl_openFile(
uri.pData, &handle, osl_File_OpenFlag_Read);
switch (e) {
case osl_File_E_None:
break;
case osl_File_E_NOENT:
cache_.insert(
std::map< OUString, rtl::Reference<Entity> >::value_type(
name, rtl::Reference<Entity>()));
return rtl::Reference<Entity>();
default:
throw FileFormatException(
uri, "cannot open: " + OUString::number(e));
}
sal_uInt64 size;
e = osl_getFileSize(handle, &size);
if (e != osl_File_E_None) {
oslFileError e2 = osl_closeFile(handle);
SAL_WARN_IF(
e2 != osl_File_E_None, "unoidl",
"cannot close " << uri << ": " << +e2);
throw FileFormatException(
uri, "cannot get size: " + OUString::number(e));
}
void * address;
e = osl_mapFile(
handle, &address, size, 0, osl_File_MapFlag_RandomAccess);
if (e != osl_File_E_None) {
oslFileError e2 = osl_closeFile(handle);
SAL_WARN_IF(
e2 != osl_File_E_None, "unoidl",
"cannot close " << uri << ": " << +e2);
throw FileFormatException(
uri, "cannot mmap: " + OUString::number(e));
}
try {
ent = parse(manager_, name, uri, address, size);
} catch (...) {
e = osl_unmapMappedFile(handle, address, size);
SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot unmap: " << +e);
e = osl_closeFile(handle);
SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot close: " << +e);
throw;
}
e = osl_unmapMappedFile(handle, address, size); e = osl_unmapMappedFile(handle, address, size);
SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot unmap: " << +e); SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot unmap: " << +e);
e = osl_closeFile(handle); e = osl_closeFile(handle);
SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot close: " << +e); SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot close: " << +e);
throw;
} }
e = osl_unmapMappedFile(handle, address, size);
SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot unmap: " << +e);
e = osl_closeFile(handle);
SAL_WARN_IF(e != osl_File_E_None, "unoidl", "cannot close: " << +e);
cache_.insert( cache_.insert(
std::map< OUString, rtl::Reference<Entity> >::value_type(name, ent)); std::map< OUString, rtl::Reference<Entity> >::value_type(name, ent));
return ent; return ent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment