Bug 3514 - Inheriting CORBA::Policy generates uncompilable code.
Summary: Inheriting CORBA::Policy generates uncompilable code.
Status: REOPENED
Alias: None
Product: TAO
Classification: Unclassified
Component: IDL Compiler (show other bugs)
Version: 1.6.6
Hardware: All Linux
: P3 normal
Assignee: Simon McQueen
URL:
Depends on:
Blocks:
 
Reported: 2008-11-17 12:37 CST by Simon McQueen
Modified: 2008-11-18 01:22 CST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon McQueen 2008-11-17 12:37:35 CST
IDL like this:

// $Id: test.idl 83823 2008-11-17 18:03:17Z smcqueen $

#include <orb.idl>

interface Foo : CORBA::Policy
{};

... generates code that fails to compile like this:

In file included from testS.cpp:36:
testS.h:76: error: âPOA_CORBAâ has not been declared
testS.h:76: error: expected `{' before âPolicyâ
testS.h:76: error: function definition does not declare parameters

... can be fixed by doing this:

sm@beatrice:~/doccvs/ACE_wrappers/TAO> svn diff tao/
Index: tao/PolicyS.h
===================================================================
--- tao/PolicyS.h       (revision 83797)
+++ tao/PolicyS.h       (working copy)
@@ -14,6 +14,7 @@
 #ifndef TAO_PIDL_POLICY_S_H
 #define TAO_PIDL_POLICY_S_H
 #include "tao/PolicyC.h"
+#include "tao/PortableServer/PolicyS.h"

 #if !defined (ACE_LACKS_PRAGMA_ONCE)
 # pragma once
Comment 1 Simon McQueen 2008-11-17 12:45:24 CST
Mon Nov 17 18:44:15 UTC 2008  Simon McQueen  <sm@prismtech.com>

        * tao/PolicyS.h:

          Add a #include of tao/PortabServer/PolicyS.h.

        * tests/Bug_3513_Regression/test.cpp:

          Whitespace.

        * tests/Bug_3514_Regression:
        * tests/Bug_3514_Regression/Bug_3514_Regression.mpc:
        * tests/Bug_3514_Regression/README:
        * tests/Bug_3514_Regression/test.idl:
        * tests/Bug_3514_Regression/test.cpp:

          Regression test for the above fix.
Comment 2 Johnny Willemsen 2008-11-17 12:48:50 CST
Simon, this makes the core TAO lib dependent on TAO PortableServer, seems not the correct change.
Comment 3 Johnny Willemsen 2008-11-17 12:50:18 CST
reopening
Comment 4 Simon McQueen 2008-11-17 12:52:32 CST
Nothing includes "tao/PolicyS.h" that I can find by grepping the ORB core. How do you see the dependency occurring ?
Comment 5 Johnny Willemsen 2008-11-17 12:56:04 CST
ok, see your point, this is risky, including files from the portableserver in the core. if somebody does include tao/policys.h he now gets this dependency. 
Comment 6 Johnny Willemsen 2008-11-17 13:02:41 CST
would it be possible to get PolicyS.h pulled in when not wanted, maybe through messaging? when you make the derived interface local probably this compiles then fine without changes? Shouldn't the IDL compiler generate then an additional include when a non local interface is derived? So, not change the code, but handle this in the IDL compiler because this is a side effect of refactoring.
Comment 7 Simon McQueen 2008-11-17 13:11:32 CST
If somebody deliberately includes anything that ends *S.h then they are by definition including a server side header file and should expect to have to link the PortableServer library.

I have built Messaging. It does not include PolicyS.h.

I don't think that there is any risk but if you want to assign this to yourself and do it differently some way then be my guest - as long as my regression test still passes I'll be perfectly happy with anything you come up with. If not then please put the ticket back to fixed. Thanks.
Comment 8 Johnny Willemsen 2008-11-17 13:18:56 CST
(In reply to comment #7)
> If somebody deliberately includes anything that ends *S.h then they are by
> definition including a server side header file and should expect to have to
> link the PortableServer library.
> 
> I have built Messaging. It does not include PolicyS.h.
> 
> I don't think that there is any risk but if you want to assign this to yourself
> and do it differently some way then be my guest - as long as my regression test
> still passes I'll be perfectly happy with anything you come up with. If not
> then please put the ticket back to fixed. Thanks.

I think we shouldn't start this path, including files from sub directories, at the end it could do more harm then it solves now. I think in the past I tried todo the same and got similar remarks as I am making now. 

I think the best change is to make TAO_IDL aware of this, or add portableserver/policy.pidl. I don't have time to test changes, I am just trying to keep the core clean and easy to maintain, as you hopefully can understand. Include other header files just assuming that nobody includes that file maybe works at this moment, but could lead to issues for other users or when other work is done in the near feature.

Also, the PolicyC/S.h files really should go out of the repository, they should be generated by the IDL compiler, not as handcrafted file in the repo. This is one of the last files we have. Your handcrafted addition will then also not work anymore, another reason to solve this in a different way
Comment 9 Simon McQueen 2008-11-17 18:27:04 CST
> I think we shouldn't start this path, including files from sub directories, at
> the end it could do more harm then it solves now. I think in the past I tried
> todo the same and got similar remarks as I am making now. 
> 
> I think the best change is to make TAO_IDL aware of this, or add
> portableserver/policy.pidl. I don't have time to test changes, I am just trying
> to keep the core clean and easy to maintain, as you hopefully can understand.
> Include other header files just assuming that nobody includes that file maybe
> works at this moment, but could lead to issues for other users or when other
> work is done in the near feature.

The problem solved now is that the ORB did not compile spec compliant IDL. I would vote 'ugly and right' over 'pretty and broken' every time in these circumstances if a choice has to be made. If we could have 'pretty and right' that would be best - I understand and agree with you totally - but we both have too busy schedules at the minute for cosmetic changes.

As to what issues might or might not arise in the future, if we think of a problematic use case let's raise an issue now and add a test. It is easier once we have something concrete we can use to justify allocating some more resources.

> Also, the PolicyC/S.h files really should go out of the repository, they should
> be generated by the IDL compiler, not as handcrafted file in the repo. This is
> one of the last files we have. Your handcrafted addition will then also not
> work anymore, another reason to solve this in a different way

The good thing is that as I've added a regression test so we don't need to worry about this. When removing these cruft files gets to the top of someone's priority list then whoever is doing it will have assurance that they have done it in a way that works.
Comment 10 Johnny Willemsen 2008-11-18 01:22:00 CST
(In reply to comment #9)
> The problem solved now is that the ORB did not compile spec compliant IDL. I
> would vote 'ugly and right' over 'pretty and broken' every time in these
> circumstances if a choice has to be made. If we could have 'pretty and right'
> that would be best - I understand and agree with you totally - but we both have
> too busy schedules at the minute for cosmetic changes.

But if we make to many 'ugly and right' patches we do have the risk that future changes will take more and more time and that we get more and more ugly stuff. 

> As to what issues might or might not arise in the future, if we think of a
> problematic use case let's raise an issue now and add a test. It is easier once
> we have something concrete we can use to justify allocating some more
> resources.

Let us keep this ticket open as reminder that we should make a pretty and right change when time permits it. Maybe as last action we should check for any include of tao/PortableServer/PolicyS.h in code in the repo, maybe people have workaround it in the past