David Elliott wrote:
> Patrik Stridvall wrote:
> > > So... let's see.. how much processing time did we waste going from
> > > ASCII->Unicode->UTF8... hmmmm.... 2*N (where N is number of
> > > characters).
> > > I think I can live with that. Hell, I'd even be willing to
> > > live with more
> > > than that.
> >
> > ... so lets instead concentrate on making the currently
> > used solution as fast and maintainable as possible.
> >
>
> Well, the currently used solution is kind of mixed up... some
> A->W, some
> W->A (not really possible, but done anyway)
Yes, I know, but they are the same solution in principle.
> Using the spec files may not be the best way to go. I would suggest a
> facility strictly for generating conversion functions given a
> specific set
> of parameters. Somewhat like the glue generation now? In
> fact, maybe we
> could make glue more modular and let it handle this stuff too.
[Suggested solution snipped]
OK, I almost did as you suggested (attached).
It hooks in to the glue code generation. From a
simple specification like the one below it can
generated the following file.
The conversions are in the "wrong" order,
but it can generate in any order, I just used
this as an example.
It supports both in and out parameter,
it even support parameters that are both
in and out (/* in/out */).
It doesn't support non-NULL terminated
in-strings yet. I found no example of
functions that used it, except TextOut
so I haven't bothered. Does anybody
know any more function than TextOut
that uses non-NULL terminated in-strings?
Comments?
--- 8<---
/* ### start build ### */
extern UINT WINAPI RegisterClipboardFormatW(LPCWSTR /* in */);
extern INT WINAPI GetClipboardFormatNameW(UINT, LPWSTR /* out */, INT /*
size */);
/* ### stop build ### */
--- 8<---
/* File generated automatically from clipboard.c; do not edit! */
#include <alloca.h>
#include "wine/winestring.h"
#include "builtin16.h"
#include "stackframe.h"
#include "winbase.h"
extern UINT WINAPI RegisterClipboardFormatA(LPCSTR);
UINT WINAPI RegisterClipboardFormatW(LPCWSTR arg1)
{
UINT result;
LPSTR newarg1 = NULL;
if(arg1) {
newarg1 = (LPSTR) alloca(lstrlenW(arg1));
lstrcpyWtoA(newarg1, arg1);
}
result = RegisterClipboardFormatA(newarg1);
return result;
}
extern INT WINAPI GetClipboardFormatNameA(UINT, LPSTR, INT);
INT WINAPI GetClipboardFormatNameW(UINT arg1, LPWSTR arg2, INT arg3)
{
INT result;
LPSTR newarg2 = NULL;
if(arg2) {
newarg2 = (LPSTR) alloca(arg3);
}
result = GetClipboardFormatNameA(arg1, newarg2, arg3);
if(arg2) {
lstrcpynAtoW(arg2, newarg2, arg3);
}
return result;
}
---8<---
build-use-glue.diff
build.diff