rig.swg: New properly formatted macro

I made a patch, you can see in that there is the solution, which
describe the error: if a function in hamlib looks 3 argument
(rig, vfo, any 3rd arg), the order of the 2nd and 3rd argument
were reversed, because the macro METHOD1 reversed them.

I've collected these functions, compared its arguments with
hamlib docs (http://hamlib.sourceforge.net/manuals/1.2.15/), and
where 1st arg is rig, 2nd arg is vfo, and 3rd is any kind of
type, changed to METHOD3, which is a new macro, and keeps the
correct order of original function - see the patch. (I didn't
find any info about the expected diff format, so I just created
the `diff -uprN ORIG NEW'.)

To check my theory, I've tested with another function, which uses
vfo type at 2nd argument, eg. rig_set_freq; here is the Python
code:

  my_rig.set_freq(Hamlib.RIG_VFO_A, 7013200.0)

and the original code drop the exception:

    my_rig.set_freq(Hamlib.RIG_VFO_A, 7012500.0)
  File "/usr/local/lib/python2.7/dist-packages/Hamlib.py", line 2513, in
set_freq
    def set_freq(self, *args): return _Hamlib.Rig_set_freq(self, *args)
TypeError: in method 'Rig_set_freq', argument 3 of type 'vfo_t'

As you can see, it's same as my original error above.

So, after I patched the source and recompiled it again, these two
function works correctly - I will test it at soon, but I think
_this_ is good and stable.

Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
Hamlib-3.0
Ervin Hegedüs 2013-02-12 21:43:19 +01:00 zatwierdzone przez Nate Bargmann
rodzic 7e9f628648
commit d9fc9c04d7
3 zmienionych plików z 30 dodań i 33 usunięć

Wyświetl plik

@ -64,14 +64,6 @@
%include <hamlib/rotlist.h>
%include <hamlib/rotator.h>
/* needed because rig.swg and rotator.swg macros require identifiers like arg (no spaces) */
%header %{
typedef char * char_string;
typedef const char * const_char_string;
typedef channel_t * channel_t_p;
typedef channel_t * const_channel_t_p;
%}
/*
* The Rig "class"
*/
@ -90,5 +82,3 @@
%include "python.i"
%include "whatever.i"
*/

Wyświetl plik

@ -29,6 +29,11 @@ typedef struct Rig {
int do_exception;
} Rig;
typedef char * char_string;
typedef const char * const_char_string;
typedef channel_t * channel_t_p;
typedef channel_t * const_channel_t_p;
%}
%extend channel {
@ -54,7 +59,7 @@ typedef struct Rig {
%array_class(tone_t, toneArray);
/*
* decalre wrapper method with one argument besides RIG* and optional no target vfo
* declare wrapper method with one argument besides RIG* and optional no target vfo
*/
#define METHOD1(f, t1) void f (t1 _##t1 _VFO_DECL) \
{ self->error_status = rig_##f(self->rig _VFO_ARG, _##t1); }
@ -62,15 +67,16 @@ typedef struct Rig {
{ self->error_status = rig_##f(self->rig _VFO_ARG, _##t1##_1, _##t2##_2); }
#define METHOD2_INIT(f, t1, t2, i2) void f (t1 _##t1##_1, t2 _##t2##_2 = i2 _VFO_DECL) \
{ self->error_status = rig_##f(self->rig _VFO_ARG, _##t1##_1, _##t2##_2); }
#define METHOD3(f, t1) void f ( vfo_t vfo, t1 _##t1) \
{ self->error_status = rig_##f(self->rig _VFO_ARG, _##t1); }
/*
* decalre wrapper method with one output argument besides RIG* (no target vfo)
* declare wrapper method with one output argument besides RIG* (no target vfo)
*/
#define METHOD1GET(f, t1) t1 f (void) \
{ t1 _##t1; self->error_status = rig_##f(self->rig, &_##t1); return _##t1; }
/*
* decalre wrapper method with one output argument besides RIG* and vfo
* declare wrapper method with one output argument besides RIG* and vfo
*/
#define METHOD1VGET(f, t1) t1 f (vfo_t vfo = RIG_VFO_CURR) \
{ t1 _##t1; self->error_status = rig_##f(self->rig, vfo, &_##t1); return _##t1; }
@ -267,28 +273,28 @@ typedef struct Rig {
#define _VFO_ARG ,vfo
#define _VFO_DECL ,vfo_t vfo = RIG_VFO_CURR
METHOD1(set_freq, freq_t)
METHOD3(set_freq, freq_t)
METHOD2_INIT(set_mode, rmode_t, pbwidth_t, RIG_PASSBAND_NORMAL)
METHOD1(set_ptt, ptt_t)
METHOD1(set_rptr_shift, rptr_shift_t)
METHOD1(set_rptr_offs, shortfreq_t)
METHOD1(set_ctcss_tone, tone_t)
METHOD1(set_dcs_code, tone_t)
METHOD1(set_ctcss_sql, tone_t)
METHOD3(set_ptt, ptt_t)
METHOD3(set_rptr_shift, rptr_shift_t)
METHOD3(set_rptr_offs, shortfreq_t)
METHOD3(set_ctcss_tone, tone_t)
METHOD3(set_dcs_code, tone_t)
METHOD3(set_ctcss_sql, tone_t)
METHOD1(set_dcs_sql, tone_t)
METHOD1(set_split_freq, freq_t)
METHOD3(set_split_freq, freq_t)
METHOD2_INIT(set_split_mode, rmode_t, pbwidth_t, RIG_PASSBAND_NORMAL)
METHOD2(set_split_vfo, split_t, vfo_t)
METHOD1(set_rit, shortfreq_t)
METHOD1(set_xit, shortfreq_t)
METHOD1(set_ts, shortfreq_t)
METHOD1(set_ant, ant_t)
METHOD3(set_rit, shortfreq_t)
METHOD3(set_xit, shortfreq_t)
METHOD3(set_ts, shortfreq_t)
METHOD3(set_ant, ant_t)
METHOD2(set_func, setting_t, int)
METHOD1(set_bank, int)
METHOD1(set_mem, int)
METHOD1(send_dtmf, const_char_string)
METHOD1(send_morse, const_char_string)
METHOD1(vfo_op, vfo_op_t)
METHOD3(set_bank, int)
METHOD3(set_mem, int)
METHOD3(send_dtmf, const_char_string)
METHOD3(send_morse, const_char_string)
METHOD3(vfo_op, vfo_op_t)
METHOD2(scan, scan_t, int)
METHODSIMPLESET(level, int, i, RIG_LEVEL_IS_FLOAT(stg))
METHODSIMPLESET(level, float, f, !RIG_LEVEL_IS_FLOAT(stg))
@ -521,4 +527,3 @@ struct channel *Rig_get_chan_all(Rig *self)
}
%}

Wyświetl plik

@ -29,10 +29,12 @@ typedef struct Rot {
int do_exception;
} Rot;
typedef const char * const_char_string;
%}
/*
* decalre wrapper method with 0,1,2 arguments besides ROT*
* declare wrapper method with 0,1,2 arguments besides ROT*
*/
#define ROTMETHOD0(f) void f () \
{ self->error_status = rot_##f(self->rot); }