[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: g-wrap Question
From: |
Puneet |
Subject: |
Re: g-wrap Question |
Date: |
Wed, 18 Apr 2007 11:51:32 +0530 |
Thanks for your kind support on this wonderful tool.
I'm not sure I understand. Can you provide source code?
Consider the following type definitions ....
typedef struct vp_tm
{
int tp;
double ffb;
} s_vp_tm, *p_vp_tm;
typedef struct vp_dly
{
struct vp_tm *da;
int ndlys;
void *n;
} s_vp_dly, *p_vp_dly;
Corresponding to s_vp_tm, I inherit from <gw-guile-rti-type>. This I understand.
Corresponding to p_vp_tm, I use add-as-wct! and I understand that
g-wrap creates an smob
type for the same.
Now the problem is that when I create a wrapper for type vp_dly, I
need to have an access to the smob type corresponding to p_vp_tm (this
is for describing element da). This I overcame by storing the type
returned by add-as-wct! and using the value for slot wct-var-name to
access the smob corresponding to p_vp_tm.
(define-class <vp-tm> (<gw-guile-rti-type>))
(define-class <vp-dly> (<gw-guile-rti-type>))
(define-method (initialize (ws <vp-ws>) initargs)
(next-method)
(let ((p-vp-tm-type
(wrap-as-wct! ws
#:name '<p-vp-tm>
#:c-type-name "p_vp_tm"
#:c-const-type-name "const p_vp_tm"
)))
(add-type! ws (make <vp-dly>
#:name 'vp:dly
#:c-type-name "s_vp_dly"
#:c-const-type-name "const s_vp_dly"
#:ffspec 'ulong
))
(define-method (unwrap-value-cg (type <vp-dly>)
(value <gw-value>) error-var)
(let ((scm-var (scm-var value))
(c-var (var value))
(ctype (c-type-name type))
(vp-tm-wct-var (slot-ref p-vp-tm-type 'wct-var-name)))
(list
"if (!scm_vp_dly_p(" scm-var"," vp-tm-wct-var "))"
`(gw:error ,error-var type ,(wrapped-var value))
"else\n"
c-var " = (" ctype ") scm_vp_dly_to_c(" scm-var","
vp-tm-wct-var");\n")))
...................
Note that I am storing the wct-var-name into variable vp-tm-wct-var
and passing it to my conversion function scm_vp_dly_to_c. This I do
because I want to wrap the 'vp_dly *da' element as an smob.
Am I doing it right? And is it the only way I can do that??
And what about void*. You have declared a gw:void* type in the
standard.scm. But since my use of void* is embedded in another
structure, I need to have access to the smob corresponding to the type
<gw:void*>. Right now I am working around the problem by having my own
add-as-wct! for the void* -- the same way I have done for p_vp_tm.
Two more quick questions.
1. What to provide for ffspec for structs? The tool gives an error if
I do not provide ffspec. I am arbitrarily putting 'ulong for now.
2. Does g-wrap support wrapping functions with variable number of
arguments (ellipsis)?
Thanks once more ....
Puneet