Bug 132296 - Improve typedef support in generated C++ headers
Summary: Improve typedef support in generated C++ headers
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-21 10:45 UTC by straub
Modified: 2021-10-28 09:05 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description straub 2020-04-21 10:45:34 UTC
cppumaker resolves typedefs in generated header files when defining typedefs in .idl files:
typedef long XLongTypedef
typedef sequence<XLongTypedef> XLongSequenceTypedef
typedef XKeyValue XStructTypedef
typedef sequence<XStructTypedef> XStructSequenceTypedef

generated .hdl files contain:
typedef ::css::uno::Sequence< ::sal_Int32 > XLongSequenceTypedef;
typedef ::css::uno::Sequence< XKeyValue > XStructSequenceTypedef;

It would be better to generate the following, ie. avoid unrolling the typedef:
typedef ::css::uno::Sequence< XongTypedef > XLongSequenceTypedef;
typedef ::css::uno::Sequence< XStructTypedef > XStructSequenceTypedef;

Method declarations could also benefit:
idl: XLongTypedef aMethod([in] XLongSequenceTypedef arg)

currently results in the following .hdl declaration:
::sal_Int32 aMethod(const Sequence<::sal_Int32>& arg)

but this one would be nicer:
XLongTypdef aMethod(const XLongSequenceTypedef& arg)
Comment 1 Stephan Bergmann 2020-08-27 16:11:51 UTC
Why would it be better?  (My assumption would be that the generated .hdl/.hpp files are not looked at much by humans anyway.  But, ultimately, I don't care much either way about this topic.)
Comment 2 Buovjaga 2021-03-31 14:43:52 UTC
(In reply to Stephan Bergmann from comment #1)
> Why would it be better?  (My assumption would be that the generated
> .hdl/.hpp files are not looked at much by humans anyway.  But, ultimately, I
> don't care much either way about this topic.)

Waiting for the reply
Comment 3 QA Administrators 2021-09-28 05:17:16 UTC Comment hidden (obsolete)
Comment 4 Marc-Oliver Straub 2021-10-28 07:57:04 UTC
Not unrolling the typedef would be better since it will improve readability of the calling code.
When using a method using a typedef, an engineer will most likely use the typedef in code that calls such a method, resulting in better self-explaining code:

XLongTypedef result = methodReturningXTypedef() 
instead of 
sal_Int32 result = methodReturningXTypedef()

It all depends on the engineer of course...
Comment 5 Stephan Bergmann 2021-10-28 08:14:35 UTC
(In reply to Marc-Oliver Straub from comment #4)
> Not unrolling the typedef would be better since it will improve readability
> of the calling code.
> When using a method using a typedef, an engineer will most likely use the
> typedef in code that calls such a method, resulting in better
> self-explaining code:
> 
> XLongTypedef result = methodReturningXTypedef() 
> instead of 
> sal_Int32 result = methodReturningXTypedef()

But that's all independent of whether or not the typedef is unrolled in the cppumaker-generated files.
Comment 6 Marc-Oliver Straub 2021-10-28 08:46:33 UTC
I don't think so. When I'm working on C++ code, I rely on the stuff in the headerfiles, not switching to IDL files. If I don't see the typedef in the header file, I'll not use it in my code.
Comment 7 Stephan Bergmann 2021-10-28 09:05:05 UTC
(In reply to Marc-Oliver Straub from comment #6)
> I don't think so. When I'm working on C++ code, I rely on the stuff in the
> headerfiles, not switching to IDL files. If I don't see the typedef in the
> header file, I'll not use it in my code.

As I already wrote in comment 1, "My assumption would be that the generated .hdl/.hpp files are not looked at much by humans anyway.  But, ultimately, I don't care much either way about this topic."  So if anybody wants to change that...