Status Update: Outparam work

Squash Outparams

The following took me a few days to achieve.

./squash -sq-rewrite-outparams out2.txt -sq-implementation nsBidiPresUtils -sq-no-squash -o-lang GNU_Cplusplus ~/work/ff-build/dom/src/base/nsFocusController.i

where out2.txt contains instructions on which functions to modify



--- /Users/tarasglek/work/mozilla/dom/src/base/nsFocusController.h
+++ /Users/tarasglek/work/mozilla/dom/src/base/nsFocusController.h
@@ -72,1 +72,1 @@
- NS_IMETHOD GetFocusedElement(nsIDOMElement** aResult);
+ nsIDOMElement* GetFocusedElement();

This still doesn’t add the already_AddRefed or other important attributes, but that should be easy. The result looks simple, but getting squash from working with a testcase to an actual source file was a little on the painful side.

After my experience with renaming I have realized that squash should avoid the C++ pretty printer for now. Thus the result is produced in a verbose AST-sensitive regexp-like way. However figuring out where things start and end is incredibly painful due to the presence of the preprocessor.

My plan is to get squash rewriting some basic Mozilla code the painful way and then I use what I learned to integrate mcpp along with the much coveted end-of-ast-node info into elsa.

JavaScript is an AST’s Best Friend

Until recently I have been doing a lot of work with dehydra. Now that it is feature-complete I am back to working on squash fulltime and I miss JavaScript already. JS is much better suited for messing about with Abstract Syntax Trees. It is so nice to be able to print out any data structure, create new ones without modifying a billion files and the lack of C++ compile/linking delay is nice too. It’s amazing how much simpler it is to analyze functions for out-param rewriting in JS compared to checking for simpler patterns in C++. I am seriously excited about Tamarin/ES4 and the productivity boost that it will provide.

I wonder whether a complete JS binding for Elsa would be a good idea.


Switching to a Mac finally made me switch to Emacs. I could not find any other editors that would be support the workflow I was used to with SciTE or Kate. Other than absolutely hating the majoring of Emacs shortcuts (who’s idea was Ctrl-^ and the crazy undo/redo) I love the editor for the amazing term mode. It’s a little buggy in the current version, but the CVS version is good enough to comfortably run vim in it for quick edits :). It’s so nice to keep all of my terminals and code in the same window. I am dreaming of the day when Emacs will undergo the Mozilla->Firefox-like modernization.


  1. The day you’re dreaming of is here.

  2. Speaking of Tamarin: Instead of “cleaning up” the c++-code, would it be feasible to turn the c++ code into javascript code?

  3. It’s possible but it will require a lot of work to write tools for that. C++ is one of the hardest languages for “understanding” such that it can be rewritten.

  4. Of course you are right, C++ allows much of the things C allows and C is just high level assembly. So a more interesting question might be, if you think that there are a sufficiently large part of the code base, that it’s worthwhile to create a translator, which contains a sufficiently “safe” or restricted subset of C++, to make “understanding” possible?

  5. Sure, I like your line of thinking. i think one can introduce a more restrictive type system onto the C++ code and then translate the code that can fit that subset of C++ that we can prove to be convertable to JS.

    We should chat some more, perhaps you could help me crack this problem.