PDA

View Full Version : dumpcpp creates non-functional code of procedure



stephan.storm
29th June 2012, 12:38
Hello community,

I try to use a COM object in Qt using QAxContainer API. I wrote a .NET class in C# which I want to access from a Qt application. I've used the necessary attributes in MSVC to make the Class visible to COM. After building the .NET dll I converted it using tlbexp. Then I build a header and cpp file using dumpccp. Everything works fine. The class I'm trying to access has only one memberfunction "hello". this function "returns" void. The problem is, that dumpcpp creates the following function body:


// member function implementation
#ifndef QAX_DUMPCPP_DOCXPLUGIN_NOINLINES
inline void IDocxPlugin::hello()
{
void qax_result;
void *_a[] = {(void*)&qax_result};
qt_metacall(QMetaObject::InvokeMetaMethod, 8, _a);
return qax_result;
}

Ofcourse the definition of void qax_result; causes an error. Do you know why dumpcpp produces such code?

Here's the C# class:

using System;
using System.Runtime.InteropServices;

namespace DocCreator
{
[Guid("828ED06C-E081-43EC-9AD5-32D818A24164")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
public interface IDocxPlugin
{
void hello();
}

[Guid("2D6E8981-9159-434B-82BB-3D1244903658")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("DocCreator.DocxPlugin")]
public class DocxPlugin
{
public void hello()
{
System.Console.WriteLine("Hello from .NET Component");
}
}
}

Here is the complete header:

/************************************************** **************************
**
** Namespace DocxPlugin generated by dumpcpp from type library
** DocxPlugin.tlb
**
************************************************** **************************/

#ifndef QAX_DUMPCPP_DOCXPLUGIN_H
#define QAX_DUMPCPP_DOCXPLUGIN_H

// Define this symbol to __declspec(dllexport) or __declspec(dllimport)
#ifndef DOCXPLUGIN_EXPORT
#define DOCXPLUGIN_EXPORT
#endif

#include <qaxobject.h>
#include <qaxwidget.h>
#include <qdatetime.h>
#include <qpixmap.h>

struct IDispatch;


// Referenced namespace
namespace mscorlib {
class _Type;
}


namespace DocxPlugin {


class DOCXPLUGIN_EXPORT IDocxPlugin : public QAxObject
{
public:
IDocxPlugin(IDispatch *subobject = 0, QAxObject *parent = 0)
: QAxObject((IUnknown*)subobject, parent)
{
internalRelease();
}

/*
Method hello
*/
inline void hello();

// meta object functions
static const QMetaObject staticMetaObject;
virtual const QMetaObject *metaObject() const { return &staticMetaObject; }
virtual void *qt_metacast(const char *);
};

// Actual coclasses
class DOCXPLUGIN_EXPORT DocxPlugin : public QAxObject
{
public:
DocxPlugin(QObject *parent = 0)
: QAxObject(parent)
{
setControl("{2d6e8981-9159-434b-82bb-3d1244903658}");
}

/*
Property ToString
*/
inline QString ToString() const; //Returns the value of ToString

/*
Method Equals
*/
inline bool Equals(const QVariant& obj);

/*
Method GetHashCode
*/
inline int GetHashCode();

/*
Method GetType
*/
inline mscorlib::_Type* GetType();

// meta object functions
static const QMetaObject staticMetaObject;
virtual const QMetaObject *metaObject() const { return &staticMetaObject; }
virtual void *qt_metacast(const char *);
};

// member function implementation
#ifndef QAX_DUMPCPP_DOCXPLUGIN_NOINLINES
inline void IDocxPlugin::hello()
{
void qax_result;
void *_a[] = {(void*)&qax_result};
qt_metacall(QMetaObject::InvokeMetaMethod, 8, _a);
return qax_result;
}


inline QString DocxPlugin::ToString() const
{
QVariant qax_result = property("ToString");
Q_ASSERT(qax_result.isValid());
return *(QString*)qax_result.constData();
}

inline bool DocxPlugin::Equals(const QVariant& obj)
{
bool qax_result;
void *_a[] = {(void*)&qax_result, (void*)&obj};
qt_metacall(QMetaObject::InvokeMetaMethod, 8, _a);
return qax_result;
}

inline int DocxPlugin::GetHashCode()
{
int qax_result;
void *_a[] = {(void*)&qax_result};
qt_metacall(QMetaObject::InvokeMetaMethod, 9, _a);
return qax_result;
}

inline mscorlib::_Type* DocxPlugin::GetType()
{
mscorlib::_Type* qax_result = 0;
qRegisterMetaType("mscorlib::_Type*", &qax_result);
#ifdef QAX_DUMPCPP_MSCORLIB_H
qRegisterMetaType("mscorlib::_Type", qax_result);
#endif
void *_a[] = {(void*)&qax_result};
qt_metacall(QMetaObject::InvokeMetaMethod, 10, _a);
return qax_result;
}



#endif

}

template<>
inline void *qMetaTypeCreateHelper<DocxPlugin::IDocxPlugin >(const void *t)
{ Q_ASSERT(!t); return new DocxPlugin::IDocxPlugin; }

template<>
inline void *qMetaTypeCreateHelper<DocxPlugin::DocxPlugin >(const void *t)
{ Q_ASSERT(!t); return new DocxPlugin::DocxPlugin; }

#endif



Any help is appreciated,
Stephan

stephan.storm
2nd July 2012, 17:28
Ok. I 'worked around' that problem by using a function which returns an integer value. I thought that perhaps any COM-Standard says that every function has to return a value. However the code doesn't compile. There's an unknown type mscorlib::_Type. I don't know what that is. Any suggestions? mscorlib is .NET-Stuff, isn't it. But that's exactly what I want to wrap with this code. Any suggestions?

Stephan