Discussion:
Code generated by script causes data loss on type convert
Fan Yang
2013-08-06 01:18:28 UTC
Permalink
Hi,
I'm using Qt port of scintilla, there is one class name ScintillaEdit is
generated by script WidgetGen.py.
I find that all return type or paramenter type sptr_t/uptr_t are replaced
with int, this may cause data loss.
At least on Mac x64, the pointer type such as docPointer couldn't work
correctly.
I simply modified the script, it seems work fine now. The diff file is
attached, I hope it could be helpful.

Regards,
Fan
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2013-08-07 09:22:23 UTC
Permalink
I find that all return type or paramenter type sptr_t/uptr_t are replaced with int, this may cause data loss.
At least on Mac x64, the pointer type such as docPointer couldn't work correctly.
I simply modified the script, it seems work fine now.
OK, committed.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
John Ehresman
2013-09-17 17:04:55 UTC
Permalink
Post by Neil Hodgson
I find that all return type or paramenter type sptr_t/uptr_t are replaced with int, this may cause data loss.
At least on Mac x64, the pointer type such as docPointer couldn't work correctly.
I simply modified the script, it seems work fine now.
OK, committed.
There's a problem with this -- the first parameter becomes an unsigned
int (uptr_t), but negative numbers are valid for the first parameter in
some api's (e.g. BraceBadLight). I'm using scintilla via Python and
PySide and an exception is raised by if the value is negative and the
type of the first parameter is uptr_t.

One option is to simply use sptr_t as the type of the first parameter in
the generated method. Note that in the case of docPointer api's, the
type used is already sptr_t. A simple patch to implement this is attached.

Another (better?) option might be to determine what the casts used
inside the scintilla source for each api and generate the method
signature with the type used in the internal cast.

Thanks,

John
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2013-09-20 01:42:33 UTC
Permalink
One option is to simply use sptr_t as the type of the first parameter in the generated method. Note that in the case of docPointer api's, the type used is already sptr_t. A simple patch to implement this is attached.
I had hoped that the original poster would OK this change but since there has been no reply, its committed as is.

http://sourceforge.net/p/scintilla/code/ci/c06ca53fd074d1652b1fc4db039f3089d7d33154/

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...