Stefan Schimanski wrote:
Hi!

I wrote a small documentation of my dynmacro patch. You can find the patch itself, in sync with r21100 from today, here: http://1stein.org/download/dynmacro.patch

The documentation is linked from the wiki page for macros (http://wiki.lyx.org/Devel/Macros#toc8) as lyx file or pdf.

Waiting for comments

I am not proficient enough in this field so just cosmetics comment from me:

+       ///
        bool operator==(MacroData const & x) const {
-               return def_ == x.def_ &&
+               return definition_ == x.definition_ &&
                        numargs_ == x.numargs_ &&
-                       disp_ == x.disp_ &&
-                       requires_ == x.requires_;
+                       display_ == x.display_ &&
+                       requires_ == x.requires_ &&
+                       optionals_ == x.optionals_ &&
+                       defaults_ == x.defaults_;


I think that putting the boolean operator at the beginning of the line is clearer:

                return definition_ == x.definition_
                        && numargs_ == x.numargs_
                        && display_ == x.display_
                        && requires_ == x.requires_
                        ...


+// The MacroContext is used during metrics calculation to resolve
+// macro instances according to the position of them in the buffer
+// document. Only macro definition in front of the macro instance
+// are visible and are resolved.
+
+class MacroContext {
+public:
+ /// construct context for insets in par (not including the ones defined in par itself)
+       MacroContext(Buffer const & buf, Paragraph const & par);

Please use Doxygen syntax:

/// Short title.
/**
  * <Explanation>
  *
  */

The trailing dot at the end of the short title is important, also for methods and members.


=== src/mathed/MathData.cpp
==================================================================
@@ -14,6 +15,7 @@
 #include "InsetMathFont.h"
 #include "InsetMathScript.h"
 #include "MathMacro.h"
+#include "InsetMathBrace.h"
 #include "MacroTable.h"


Please respect alphabetical order.


@@ -248,35 +250,14 @@
                return;
        }

+       const_cast<MathData*>(this)->updateMacros(mi);
+

Couldn't you declare some member variable _mutable_ instead of using const_cast?



+void MathData::updateMacros(MetricsInfo & mi)
+{
+       Cursor & cur = mi.base.bv->cursor();
+
+       // go over the array and look for macros
+       for (size_t i = 0; i < size(); ++i) {
+               MathMacro * macroInset = operator[](i).nucleus()->asMacro();
+               if (macroInset) {

Please, rework the code if there's more than three levels of indentation, ex, use:
                if (!macroInset)
                        continue;

and de-indent the rest.


+               // insert optional arguments?
+               for (; j < macroOptionals && p < size(); ++j) {
+                       if (operator[](p)->getChar() == '[') {
...
+                       } else
+                               detachedArgs.push_back(MathData());

Same comment:

                // insert optional arguments?
                for (; j < macroOptionals && p < size(); ++j) {
                        if (operator[](p)->getChar() != '[') {
                                detachedArgs.push_back(MathData());
                                continue;
                        }
...

I don't have the courage nor the time to go further.

Abdel.

Reply via email to