Re: [Libwpd-devel] Doing away with WPXString
2010/11/1 William Lachance : > The problem is mainly that this change (along with const char change) > involve changes to all the various sub-projects, since I'm changing > the API/contract of libwpd. I don't really like leaving those in a > broken state. > > I'll try to get everything done (or at least > libwpg/libwpd/writerperfect) for tomorrow or Wednesday, I think I > should have the time. Ok, after spending a few more hours on this work, I decided to mostly back out of doing it. There are just too many places where there's a legitimate need for this class or something like it. Notably, it's used all over the place in libwpg (which I still don't feel 100% comfortable messing with) as well as the WPXPropertyList class (where it's used as a return type, avoiding the problems of returning a const char *). The one change that I'm leaving in is the addition of an insertSpace function to the API, because it is an actual useful API change (and bonus: we now handle spacing correctly in wpd2html). I've committed my changes and pushed them to git. -- William Lachance [email protected] -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Libwpd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libwpd-devel
Re: [Libwpd-devel] Doing away with WPXString
The problem is mainly that this change (along with const char change) involve changes to all the various sub-projects, since I'm changing the API/contract of libwpd. I don't really like leaving those in a broken state. I'll try to get everything done (or at least libwpg/libwpd/writerperfect) for tomorrow or Wednesday, I think I should have the time. Will 2010/11/1 Fridrich Strba : > I would prefer to have it pushed as it goes. I will be in Hamburg for a > hack-weekend from this Friday and would like to finalize the LibreOffice > plug-in. So, if it was possible to do the functionality first so that I > can try to craft the plug-in and then try to beautify the stuff later :) > I would not mind. > > Cheers > > F. > > On Sun, 2010-10-31 at 13:51 -0400, William Lachance wrote: >> Just a quick update on this. I've begun work on it, about 1/3 through >> I'd say. I'm working on a branch which I will push when it's ready >> (hopefully next week). > > > -- William Lachance [email protected] -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Libwpd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libwpd-devel
Re: [Libwpd-devel] Doing away with WPXString
I would prefer to have it pushed as it goes. I will be in Hamburg for a hack-weekend from this Friday and would like to finalize the LibreOffice plug-in. So, if it was possible to do the functionality first so that I can try to craft the plug-in and then try to beautify the stuff later :) I would not mind. Cheers F. On Sun, 2010-10-31 at 13:51 -0400, William Lachance wrote: > Just a quick update on this. I've begun work on it, about 1/3 through > I'd say. I'm working on a branch which I will push when it's ready > (hopefully next week). -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Libwpd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libwpd-devel
Re: [Libwpd-devel] Doing away with WPXString
Just a quick update on this. I've begun work on it, about 1/3 through I'd say. I'm working on a branch which I will push when it's ready (hopefully next week). I realized that it's not a good idea to eliminate WPXString altogether as the functionality for explicitly inserting spaces is really useful for ODT and HTML filters. Basically, these documents ignore all but one consecutive unicode space: if you want this, you are expected to define them explicitly (using a text:s or element). So what I'm doing instead is making WPXString an internal-only API and moving the handling of spaces to libwpd proper. Now, if there is more than one consecutive space in a given piece of text, libwpd will tell you about the remaining ones with an insertSpace() callback. This centralizes a somewhat-complicated piece of logic in one place, which seems like a win to me. Will 2010/10/23 Fridrich Strba : > Will, > > On Sat, 2010-10-23 at 15:41 -0400, William Lachance wrote: >> I imagine I could convert everything libwpd-related (libwpd, >> writerperfect, bindings, libwpg, the abiword plugin) to this approach >> (with the insertSpace function I mentioned above) in the space of an >> afternoon next week. > > Ok, so if you manage to do it and if valgrind is happy (./regression.pl > --odt --vg ), I will not stop anybody from doing anything :) > > Cheers > > Fridrich > > -- William Lachance [email protected] -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Libwpd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libwpd-devel
Re: [Libwpd-devel] Doing away with WPXString
Will, On Sat, 2010-10-23 at 15:41 -0400, William Lachance wrote: > I imagine I could convert everything libwpd-related (libwpd, > writerperfect, bindings, libwpg, the abiword plugin) to this approach > (with the insertSpace function I mentioned above) in the space of an > afternoon next week. Ok, so if you manage to do it and if valgrind is happy (./regression.pl --odt --vg ), I will not stop anybody from doing anything :) Cheers Fridrich -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Libwpd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libwpd-devel
Re: [Libwpd-devel] Doing away with WPXString
2010/10/23 Fridrich Strba :
> Will,
>
> My first wild idea is that if you do it all properly, go for it. Like to
> be sure that we don't require user to free anything she did not allocate
> and that we don't return reference to a temporary from a function, try
> it.
const char * implies read-only, just like const WPXString &. I don't
think there's any risk of memory issues here, as long as the API is
used as intended. :)
> Now, concerning the binding, we don't have big issues with binding
> libwpd's WPXString in the libwpd2-bindings module and also the len()
> function that is returning the unicode character count is great.
Hmm, I didn't think about that. Looking closely at WriterPerfect, I
guess the main reason we have the extra functions to return the length
of the string is to allow us to iterate over it in the case that we're
implementing a document listener which requires us to explicitly
delineate spaces (e.g. opendocument, html, )... something that,
come to think of it, we should really be taking care of inside libwpd
by providing an insertSpace function. :)
> So, if it is not really a huge performance problem I would plead to
> stick with WPXString for 0.9.x and try to simplify the API after. The
> reason is that I actually settled for using the WPXString everywhere in
> libraries that have something to do with libwpd and would not be very
> confortable to do such a huge change at this point of the release cycle.
The main reason to do this is definitely API ease of use, not
performance. I imagine this change will improve performance somewhat
(because we'll be copying fewer strings), but that's never really been
an issue with libwpd (libwpd can process even a large document in a
fraction of a second).
The thing is, if we don't do this now, it will be a long time before
we ever do (since it's an API-breaking change), so we'll be stuck with
the current API for a long time. Really, in almost all cases the
conversion is very straightforward so I think the risk is quite low.
Take this function from the raw listener:
void RawDocumentGenerator::insertText(const WPXString &text)
{
__iprintf("insertText(text: %s)\n", text.cstr());
}
After the conversion, the function would look like this:
void RawDocumentGenerator::insertText(const char *text)
{
__iprintf("insertText(text: %s)\n", text);
}
I imagine I could convert everything libwpd-related (libwpd,
writerperfect, bindings, libwpg, the abiword plugin) to this approach
(with the insertSpace function I mentioned above) in the space of an
afternoon next week.
--
William Lachance
[email protected]
--
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
___
Libwpd-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libwpd-devel
Re: [Libwpd-devel] Doing away with WPXString
Will, My first wild idea is that if you do it all properly, go for it. Like to be sure that we don't require user to free anything she did not allocate and that we don't return reference to a temporary from a function, try it. Now, concerning the binding, we don't have big issues with binding libwpd's WPXString in the libwpd2-bindings module and also the len() function that is returning the unicode character count is great. So, if it is not really a huge performance problem I would plead to stick with WPXString for 0.9.x and try to simplify the API after. The reason is that I actually settled for using the WPXString everywhere in libraries that have something to do with libwpd and would not be very confortable to do such a huge change at this point of the release cycle. Cheers Fridrich On Sat, 2010-10-23 at 11:45 -0400, William Lachance wrote: > Hey, > > So after having come back to libwpd after a few years, I realized that > I made one mistake when designing the external API. > > For various reasons (OOo compatibility, language bindings) we don't > want to export STL structures (string, map, etc.) in the external API. > For this reason, I created a class called WPXString to wrap > std::string. I've since come to realize that this isn't really > necessary. For libwpd's external API, we can just use const char *, > which binds quite nicely and has no overhead. For its internal API, we > can just use std::string straight up. > > Benefits: > > 1. Library becomes easier to understand (no need to look up > WPXString's various methods), both internally and externally > 2. Library becomes easier to bind. > 2. Somewhat reduced overhead. > > Thoughts? -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Libwpd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libwpd-devel
Re: [Libwpd-devel] Doing away with WPXString
On Sat, 2010-10-23 at 11:45 -0400, William Lachance wrote: > Hey, > > So after having come back to libwpd after a few years, I realized that > I made one mistake when designing the external API. > > For various reasons (OOo compatibility, language bindings) we don't > want to export STL structures (string, map, etc.) in the external API. > For this reason, I created a class called WPXString to wrap > std::string. I've since come to realize that this isn't really > necessary. For libwpd's external API, we can just use const char *, > which binds quite nicely and has no overhead. For its internal API, we > can just use std::string straight up. > > Benefits: > > 1. Library becomes easier to understand (no need to look up > WPXString's various methods), both internally and externally > 2. Library becomes easier to bind. > 2. Somewhat reduced overhead. > > Thoughts? My thoughts would be "Go for it". I always hate custom data structures anyway. Marc -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ Libwpd-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libwpd-devel
