Re: [C++-sig] pygccxml and multidimensional arrays

2009-04-23 Thread Roman Yakovenko
On Wed, Apr 22, 2009 at 11:43 PM, Davidson, Josh  wrote:
> Is this a confirmed bug?
>
> Thanks,

I am sorry, but I am pretty busy these days ( too much production
problems and too litle people who handles them ).

I will try to take a look on your problem this evening. I will let you know.

Do you have some concrete usage example, so may be, I will be able to
provide quick work-around?

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] pygccxml and multidimensional arrays

2009-04-23 Thread Davidson, Josh
I'm using information provided by pygccxml to generate Construct objects
(http://construct.wikispaces.com/) that are capable of reading and
writing to data structures stored in shared memory.  Right now, I just
manually reverse the indices any time I detect an array type before I
generate a Construct.

Josh

-Original Message-
From: cplusplus-sig-bounces+josh.davidson=lmco@python.org
[mailto:cplusplus-sig-bounces+josh.davidson=lmco@python.org] On
Behalf Of Roman Yakovenko
Sent: Thursday, April 23, 2009 11:11 AM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] pygccxml and multidimensional arrays

On Wed, Apr 22, 2009 at 11:43 PM, Davidson, Josh
 wrote:
> Is this a confirmed bug?
>
> Thanks,

I am sorry, but I am pretty busy these days ( too much production
problems and too litle people who handles them ).

I will try to take a look on your problem this evening. I will let you
know.

Do you have some concrete usage example, so may be, I will be able to
provide quick work-around?

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] pygccxml and multidimensional arrays

2009-04-23 Thread Roman Yakovenko
On Thu, Apr 23, 2009 at 8:17 PM, Davidson, Josh  wrote:
> I'm using information provided by pygccxml to generate Construct objects
> (http://construct.wikispaces.com/) that are capable of reading and
> writing to data structures stored in shared memory.  Right now, I just
> manually reverse the indices any time I detect an array type before I
> generate a Construct.

Okey.

P.S. You have interesting project. Some time ago I was playing with
idea to generate serialize\unserialize\[upgrade] for C++ classes based
on ASN.1, but dropped it.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] pygccxml and multidimensional arrays

2009-04-23 Thread Roman Yakovenko
On Thu, Apr 23, 2009 at 9:21 PM, Roman Yakovenko
 wrote:
> On Thu, Apr 23, 2009 at 8:17 PM, Davidson, Josh  
> wrote:
>> I'm using information provided by pygccxml to generate Construct objects
>> (http://construct.wikispaces.com/) that are capable of reading and
>> writing to data structures stored in shared memory.  Right now, I just
>> manually reverse the indices any time I detect an array type before I
>> generate a Construct.
>
> Okey.

Sorry, I forgot to add, can you open bug on SourceForge project page?

Thanks.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Expanding embedded code

2009-04-23 Thread Stefan Seefeld

Robin Gilks wrote:
I'm still having a problem with the python side of things - the c++ 
side mostly makes sense. For example, the "class instances" section of 
the  page at
  
http://wiki.cacr.caltech.edu/danse/index.php/Lots_more_details_on_writing_wrappers 

I can follow with no problems but I've no idea how to invoke it from 
python with either the "wrap_new_Numbers" call or the subsequent 
"wrap_Numbers_MemberMult" call. I just don't get what the python code 
should look like to get the void pointer to the class instance at all! 
Any chance of a Python 3 liner that shows how its done?




I'm not sure what you are asking. Sticking to my example code, when you 
run the python script, 'instance' will be available in the global 
namespace, so you can make calls into it from Python. If that is not 
what you want, can you come up with another example ?


Thanks,
  Stefan

--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] Expanding embedded code

2009-04-23 Thread Robin Gilks

Stefan Seefeld wrote:


I'm not sure what you are asking. Sticking to my example code, when 
you run the python script, 'instance' will be available in the global 
namespace, so you can make calls into it from Python. If that is not 
what you want, can you come up with another example ?


Thanks,
  Stefan

The problem is my lack of Python knowledge - the 35+ years assembler 
experience doesn't seem to count!!


I've attached a minimal set of files and a make file that I hope will 
illustrate the problem. I'm generating the bindings using pybindgen 
(version 0.10.0). I hope that just typing make will show all my 
mistakes!! The test1.py python script has the questions - how do I get 
the specific instance of the class already instantiated before calling 
the script to be referenced rather than a new instance. I'm passing the 
class pointer across to the script in a PyCObject but once in the python 
domain I don't have a clue as to what to do with it!!


Note - I'm specifically using pybindgen so I can read the generated code 
- Boost makes my brain hurt...


Cheers

--
Robin





===
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
===


# All of the sources participating in the build are defined here
C_SRCS = testclass.C testif.C

OBJS = testif.o testclass.o
C_DEPS = testif.C

# All Target
all: testclass

# Tool invocations
testclass: $(OBJS) testclassgen.py
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
$(CXX)  -o "testclass" testclass.o testif.o -l python2.5
@echo 'Finished building target: $@'
@echo ' '

testif.C: testclass.H
python testclassgen.py > testif.C
   
# Other Targets
clean:
-$(RM) $(OBJS) $(C_DEPS) testclass *.pyc
-...@echo ' '

.PHONY: all clean dependents
.SECONDARY:

INCLUDES+= -I. -I /usr/include/python2.5
CXX = g++
CC = gcc

WARNFLAGS +=  -W -Wall 

DEBUGFLAGS = -g

CXXFLAGS += -pipe -funit-at-a-time $(DEBUGFLAGS) $(INCLUDES) $(DEFINES) 
$(WARNFLAGS)

===
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
 altered or corrupted during transmission.
===

'''test.py - Python source designed to demonstrate the use of python embedding'''

import testclass

class ReceiveData:

   def Receive(self, ptr, command, length, packet):
  print "Got command", command, "of length", length
  # how do I get the CObject in ptr into 'my' without creating a new instance
  my = testclass.testclass()
  # this as it is now will use another instance of testclass and return garbage
  print "Type should = 123, is = ", my.Gettype()
  print "Size should = 45, is = ", my.Getsize()
  return 0
  

  


// 1) setenv PYTHONPATH ${PYTHONPATH}:./
// 2) exe py_script class method command (int) length (int) data (string)
// eg. ./testclass test1 ReceiveData Receive 65 4 "aassddd"


#include 
#include "testclass.H"


PyMODINIT_FUNC inittestclass(void);


static void delclass(void *ptr)
{
testclass * oldclass = static_cast(ptr);
delete oldclass;
return;
}

int
main (int argc, char *argv[])
{
   PyObject *pName, *pModule, *pDict, *pClass, *pInstance, *pValue, *pCObject;

   if (argc < 5)
   {
  printf(" Not enough params\n");
  exit(1);
   }
   
   if (PyImport_AppendInittab("testclass", inittestclass) == -1)
   {
  printf("Couldn't append to initial table\n");
  return 1;
   }
   
   Py_Initialize ();
   pName = PyString_FromString (argv[1]);
   pModule = PyImport_Import (pName);
   if (PyErr_Occurred())
   {
	   PyErr_Print();
  return 1;
   }

   pDict = PyModule_GetDict (pModule);
   if (pDict == NULL)
   {
  printf ("Dictionary reference to %s not found\n", argv[1]);
  return 1;
   }

   // Build the name of a callable class 
   pClass = PyDict_GetItemString (pDict, "ReceiveData");
   if (pClass == NULL)
   {
  printf ("Class %s not found in module %s\n", "ReceiveData",