Henning Thielemann | 1 Aug 11:46 2006
Picon

Formatting of source code (Was: Ada language module for SWIG)


> Date: Mon, 31 Jul 2006 21:21:01 +0100
> From: William S Fulton <wsf <at> fultondesigns.co.uk>
> Subject: Re: [Swig-devel] Ada language module for SWIG
> To: rod <rodkay <at> mullum.com.au>
> Cc: William S Fulton <wsf <at> fultondesigns.co.uk>,
> 	swig-devel <at> lists.sourceforge.net
> Message-ID: <44CE662D.2030302 <at> fultondesigns.co.uk>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> >> Code gets copied and pasted a lot between various modules so please
> >> follow the same style otherwise a dogs dinner will ensue, eg curly brace
> >> positioning, tab size, 2 space indenting etc. Extra vertical space ssems
> >> okay. My particular preference is not for the style that is used in
> >> SWIG, but I'm not so arrogant to impose my own style on the code I
> >> maintain. Keeping the variable names the same as other modules will also
> >> help a lot, eg Node *n, String *tm if you aren't already doing that.
> > 
> >    Ok, I'll re-format the code to follow SWIG style.
> > 
> Cool, it will help everyone long term.

Maybe I already noted that: I prefer having some code formatting tool
rather than trying to manually format the sources appropriately to the
projects I'm involved. What about specifying the options for 'indent' that
make the code look like it is prefered for SWIG?

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
(Continue reading)

Henning Thielemann | 1 Aug 13:17 2006
Picon

Re: Ada language module for SWIG


Btw. I like to hear your opinion about the typemaps I introduced for
Modula-3, the handling of enumerations, preserving naming conventions of
the target language and all the problems I describe in the Modula-3 part
of the SWIG documentation.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
William S Fulton | 1 Aug 23:40 2006
Picon

Re: Formatting of source code (Was: Ada language module for SWIG)

Henning Thielemann wrote:
>> Date: Mon, 31 Jul 2006 21:21:01 +0100
>> From: William S Fulton <wsf <at> fultondesigns.co.uk>
>> Subject: Re: [Swig-devel] Ada language module for SWIG
>> To: rod <rodkay <at> mullum.com.au>
>> Cc: William S Fulton <wsf <at> fultondesigns.co.uk>,
>> 	swig-devel <at> lists.sourceforge.net
>> Message-ID: <44CE662D.2030302 <at> fultondesigns.co.uk>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>>>> Code gets copied and pasted a lot between various modules so please
>>>> follow the same style otherwise a dogs dinner will ensue, eg curly brace
>>>> positioning, tab size, 2 space indenting etc. Extra vertical space ssems
>>>> okay. My particular preference is not for the style that is used in
>>>> SWIG, but I'm not so arrogant to impose my own style on the code I
>>>> maintain. Keeping the variable names the same as other modules will also
>>>> help a lot, eg Node *n, String *tm if you aren't already doing that.
>>>    Ok, I'll re-format the code to follow SWIG style.
>>>
>> Cool, it will help everyone long term.
> 
> Maybe I already noted that: I prefer having some code formatting tool
> rather than trying to manually format the sources appropriately to the
> projects I'm involved. What about specifying the options for 'indent' that
> make the code look like it is prefered for SWIG?
> 

Using a formatting tool is a great idea and can be run every now and
again. I had a look at indent, but it isn't very good at C++. I gave it
a quick try and it kept changing parameters such as void foo(Node *n) to
(Continue reading)

Henning Thielemann | 2 Aug 12:05 2006
Picon

Re: Formatting of source code (Was: Ada language module for SWIG)


On Tue, 1 Aug 2006, William S Fulton wrote:

> Using a formatting tool is a great idea and can be run every now and
> again. I had a look at indent, but it isn't very good at C++. I gave it
> a quick try and it kept changing parameters such as void foo(Node *n) to
> void foo(Node * n), but not for pointers to primitive types. Does anyone
> know of a good C++ beautifier?

There is a rich set of options for indent. I assume that there is also a
possibility to let it format in the SWIG way.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
rod | 2 Aug 23:43 2006
Picon

Re: Ada language module for SWIG

On Tuesday 01 August 2006 06:21, William S Fulton wrote:
>
> There are two parts to the test cases, 1) Making them compile and 2)
> Providing runtime tests. Just making the wrappers compile is a very good
> indication that the language module is in a fairly healthy state. For
> the strongly typed languages it indicates the module is in an excellent
> state due to the type checking provided by the target language compiler.
> Also, if one language is passing all the tests, it is also a good
> indication that the other languages will be okay as many of the tests
> are corner cases for the core. A lot of the logic is common and you are
> encouraged to copy and paste your code from other language modules to
> make this more likely. Runtime tests are more important for interpreted
> languages but are the ultimate test. Once the simple and class examples
> are running correctly, a lot of the work has been done and I'd
> concentrate on writing the typemaps to get the whole test-suite
> compiling 100%. Then, just start writing runtime tests, with blatant
> copying and converting of runtime tests from other languages, plus add
> in any new runtime tests for anything that is particularly important for
> you.

   Testcases are now the main priority for both modules. I'll spend a few 
weeks with these, and let you know how I get on.

> >>>   Structural:
> >>>   - The declaration of the main GNAT and ADA classes has been extracted
> >>> out of the implementation (.cxx) file and placed in their own header
> >>> file.
> >>
> >> Please keep the same as the other modules and keep the class methods
> >> inline. Again I don't personally like the current approach and find it a
(Continue reading)

rod | 3 Aug 01:16 2006
Picon

Re: Ada language module for SWIG

