[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about `smob' generated by swig

From: Marco Maggi
Subject: Re: about `smob' generated by swig
Date: Thu, 29 Mar 2007 07:34:20 +0200

"William Xu" wrote:
> Yes, it's more like a smob type pointer. Consider this,
>    void bar(unsigned char *s)
>    {
>         printf("s = %s\n", s);
>    }
> One problem is that how i create and pass a `unsigned
> char*' parameter to `bar'. If SWIG requires me to write
> smob creation myself, that's a pain...

AFAICT you have to write a C constructor:

  unsigned char *
  make_one_thing (int dim)
     unsigned char * p = malloc(dim);

     return p;

and SWIG will generate the Scheme/C wrapper, something

  static SCM
  _wrap_make_one_thing (SCM s_0)
    unsigned char * result = 0 ;
    int arg0;
    SCM gswig_result;

    arg0 = scm_to_int(s_0);
    result = (unsigned char *)new_matrix(arg0);
    gswig_result = SWIG_NewPointerObj (result,
                      SWIGTYPE_p_unsigned_char, 0);
    return gswig_result;

so you do not have to write the SMOB driver.

Marco Maggi

"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]