Qt-jambi-interest Archive, July 2007
Problems using generator
Message 1 in thread
Hello!
I'm getting some strange error messages when I try to compile a C++ Qt
widget using the jambi generator.
../cpp/com_poseidon_mapborealis/qtjambishell_CMbSimpleTextItem.cpp: In
function 'void
Java_com_poseidon_mapborealis_CMbSimpleTextItem__1_1qt_1setText_1String__JLjava_lang_String_2(JNIEnv*,
_jclass*, jlong, _jobject*)':
../cpp/com_poseidon_mapborealis/qtjambishell_CMbSimpleTextItem.cpp:1290:
error: invalid conversion from '_jobject*' to 'jlong'
../cpp/com_poseidon_mapborealis/qtjambishell_CMbSimpleTextItem.cpp:1290:
error: initializing argument 1 of 'void* qtjambi_from_jlong(jlong)'
The class definition looks like this:
class CMbSimpleTextItem : public CMbItem
{
public:
void setText( const QString text );
QString text() const { return _text; };
private:
QString _text;
QGraphicsSimpleTextItem *_textItem;
void init();
public:
CMbSimpleTextItem ( QString text, CMbItem * parent = 0, CMbScene*
scene = 0 );
CMbSimpleTextItem ( CMbItem *parent = 0, CMbScene* scene = 0 );
~CMbSimpleTextItem();
virtual QRectF boundingRect() const;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem
*option, QWidget *widget);
};
where CMbItem looks like this:
class CMbItem : public QGraphicsItem
{
public:
enum CMbItemType
{
General = UserType + 1,
Point,
Ship,
Anchor,
Fairlead,
Bollard,
MooringCable
};
private:
void init();
CIdFactory *_idFactory;
unsigned int _id;
public:
CMbItem ( QGraphicsItem * parent = 0, CMbScene* scene = 0 );
CMbItem ( QPointF pos, QGraphicsItem *parent = 0, CMbScene* scene =
0 );
~CMbItem();
virtual QRectF boundingRect() const;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem
*option, QWidget *widget);
void setPos( const QPointF& pos );
void removeChildren();
unsigned int id() const { return _id; };
virtual int type () const;
protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent *event );
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent *event );
virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent *event );
};
Regards,
Helge Fredriksen
Message 2 in thread
Helge Fredriksen wrote:
> Hello!
>
> I'm getting some strange error messages when I try to compile a C++ Qt
> widget using the jambi generator.
>
> ../cpp/com_poseidon_mapborealis/qtjambishell_CMbSimpleTextItem.cpp: In
> function 'void
> Java_com_poseidon_mapborealis_CMbSimpleTextItem__1_1qt_1setText_1String__JLjava_lang_String_2(JNIEnv*,
> _jclass*, jlong, _jobject*)':
> ../cpp/com_poseidon_mapborealis/qtjambishell_CMbSimpleTextItem.cpp:1290:
> error: invalid conversion from '_jobject*' to 'jlong'
> ../cpp/com_poseidon_mapborealis/qtjambishell_CMbSimpleTextItem.cpp:1290:
> error: initializing argument 1 of 'void* qtjambi_from_jlong(jlong)'
>
> class CMbSimpleTextItem : public CMbItem
> {
>
> public:
> void setText( const QString text );
Hi Helge,
This is a bug in the generator when you pass strings as const QString
(not reference). If you change your signature to be:
const QString &
you'll not run into this problem, which is probably what you intended in
the first place ;-)
I've attached a patch to the generator which solves the problem there too.
best regards,
Gunnar
==== //depot/qtjambi/main/generator/metajavabuilder.cpp#39 (text) ====
==== //depot/qtjambi/main/generator/metajavabuilder.cpp#39 (text) ====
279c279
< void MetaJavaBuilder::fixQObjectForScope(TypeDatabase *types,
---
> void MetaJavaBuilder::fixQObjectForScope(TypeDatabase *types,
406c406
< FunctionList compare_operators = m_dom->findFunctions("operator==")
---
> FunctionList compare_operators = m_dom->findFunctions("operator==")
413c413
< }
---
> }
1002c1002
< void MetaJavaBuilder::setupFunctionDefaults(MetaJavaFunction *java_function, MetaJavaClass *java_class)
---
> void MetaJavaBuilder::setupFunctionDefaults(MetaJavaFunction *java_function, MetaJavaClass *java_class)
1492c1492
<
---
>
1517c1517
<
---
>
1592c1592,1593
< && java_type->isConstant() == java_type->isReference()) {
---
> && (java_type->isConstant() == java_type->isReference()
> || java_type->isConstant())) {
1749c1750
< for (int i=0; i<names.size() - 1 && ns; ++i)
---
> for (int i=0; i<names.size() - 1 && ns; ++i)
1754c1755
<
---
>