On Tuesday 01 August 2006 21:17, Henning Thielemann wrote:
> Btw. I like to hear your opinion about the typemaps I introduced for
> Modula-3, the handling of enumerations, preserving naming conventions of
> the target language and all the problems I describe in the Modula-3 part
> of the SWIG documentation.

   Well, sadly, I do not know Modula-3 (or SWIG, for that matter) well enough 
to have formed any really valid opinions. Also, the Ada language module and 
typemaps are probably closer to the C# and Java modules, at the moment.

   Still, a couple of points come to mind ...

   With Ada, it is possible to specify a representation value for each 
enumeration literal, so mapping to C++ enums was reasonably straightforward.
I'm not sure if a similar facility exists within Modula-3 ?

   Multiple inheritance is also a worry for Ada. At the moment, only the first 
base class is considered, any others are ignored. For the 'Gnat' module, a 
form of multiple inheritance is possible, but only for base classes which 
contain only pure virtual functions and no data members. Perhaps something 
might be done to simulate MI via composition, but I haven't really thought it 
through as yet.

   Sub-classing in the Ada module uses the 'directors' approach similar to the 
Java module. The Gnat module maps Ada records to directly correspond (ie 
binary equivalent, including virtual tables) to the C++ class, so it is 
possible to sub-class without the need for 'directors'. This is possible due 
to the Gnat compiler conformance to the ABI specification. I understand that 
the Modula-3 compiler (gcc) developers are similarly considering compliance 
to the ABI standard. Perhaps that would ease Modula-3 sub-classing.
(Continue reading)

William S Fulton | 3 Aug 10:36 2006
Picon

Re: Ada language module for SWIG

rod <rodkay <at> mullum.com.au> writes:
> > >    I guess I've adopted an 'Ada-ish' style for the c++ code, in which
> > > each class has it's own header and implementation file. As you suggest,
> > > there is no pressing need for this setup; the files can be merged into a
> > > single support file, or even into the module file itself. My only concern
> > > is that this will make for huge files.
> >
> > Everyone works differently, but I find one or two big files with self
> > contained code are easier to find your way around than many little files
> > when moving around the code; * is your friend if you use vim (or CTRL-K
> > in Eclipse, or CTRL-F3 in visual studio).
> 
>    I've only been using text editors. I guess I should look into a decent C++ 
> IDE to make life a little easier.
> 
This shortcut is just to search for exact word matches at the cursor within the
same file. Any decent text editor will offer this, so an IDE is not absolutely
necessary. Eclipse CDT strikes me as being really good at navigating around the
code, perhaps better than visual studio and SourceNavigator. I still tend to
fire up vim though for any serious editing sessions :)

William

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Henning Thielemann | 3 Aug 19:04 2006
Picon

Re: Ada language module for SWIG


On Thu, 3 Aug 2006, rod wrote:

> On Tuesday 01 August 2006 21:17, Henning Thielemann wrote:
> > Btw. I like to hear your opinion about the typemaps I introduced for
> > Modula-3, the handling of enumerations, preserving naming conventions of
> > the target language and all the problems I describe in the Modula-3 part
> > of the SWIG documentation.
> 
>    With Ada, it is possible to specify a representation value for each 
> enumeration literal, so mapping to C++ enums was reasonably straightforward.
> I'm not sure if a similar facility exists within Modula-3 ?

I have seen such arbitrary assignments in a Modula-2 dialect, but they are
definitely impossible in Modula-3. Is it possible in Ada to determine the
maximum enumeration item?

>    Multiple inheritance is also a worry for Ada. At the moment, only the first 
> base class is considered, any others are ignored. For the 'Gnat' module, a 
> form of multiple inheritance is possible, but only for base classes which 
> contain only pure virtual functions and no data members. Perhaps something 
> might be done to simulate MI via composition, but I haven't really thought it 
> through as yet.

I haven't yet a good support for C++ classes. In Modula-3 it is good style
to have one module per class - that is, I had to deviate from the C++
header file structure of a library.

>    Sub-classing in the Ada module uses the 'directors' approach similar to the 
> Java module. The Gnat module maps Ada records to directly correspond (ie 
(Continue reading)

William S Fulton | 3 Aug 22:10 2006
Picon

Re: Formatting of source code (Was: Ada language module for SWIG)

Henning Thielemann wrote:
> On Tue, 1 Aug 2006, William S Fulton wrote:
> 
>> Using a formatting tool is a great idea and can be run every now and
>> again. I had a look at indent, but it isn't very good at C++. I gave it
>> a quick try and it kept changing parameters such as void foo(Node *n) to
>> void foo(Node * n), but not for pointers to primitive types. Does anyone
>> know of a good C++ beautifier?
> 
> There is a rich set of options for indent. I assume that there is also a
> possibility to let it format in the SWIG way.
> 
Nearly. As I said, it was not working very well for C++ files. It looks
okay for C files. That's why I am asking for recommendations for C++
beautifiers as indent is C focused.

William

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Mikael Magnusson | 3 Aug 22:33 2006
Picon

Re: Formatting of source code (Was: Ada language module for SWIG)

On Thu, Aug 03, 2006 at 09:10:53PM +0100, William S Fulton wrote:
> Henning Thielemann wrote:
> > 
> > There is a rich set of options for indent. I assume that there is also a
> > possibility to let it format in the SWIG way.
> > 
> Nearly. As I said, it was not working very well for C++ files. It looks
> okay for C files. That's why I am asking for recommendations for C++
> beautifiers as indent is C focused.
> 
> William

bcpp?

http://www.faqs.org/docs/Linux-HOWTO/C-C++Beautifier-HOWTO.html

Mikael

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Gmane