Training, Open Source computer languages

This is page http://www.wellho.net/forum/Programm ... -Ruby/not-able-to-access-accessor-function-generated-by.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

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