logo       

Re: NULL pointers and None type: msg#00185

programming.swig

Subject: Re: NULL pointers and None type

You need to change your declaration to

class Iterator
{
public:
Iterator(CObject *O);
void Next(void);

CObject * Obj;
};

ie, you need to use pointer instead of references.

This is not a swig constrain, it is a C++ one: when
you use reference, you can't pass a null value, or
you will get a seg. fault.

Marcelo

Alexander Tournier wrote:

Hi,

Have a small problem here:
I've built an iterator:

class Iterator
{
public:
Iterator(CObject &O);
void Next(void);

CObject * Obj;
};

inline Iterator::Iterator(CObject &O) {Obj = &O;}

inline void Iterator::Next(void) {Obj = Obj->Next;}


That's fine:
but then I would like to be able to feed it a NULL pointer or a None statement so that Obj would just point to NULL.
>> I = Iterator(None)

I guess I could test before feeding the iterator anything, just wondering if there was a solution?

Any ideas???
Thanks

Alex


_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise