On 08/05/2013 02:16 AM, Jos van den Oever wrote:
On 08/04/13 20:25, Friedrich W. H. Kossebau wrote:
really cool work from Jos, happy to see it having made it into Calligra master

So am I. Glad I blew off the dust from this one.

Having finally given the patch I look as well I found I have a really hard
time reading all_the_created_methods_and_objects.

I wonder who else would favour to do like it is done in the browsers' HTML DOM, where the hyphens in all element/attribute names are replaced by removing
them and turning the following letter to Uppercase.

Might need some more work in the generator, but given that this is affecting quite some code is should be worth the effort. So the only usages of _ would be to separate the element/attribute name from e.g. the set-prefix and as replacement for the namespace separator, which at least might help parsing. So
in the given example it would be:

   text_p p(xmlWriter);
   p.set_text_styleName("italic");
   text_span span(p.add_text_span());
   span.set_text_styleName("italic");
   span.addTextNode("Hello World!");

What do people think? What are other downsides of this approach? Will it need some special case handling for some cases (and would that still be worth it??

This issue was brought by Inge, Sebsauer and Zagge as well. I proposed to address it after the patch landed which is now.

The initial patch used camelcasing of the class names and function names. I moved away from that to use a simple rule s/[:-]/_/. There are a few ways in which to map the characters : and - that are not allowed in class names or function names. Here are a few obvious ones:

using namespace writeodf;

   Element                          Attribute Attribute+uppercase
   office:body                      xml:id          svg:viewBox
   class name   open tag            set attribute   set attribute
1) office_body  add_office_body()   set_xml_id(v) set_svg_viewBox(v)
2) OfficeBody   addOfficeBody       setXmlId(v) setSvgViewBox(v)
3) Office_Body  addOffice_Body      setXml_Id(v) setSvg_ViewBox(v)
4) office::body add<office::body>() set<xml::id>(v) set<svg::viewBox>(v)

Methods 1-3 have good autocompletion. Method 4 does not and has harder error messages, but it looks really cool.

Just from my first impression I love method 4 because its super-easy to understand what part is added by us (add/set/...), what part is namespace and what part is tag-name.

For error-messages: true for gcc, I guess clang is better then and I think/hope gcc is improving there too.


Before you comment on the best method and pros and cons, I would ask you to convert at least one Calligra cpp file to the new API to get familiar with it. There's plenty to choose from.

Yep, sorry but that has really the very last priority for me :)

_______________________________________________
calligra-devel mailing list
calligra-devel@kde.org
https://mail.kde.org/mailman/listinfo/calligra-devel

Reply via email to