Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: DrewBoo on April 01, 2008, 06:43:07 am

Title: PATCH: File extension handling improvement
Post by: DrewBoo on April 01, 2008, 06:43:07 am
I have submitted a patch to BerliOS for your consideration.

http://developer.berlios.de/patch/?func=detailpatch&patch_id=2425&group_id=5358

Currently, Code::Blocks has inconsistent concepts of what a "source file" and "header file" are, which prevents some functionality from working.  See discussion here: http://forums.codeblocks.org/index.php/topic,8098.msg60489.html and here: http://forums.codeblocks.org/index.php/topic,7905.0.html

The Project Manager has predefined file masks to define "Source Files" and "Header Files".  ".C" (capital letter) is a valid extension, for example.  You can also add you own extensions, such as ".inl" for inline code.

Elsewhere in Code::Blocks, functionality that requires knowing header and source files ignore extensions defined in the Project Manager - even many of the default ones - and use a hard coded list.

This patch will retain the existing hard-coded extensions, but before returning failure also check whatever extensions are known by the Project Manager.

If you use non-standard file extensions such as .C or .H or .inl or any other extensions you teach the Project Manager, the following functionality will now work with those files:



Files affected:

src/sdk/globals.cpp
    Modified FileTypeOf() so that, before giving up and returning ftOther, check the Project Manager to see if it would consider the file a source or header
src/sdk/filegroupsandmasks.cpp
    Improved const-correctness
src/sdk/editormanager.cpp
    Changed swap header/source code to consider file extensions known by the project manager
src/include/projectmanager.h
    Provided an accessor to a const FileGroupsAndMasks object
src/include/filegroupsandmasks.h
    Improved const-correctness
Title: Re: PATCH: File extension handling improvement
Post by: joubertdj on April 01, 2008, 08:09:37 am
 :) Nice ... I hope all the tests succeed for your sake, so that it can be included in SVN!
Title: Re: PATCH: File extension handling improvement
Post by: mandrav on April 01, 2008, 08:30:34 am
Quote
src/include/projectmanager.h
    Provided an accessor to a const FileGroupsAndMasks object
src/include/filegroupsandmasks.h
    Improved const-correctness

Without having looked at the patch yet, I can safely say it's probably not going to be accepted for the time being. That is because touching those files I quoted is going to break binary compatibility with the 8.02 release. And that is something that hasn't been yet decided by the devs how to handle.

Still, thanks for providing patches to improve C::B :).
Title: Re: PATCH: File extension handling improvement
Post by: DrewBoo on April 01, 2008, 08:43:43 am
Without having looked at the patch yet, I can safely say it's probably not going to be accepted for the time being. That is because touching those files I quoted is going to break binary compatibility with the 8.02 release. And that is something that hasn't been yet decided by the devs how to handle.

Hmm...I don't have to change filegroupsandmasks.h...I made it more const correct because it seemed like the right thing to do.

As for projectmanager.h...it's holding on to that FileGroupsAndMasks object really tight.  I could get my hands on it by doing some OFFSETOF voodoo instead of changing the interface in the header.  You know, just while the devs are deciding how this should usually be handled.

What do you think?

Still, thanks for providing patches to improve C::B :).

Bah...it's fun.   :lol:
Title: Re: PATCH: File extension handling improvement
Post by: DrewBoo on April 01, 2008, 08:45:53 am
Still, thanks for providing patches to improve C::B :).

Oh, and congratulations on your 212th post.
Title: Re: PATCH: File extension handling improvement
Post by: thomas on April 01, 2008, 10:00:03 am
Doesn't look so bad all in all, except my TortoiseDiff doesn't seem to like the patch (some error about line 12... I'm too lazy to figure it out  8)), so only been reading out of context.
Title: Re: PATCH: File extension handling improvement
Post by: DrewBoo on April 01, 2008, 03:47:03 pm
Doesn't look so bad all in all, except my TortoiseDiff doesn't seem to like the patch (some error about line 12... I'm too lazy to figure it out  8)), so only been reading out of context.

If you think it could get in, I'll go see what Tortoise doesn't like about the patch.

[Edit]
...Ah, Tortoise is Windows-only.  I won't be able to check that right away.  For what it's worth, I tested that patch in my Ubuntu environment against a clean svn checkout using

Code
 patch -p0 < filetypes.patch

And it worked.  Perhaps it's just not happy about line endings?