[antlr-interest] Offtopic - Re: Autiomatic header file generation for C/C++??

Sam Harwell sam at tunnelvisionlabs.com
Thu Mar 22 15:46:11 PDT 2012


I did it by treating the first base class as the "primary" base class for
class-to-class casts. Casts involving a type that's not a primary class are
performed as interface casts which are slightly slower.

The system didn't allow instance data members to be stored in anything but a
primary base class. The restriction didn't feel like a limitation at all,
especially considering the advantages that came from the other features.

--
Sam Harwell
Owner, Lead Developer
http://tunnelvisionlabs.com

-----Original Message-----
From: Jan Finis [mailto:finis at in.tum.de] 
Sent: Thursday, March 22, 2012 4:54 PM
To: Sam Harwell
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Offtopic - Re: Autiomatic header file
generation for C/C++??

can you tell me how to do a constant time instanceof with multiple
inheritance? That was always a mystery for me. Or do you keep the whole
transitive closure of the supertype relation in a bit set or something?

Am 22.03.2012 16:29, schrieb Sam Harwell:
> Hi Ivan,
>
> As part of an experiment several years ago, I created a project where 
> the basic interface of all primary classes was specified in an 
> intermediate language. I used a tool to generate the C++ header files 
> for one particular
> reason: I wanted the headers to prefer forward declarations to 
> #include statements absolutely wherever possible. The result was one 
> of the fastest compiling (reasonably large) C++ projects I've ever 
> worked on - we're talking approach plain C speed. I wouldn't ever 
> expect a developer to be able to maintain the accuracy of this separation
manually.
>
> To handle inline functions which are normally placed in the header, if 
> one or more functions was marked inline in the intermediate language 
> then the declaration in the header was marked inline and it emitted a 
> line like this at the end of the header:
>
> #include "HeaderName.inl"
>
> The generated code had a number of other features not normally 
> possible in hand-written code:
>
> 1. The classes had the construction semantics of languages like C# and 
> Java
>
> 1a. The vtable was fully initialized for the derived class before user 
> code in the base constructor executed.
>
> 1b. All fields were initialized to default values when the class was 
> constructed (the intermediate language allowed overriding this value).
>
> 2. The classes supported constant-time (3 inline assembly instructions 
> on
> x86) class-to-class dynamic cast (we're talking instanceof here, not 
> type equality).
>
>
> --
> Sam Harwell
> Owner, Lead Developer
> http://tunnelvisionlabs.com
>
>
> -----Original Message-----
> From: Ivan Brezina [mailto:ibre5041 at ibrezina.net]
> Sent: Thursday, March 22, 2012 4:12 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Offtopic - Re: Autiomatic header file 
> generation for C/C++??
>
> Hi,
> I have to warn you, that generally your request is nonsense and no 
> tool can fulfill it.
> 1. header file is something like an interface, you usually design is 
> before the .cpp file 2. the header file and .cpp file both include 
> other headers and in most cases the header's headers are only subset on
the .cpp ones.
> This is fundamental problem.
> You do not want mix "interface" dependencies with "implementation"
> dependencies.
> 3. You usually do not want all the implementation internals to be 
> exported the header.
> The tool would have to support some kind of blacklisting.
> 4. It is very hard to guarantee that the generated headers are 
> "correct" and compileable.
> For example imagine two classes cyclically dependent. Implementation 
> of class A depends on B.hpp and viceversa. The tool can simply 
> generate headers with the infinite inclusion recursion.
> 5. It is also not easy to order the content of the header file.
> Imagine that you have
> some types declared via preprocessor macros.
>
> Ivan
>
>
> Quoting "Voelkel, Andy"<andy.voelkel at plantronics.com>:
>
>> Hi,
>>
>> I took a look a more detailed look at that and lzz. I prefer the 
>> approach of makeheaders - unfortunately it is old enough that it does 
>> not understand namespaces. Still, for a project that does not need 
>> namespaces, it might just work.
>>
>> I find it AMAZING that C/C++ programmers put up with the hassle of 
>> manual header file maintenance, and that no other tool seems to be in 
>> widespread use.  Last time I checked it was 2012, not 1985.
>>
>>
>> -          Andy
>>
>> From: Eric [mailto:researcher0x00 at gmail.com]
>> Sent: Tuesday, March 20, 2012 5:00 PM
>> To: Voelkel, Andy
>> Cc: antlr-interest at antlr.org
>> Subject: Re: [antlr-interest] Autiomatic header file generation for
> C/C++??
>> Hi Andy,
>>
>> FWIW I did a quick search and found makeheaders.
>>
>> Eric
>> On Tue, Mar 20, 2012 at 7:49 PM, Voelkel, Andy 
>> <andy.voelkel at plantronics.com<mailto:andy.voelkel at plantronics.com>>
>> wrote:
>> Hi,
>>
>> Does anyone know of any tools for generating C/C++ header files 
>> automatically from an annotated version of the C/C++ source files? I 
>> really hate writing and maintaining header files in C/C++.
>>
>> This isn't strictly related to Antlr, other than the fact that Antlr 
>> would be a logical front end for such a tool. But I thought that the 
>> same types that hang out in Antlr-land might know about such things.
>>
>>
>> -          Andy
>>
>> ________________________________
>>
>> CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents,
>>   files or previous e-mail messages attached to it, may contain 
>> information that is confidential and/or legally privileged. If you 
>> are not the intended recipient, or a person responsible for 
>> delivering it to the intended recipient, please DO NOT disclose the 
>> contents to another person, store or copy the information in any 
>> medium, or use any of the information contained in or attached to 
>> this transmission for any purpose. If you have received this 
>> transmission in error, please immediately notify the sender by reply 
>> email or at privacy at plantronics.com<mailto:privacy at plantronics.com>,
>> and
>> destroy the original transmission and its attachments without reading 
>> or saving in any manner.
>>
>> For further information about Plantronics - the Company, its 
>> products, brands, partners, please visit our website 
>> www.plantronics.com<http://www.plantronics.com>.
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-addres
>> s
>>
>>
>> ________________________________
>>
>> CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents,
>>   files or previous e-mail messages attached to it, may contain 
>> information that is confidential and/or legally privileged. If you 
>> are not the intended recipient, or a person responsible for 
>> delivering it to the intended recipient, please DO NOT disclose the 
>> contents to another person, store or copy the information in any 
>> medium, or use any of the information contained in or attached to 
>> this transmission for any purpose. If you have received this 
>> transmission in error, please immediately notify the sender by reply
>>   email or at privacy at plantronics.com, and destroy the original 
>> transmission and its attachments without reading or saving in any 
>> manner.
>>
>> For further information about Plantronics - the Company, its 
>> products, brands, partners, please visit our website 
>> www.plantronics.com.
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-addres
>> s
>>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list