Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
20.9.2014 - We have just updated our course layouts and descriptions and added our 2015 schedule.

not able to access accessor function generated by

Posted by varun (varun), 4 June 2007
i m learning python language and
'm just getting started with swig and quickly ran into my first problem.

struct Vector {
       double x,y,z;
};

I created a test.h file which includes only this definition
every thing went successfully while compiling
but i m not able to access the accessor functions automatically generated by swig

following error message is displayed

>>> struct_vector.vector.x.get()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
AttributeError: 'property' object has no attribute 'get'

the swig generated function for variable x looks like

Code:
          SWIGINTERN PyObject *_wrap_vector_x_get(PyObject    
          *SWIGUNUSEDPARM(self), PyObject *args) {
2438   PyObject *resultobj = 0;
2439   struct vector *arg1 = (struct vector *) 0 ;
2440   double result;
2441   void *argp1 = 0 ;
2442   int res1 = 0 ;
2443   PyObject * obj0 = 0 ;
2444
2445   if (!PyArg_ParseTuple(args,(char *)"O:vector_x_get",&obj0))
          SWIG_fail;
2446   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_vector, 0 |
           0 );
2447   if (!SWIG_IsOK(res1)) {
2448     SWIG_exception_fail(SWIG_ArgError(res1), "in method '"
           "vector_x_get" "', argument " "1"" of type '" "struct vector *""'");
2449   }
2450   arg1 = (struct vector *)(argp1);
2451   result = (double) ((arg1)->x);
2452
2453   resultobj = SWIG_From_double((double)(result));
2454   return resultobj;
2455 fail:
2456   return NULL;
2457 }



please help
is there something i should write into .i (interface file)
Code:

 1 %module struct_vector
 2 %{
 3 #include <stdio.h>
 4 # include "struct_vector.h"
 5 extern int abc();
 6 %}
 7
 8
 9 extern int abc();


Posted by admin (Graham Ellis), 5 June 2007
I notice that you're just "learning the Python language" .... and I have to say that SWIG (interfacing it to C) is really not where I would have chosen to start  .

We do a lot - a VERY great deal - of worth with Python here, but the C interfacing stuff is something that crops up about as often as a blue moon and I really don't feel qualified to offer good advise.   Do you really need to interface via SWIG?



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho