[pypy-svn] r75843 - in pypy/branch/reflex-support/pypy/module/cppyy: include src
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Jul 5 18:48:08 CEST 2010
Author: cfbolz
Date: Mon Jul 5 18:48:06 2010
New Revision: 75843
Modified:
pypy/branch/reflex-support/pypy/module/cppyy/include/cppyy.h
pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx
Log:
(arigo, antocuni, wlav, cfbolz): clean up the calling of constructors.
Modified: pypy/branch/reflex-support/pypy/module/cppyy/include/cppyy.h
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/include/cppyy.h (original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/include/cppyy.h Mon Jul 5 18:48:06 2010
@@ -4,5 +4,6 @@
#include "Reflex/Type.h"
#include "Reflex/Member.h"
#include "Reflex/Object.h"
+#include "Reflex/Builder/TypeBuilder.h"
#endif // CPPYY_CPPYY
Modified: pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx (original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/src/reflexcwrapper.cxx Mon Jul 5 18:48:06 2010
@@ -1,6 +1,7 @@
#include "cppyy.h"
#include "reflexcwrapper.h"
#include <vector>
+#include <iostream>
long callstatic_l(const char* class_name, const char* method_name, int numargs, void* args[]) {
long result;
@@ -24,8 +25,20 @@
void* construct(const char* class_name, int numargs, void* args[]) {
std::vector<void*> arguments(args, args+numargs);
Reflex::Type t = Reflex::Type::ByName(class_name);
- Reflex::Object r = Reflex::Object(t, t.Allocate());
- t.FunctionMemberAt(1).Invoke(r, 0, arguments);
+ std::vector<Reflex::Type> argtypes;
+ argtypes.reserve(numargs);
+ for (int i = 0; i < numargs; i++) {
+ argtypes.push_back(Reflex::Type::ByName("int"));
+ }
+ Reflex::Type constructor_type = Reflex::FunctionTypeBuilder(
+ Reflex::Type::ByName("void"), argtypes);
+ return t.Construct(constructor_type, arguments).Address();
+ void* mem = t.Allocate();
+ memset(mem, 41, t.SizeOf());
+ Reflex::Object r = Reflex::Object(t, mem);
+ int i = 1;
+ std::cout << t.FunctionMemberAt(i).Name() << std::endl;
+ t.FunctionMemberAt(i).Invoke(r, 0, arguments);
return r.Address();
}
More information about the Pypy-commit
mailing list