Subscribe: My gsoc 2007 experience
Added By: Feedage Forager Feedage Grade B rated
Language: English
add  cbinding  code completion  code  completion  monodevelop  much  packages  pad  project  projects  status report  week  work 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: My gsoc 2007 experience

My gsoc 2007 experience

For my Google Summer of Code project, I'm going to make a MonoDevelop Add-In that adds support for C/C++, this is where I will post about my progress.

Last Build Date: Sun, 05 Oct 2014 04:21:50 +0000


Levi's awesome patch

Sat, 29 Mar 2008 15:23:00 +0000

Yesterday Levi Bard (tak) sent a patch that adds code completion to members and local variables in CBinding (MonoDevelop's C/C++ binding). So that is right, the most often requested feature is now commited in trunk!

Thanks Levi!

Forgot to mention that it is not context sensitive, so local variables to one function will be available for completion in other functions, and conflicts will arise when different variables have the same name (even if they exist in different scopes). For this reason completion for local variables can be turned off in the C/C++ Preferences.

If only we had a C++ parser... things would be much better.

Tag Parsing Improvements

Sat, 12 Jan 2008 01:29:00 +0000

Well, well, first post since the end of SoC 2007... whooops!
The reason I haven't blogged in so long is because I have been working very little on CBinding, just fixing simple bugs and adding small features, nothing really worth mentioning. But I think I have finally done something worth announcing!

First off, to build the class pad from from the output of ctags, one has to do a lot of searching in the outputted tags because the tags are not outputted in a hierarchical manner, they are just outputted as a list of tags and each tag entry is marked with the 'parent' tag (namespace, class, struct etc., if any). My original implementation was to do a linear search every time I needed to find a specific tag and I just left it at that and forgot about it. As you have probably noticed, CBinding takes quite some time parsing the tags, this is especially noticeable when parsing the system tags which tend to be many.

Luckily, ctags outputs sorted tags, so I recently changed the search algorithm from linear to binary, which greatly decreases the time it takes to parse tag files, here are some numbers for parsing one of my project's tags (this includes parsing system tags):
before: 102,640 milliseconds
after: 15,731 milliseconds

Nice! well, to be honest I still think it is rather slow... next I'm going to try to implement some caching to improve this even more.

CBinding on main trunk!

Fri, 07 Sep 2007 19:15:00 +0000

It seems I didn't completely screw up this summer with CBinding, so it is now on the main MonoDevelop trunk :) :)

To try out CBinding from now on all you have to do is run configure/ with --enable-c and thats it!

CBinding is functional on svn as of revision 85496.

Hope you enjoy and don't forget to get those bugs reported ;)

Twelfth Status Report

Sat, 18 Aug 2007 14:32:00 +0000

This week I mostly did small improvements and fixed bugs, among the more notable I made certain paths to be serialized as relative to the project, attempt to always parse functions from it's prototype unless it does not have one, added commands to context menus, hide resources node in the project pad, added custom icons to stock icons so they can be used in the completion widget, made it possible for C/C++ projects to depend on other C/C++ projects that compile into a shared library, keep a project's internal pkg-config package updated and implemented IDeployable.

Other than that I added project templates for console project, static library project and shared library project for both C and C++.

Building libbanshee with MonoDevelop

Sat, 11 Aug 2007 19:07:00 +0000

Today I checked out Banshee and made a MonoDevelop C Project for libbanshee using CBinding these are the current requirements to do this:
  • You must have a recent MonoDevelop svn checkout (There are breaking changes that did not make it into MD 0.15, specifically an updated addin extension tree) so the checkout needs to be quite recent.
  • The banshee source which comes with an MD solution, I checked out todays svn, I'm not sure if the packaged tarball includes this.
  • Download this file:
In the tar file you will find the following files:
  • CBinding.dll: This is the C/C++ AddIn I have been working on, all you have to do is copy it to (assumming you use make run to run your svn MD) {MD_ROOT}/build/AddIns/BackendBindings. Alternatively you can follow these instructions if you want to keep up with CBinding development from svn:
  • libbanshee.mdp: This is the MonoDevelop project for libbanshee, just copy it to {BANSHEE_ROOT}/libbanshee
  • libbanshee.diff (optional): This is a patch that adds libbanshee.mdp to the banshee MD solution.
And thats it, this should work, but I don't guarantee anything. Please let me know if anything went wrong when you did this.

It should be noted that I'm not at all familiar with the banshee build process, so I just made the output of libbanshee go to the build folder in the banshee root folder, I'm not sure if this is correct behavior.

Tenth Status Report

Sat, 04 Aug 2007 22:27:00 +0000

I spent most of this week learning ANTLR which is a parser generator, my hope is that I would be able to use this tool to generate a simple parser to keep track of variables, their, type, scope and name. Apparently there is no easy way to instruct the parser to filter out everything else except what I'm interested in, so doing this won't be so simple, and I didn't get much real work done in this area (except learn a bunch of ANTLR stuff).

I also implemented :: completion which means I only have left to implement . and -> completion but for these I do need the parser. Here is a screencast to show the completion work that is done by now:

While watching the screencast I noticed there was some inconsistencies between the icons used in the completion widget and those used in the class pad, I will fix this shortly.

So I think CBinding is pretty much complete for now, I think now it is more important to test, bugfix and polish current work, so unless something comes up I will probably spend the rest of soc doing this and working on the parser.

Ninth Status Report

Sat, 28 Jul 2007 02:13:00 +0000

This week I started by implementing parameter completion, I'm pretty satisfied with the result, the parameter list widget is shown as soon as you press (, and it behaves like it does on C#, you can see other overloads by using the up and down arrow keys and the current parameter is highlighted in blue (this was already provided by MD).

Then I created "global" code completion, when you press ctrl+space it shows a list of available namespaces, classes, functions, structures, constants, etc. This was pretty straight forward since it doesn't have to resolve anything.

Also I changed how the class pad tree is built, instead of creating a single tags file for the entire project and then parsing that, now I create tags for each file (and it's non system #included files) and update the class pad information with this. This is done each time a file is saved.

Here is a screen shot of a C++ project and it's (wacky) class pad tree:
I also wanted to upload some images of the code completion and parameter completion, unfortunately when I press the screenshot key the widgets disappear and don't appear on the screenshots.

Supposedly this week I was going to create a simple parser to keep track of local variables and in what method the caret is currently in so that I can provide completion for something like coord. (and then the completion widget with the available fields would appear), but I found this would not be so simple and it would be very important that it is fast and efficient, so I decided to put it off until I have some information on what a good way to do this would be. So if anyone knows of any code that does something like this that I can look at or has any advice on how I should do this, I would love to know.

Eight Status Report

Sat, 21 Jul 2007 04:22:00 +0000

* Accomplished this week:
Implemented a better formatting strategy using a text editor extension.
Implemented dependency tracking.
Projects can now reference other projects in the solution. The way this is done is each project that compiles into a static library has a pkg package and other projects add that package to their project packages. The edit packages dialog has been updated to better support this.
Some bugs were fixed.

* Plans for next week:
For next week I will create a file level parser to keep track of local variables and parameters for code completion.

* Interesting documents:

Seventh Status Report

Sat, 14 Jul 2007 03:14:00 +0000

* This weeks accomplishments:
Finally got the class pad to get built in a separate thread, I'm not entirely satisfied with the implementation, but it will do for now.
Implemented support for precompiled headers in gcc and g++.
Implemented dragging and dropping of packages.
Implemented a very simple FormattingStrategy, but I think I will have to redo it so it will be much more robust.
Cleaned up the code a bit, fixed several bugs and did some small optimizations.

* Plans for next week:
I'm going to start by remaking the FormattingStrategy, there seems to be two ways to do this, subclassing and registering a Formatter which is what I did now, or subclassing and registering a TextEditorExtension, which I think is what the C# binding does. The first option (what I'm doing now) seems to be a bit restrictive, I couldn't work very well with it because it's behavior seems to be a bit strange, for example when typing a '}' I wanted to remove a '\t' from the beginning of that line, but it seems the method got called twice so I would end up removing two tabs (or getting an index out of bounds exception if there was only one tab. So I'm going to look more into this and see if I can figure it out or try the second method.

Also next week I'd like to implement dependency tracking.

* Interesting documents I used:

Testing out current work

Sun, 08 Jul 2007 22:20:00 +0000

If you have an svn build of MD, its very easy to to test out the CBinding addin.
Make sure you have a recent revision (at the time of this writing, the latest was 81606)

Apply this patch in the MD root directory:

--- (revision 81606)
+++ (working copy)
@@ -490,6 +490,7 @@
Index: Extras/
--- Extras/ (revision 81606)
+++ Extras/ (working copy)
@@ -1,2 +1,2 @@

-SUBDIRS = MonoDevelop.DesignerSupport Deployment MonoDevelop.SourceEditor MonoDevelop.Autotools CSharpBinding DebuggerAddIn ILAsmBinding MonoQuery JavaBinding BooBinding NemerleBinding NUnit MonoDeveloperExtensions VersionControl VBNetBinding prj2make-sharp-lib WelcomePage ChangeLogAddIn MonoDevelop.GtkCore AspNetAddIn AspNetEdit MonoDevelop.WebReferences
+SUBDIRS = MonoDevelop.DesignerSupport Deployment MonoDevelop.SourceEditor MonoDevelop.Autotools CSharpBinding DebuggerAddIn ILAsmBinding MonoQuery JavaBinding BooBinding NemerleBinding NUnit MonoDeveloperExtensions VersionControl VBNetBinding prj2make-sharp-lib WelcomePage ChangeLogAddIn MonoDevelop.GtkCore AspNetAddIn AspNetEdit MonoDevelop.WebReferences CBinding

In a terminal, cd to the Extras directory and enter the following commands:

$ svn propset svn:externals "CBinding" .
$ svn up

Now just build MD, note that there is currently no option to enable/disable CBinding, if you want to disable it you will have to undo what the patch did (which takes a second or two).

Also note that there is still a lot to do, this project is not finished!

I hope I didn't forget anything... and any feedback is very welcome.

Oh, almost forgot, don't laugh at my crappy icons :( I did my best, someone who has better ones I can use please let me know.

Sixth Status Report

Sat, 07 Jul 2007 00:28:00 +0000

* Accomplished this week:
This week all I could do was finish the class pad support.

* Plans/challenges for next week:
The current implementation is fine for small projects, but it's no good for large projects because it locks the UI while parsing the tags file. To solve this I decided to parse the tag file in a separate thread and
using events dynamically add new nodes to the tree as they were made available. Sounds pretty straight forward right? I thought so, so I just started hacking away without much planning. I suddenly found myself hacking around several things and the whole thing just felt really messy, so I stopped right there and decided to plan better what I was going to do before I did it. So for next week I plan on getting the class pad tree to get built without locking the UI, any advice on how to do this would be great. Also other things I want to do are implement support for pre-compiled headers and dependency tracking.

Fifth Status Report

Sat, 30 Jun 2007 03:09:00 +0000

* Accomplished this week:
I talked with Michael and he said it was ok if I put code completion aside for now and started working on code navigation first.

So far the class pad is filled with namespaces (nested or by full name), classes and methods/functions. When you double click on any item you are taken to the definition in the code.

The class pad information is generated using ctags, Mathias recommended I used globals (for code completion) but at least for navigation I'm using ctags because its more easily available in most distributions and for navigation it works great.

Well, not exactly *great*, let me explain. MonoDevelop creates the nodes hierarchy from top to bottom, yet ctags provides the information of its tags the other way around, for example in a class' tag you don't get any information on it's members, but in a member's tag you get information on it's class. This means the code is not as fast as it could be, but in the tests I have made the tree is still built pretty much instantly, and I don't have the fastest of computers. And since nodes are lazily built I'd expect even the largest projects to have their class pad tree to be built in acceptable time.

* Plans for upcoming week:
Finish the class pad including all of it's options.

Goodbye code completion...

Tue, 26 Jun 2007 02:26:00 +0000

I hope not too many people were really looking forward to the ctags based code completion, because it has been set aside for now. I talked with Michael and he said it was ok if instead I work on code navigation. Code navigation will also use ctags, stay tuned for this week's status report.

Fourth Status Report

Sat, 23 Jun 2007 02:48:00 +0000

* Accomplished this week:
Compiler errors are now parsed using regexp.
Added a ProjectServiceExtension so that *.o files are removed when the project is cleaned.
Changed the code generation panel, now the extra compiler options and extra linker options are show in a TextView each, so that you can put an extra option per line. Also added a "Define Symbols" field, by deault the Debug configuration defines DEBUG and both Debug and Release configurations define MONODEVELOP.
The Debug configuration now creates debug information.

Started work on the code completion feature, this is how its currently planned:
The code completion is done by a separate, generic AddIn which uses ctags. The goal is that this AddIn will allow to easily add basic code completion to any ctags supported language.
The ctags AddIn defines a "CTagsProject" which must be subclased by any project which wishes to use the code completion feature. Projects that inherit CTagsProject my as well ignore it completely and they won't be affected. Projects that inherit CTagsProject and do want to use the code completion feature must set the WantCodeCompletion property to true and implement AddTagsToProvider which is where the logic about which entries should be added to the completion list window takes place.

Currently the tags of a project are created when the project is built, but this will probably be moved to somewhere more appropriate.

* Plans for upcoming week
For next week I plan to implement a much more robust AddTagsToProvider so that correct tags are shown at the correct time, this will probably require a lot more work than I was expecting since tags don't work exactly as I thought they did.

* Challenges I might be facing
implementing a robust AddTagsToProvider won't be as easy as I thought because tags don't contain all the info I thought they did, for example the tag for a local variable does not contain the information about its type, also, tags for parameters are not created.

* Interesting resources

Third Report

Sat, 16 Jun 2007 00:59:00 +0000

* Accomplished this week:
Changed how the compiler command is executed, instead of calling gcc/g++ directly now it calls bash.
Finished the package selection dialog.
Finished the package folder node and package nodes.
C/C++ project templates can now specify more options like arguments to send to the linker and compiler.
`pkg-config --cflags` is now only sent to the compiler and `pkg-config --libs` to the linker.
Implemented DoExecute ().
Source files are only compiled if the object code is outdated.
Created the output options panel.

* Plans for upcoming week:
Change CreateErrorFromErrorString and CreateLinkerErrorFromErrorString to use regular expressions.
Start work on integrating makefile integration. Michael suggested and I agreed to start working on makefile integration before code completion.

* Challanges I might be facing:
I started looking into regular expressions with C# and msdn seems to have very little documentation on the subject, if someone has some good resources on this I would appreciate it.

Second Status Report

Fri, 08 Jun 2007 15:27:00 +0000

As I said earlier I wasn't able to work much this week, so here is what little I did.

* Accomplished this week:
First I fixed the order in the Project Tree following Lluis' advice so that the packages node is placed before everything else, then I had the References node disappear only if the current Project is a CProject.

I also added support to send extra arguments to the linker as well as the compiler and I cleaned up a bit, changing ProjectReferenceCollection to ProjectPackageCollection where necessary.

* Plans for the upcoming week:
Next week is my last week of finals, after that I will be focusing on completing the Edit packages dialog.

First Status Report

Sat, 02 Jun 2007 18:56:00 +0000

* Accomplished this week:Well, I have been working since interim period so its pretty much whatI have done, though not so much because I have had classes.First I created the basic C/C++ addin and added functionality for forcompiling C projects using gcc and C++ with g++.Then created the code generation panel where the following options areavailable:-Warning level: this can be set to "no warnings", "normal" and "all".-Optimization level: can be set to 0-3.-Target: "Executable", "Static Library" or "Shared Object".-Extra Compiler arguments: You can add whatever options you want tosend to the compiler (ie -DDEBUG to define DEBUG, etc.)-Libraries: Here you can select what libraries to link with yourproject.-Include: Add extra folders to search for #include files.-Library: Add extra folders to search for libraries.I also created a dialog to select what compiler to use, by default theaddin uses gcc for C and g++ for C++, but you can create a class thatimplements ICompiler and register it in the MonoDevelop Addin Tree(specifically, in "/CBinding/Compilers"). This dialog loads allregistered classes and allows you to select which one to use for yourproject.And currently I'm working on creating a dialog to select what pkg-config packages to include in your project, this works very similar toreferences in .NET languages. In the project solution pad I removedthe "References" node and created a "Packages" node which has an "Editpackages..." command in it's context menu which launches the Editpackages dialog where you will be able to add/remove packages fromyour project.* Plans for the upcoming week:Since I'm getting closer to finals I have a lot of final projects forschool to complete and I have to get ready for finals, so I don'tthink I will be working much until around the 16 of June when I havemy last exam. I still hope to be able to get some work done anyway.This is why I have been working since the interim period, to make upfor the time I won't have in the next 2 weeks.When I get back to work I will be focusing on completing the editpackages dialog, which still has a long way to go, and fixing somesmall details that were bothering me.* Challenges or problems that I might be facing:To add the packages node I created a NodeBuilderExtension that extendsthe Project node and adds the packages node, the problem here is thatit adds the node at the end of the list of nodes, even after theproject source files which is just not nice, I didn't find any easyway to fix this and there probably is one.Also for some reason the activalanguage condition is not working forthe NodeBuilderExtensions, if I put the condition the condition isnever true so for now I just commented out the condition so Irecommend you don't use this addin in your stable MonoDevelop justyet, since it will remove the References node and add the Packagesnode even if its a C# project.Whats very weird about this problem is that the exact same conditiondoes indeed work for the Dialogs... I don't get it, though I didn'tdig much into the problem.Another challenge I will have is filtering the pkg-config packages sothat only suited packages appear in the edit packages dialogselection, I'm not quite sure how I'm going to do this yet.This probably won't be a challenge but since I have never done itbefore I'm adding it here anyway, I will have to get the value for thepkg-config env variable to search all the paths there for packages, Ihave no idea how to get an env variable's value... but if it's simplelike I think it is, some quick googling should solve this.* Interesting resources that helped you during the week.[...]

Code Generation Panel

Sat, 28 Apr 2007 03:50:00 +0000

I have now created the code generation panel and all of its functionality except for the paths tab is implemented, here are some screenshots:



Sun, 22 Apr 2007 04:55:00 +0000

Since my last post here is what is new:
  • Code always compiles to object code, then depending on the target an executable, static library or shared object is created.
  • The compiler can be changed, defaults are of course gcc and g++, to add a new compiler in the future (this is still no implemented) one will only have to extend CBinding.CCompiler and register it with MonoDevelop (this idea was provided by Michael).
  • Created the Code Generation panel, even though it still far from finished.
  • Several other fixes.
My main challenge right now is serializing ArrayLists (for libraries, extra include paths etc.) into the configuration. Following what is said in this article isn't working :(

Compilation is back!

Tue, 17 Apr 2007 20:08:00 +0000

Yeah, so after some work today I got the Add-In back in shape and now its able to compile C projects again, and it no longer has the ugly bug where you could not add new files.

Several other thins were improved like generating the args to send to gcc and getting the configuration from the .mdp


Tue, 17 Apr 2007 02:38:00 +0000

Big changes today, the Add-In can no longer compile C projects :(
The reason behind this is kind of embarrassing, so let me just say I was doing it all wrong, but thanks to Michael I'm now going in the right direction.

Luckily what I did while I was doing things wrong can be mostly reused, so this past weekend's work didn't go all to waste.

First succesful C project compiled

Mon, 16 Apr 2007 02:08:00 +0000

At last a C project can be successfully compiled! though I have a weird bug where I can't add new files, I can only add existing files. I'm going to concentrate on fixing that bug this week, but since I'm still in school I'm not sure how much time I'm going to have, I might have to wait until the weekend.

Right after that the goal is to create the global options panel and make the argument creation for gcc better (It's currently just rushed code that could break like a twig).

Day one...

Sun, 15 Apr 2007 02:28:00 +0000

Today I started coding. My project is to create a MonoDevelop Add-In that adds support for C/C++.

My mentor, Michael James Hutchinson, is an awesome guy who helped me enormously, on my very first day of coding! he taught me in the ways of svn (I'm rather new to Linux and open source development :p) and showed me how to get my project set up and good to go in the MonoDevelop tree.

Cool trick he taught me: have two versions of MonoDevelop, one you develop in and one where you test your code in.

This was probably obvious to everyone else but me, but hey at least now I know...

Didn't get much done today, mostly learned svn and dug into source code for other Language Bindings.

As of right now, once you install my adding in MonoDevelop you can create a new, Empty C Project, and it will recognize the language as C, how exciting! >_>

Thats pretty much it for now, see you later folks!