diff --git a/bindings/hamlib.swg b/bindings/hamlib.swg index 5b1cce8ad..9441b92c8 100644 --- a/bindings/hamlib.swg +++ b/bindings/hamlib.swg @@ -44,6 +44,87 @@ %include cstring.i #ifdef SWIGPYTHON %include python/file.i + +%typemap(out) int [ANY] { + int len,i; + len = $1_dim0; + $result = PyList_New(len); + for (i = 0; i < len; i++) { + PyList_SetItem($result,i,PyInt_FromLong((long)$1[i])); + } +} + +%typemap(varout) int [ANY] { + int len,i; + len = $1_dim0; + $result = PyList_New(len); + for (i = 0; i < len; i++) { + PyList_SetItem($result,i,PyInt_FromLong((long)$1[i])); + } +} + +#endif + +#ifdef SWIGPERL + +%typemap(out) int [ANY] { + AV * av = newAV(); + int i = 0,len = 0; + len = $1_dim0; + + for (i = 0; i < len ; i++) { + SV* perlval = newSV(0); + sv_setiv(perlval, (IV)$1[i]); + av_push(av, perlval); + } + $result = newRV_noinc((SV *)av); + sv_2mortal( $result ); + argvi++; +} + +%typemap(argout) int [ANY] { + AV * av = newAV(); + int i = 0,len = 0; + len = $1_dim0; + + for (i = 0; i < len ; i++) { + SV* perlval = newSV(0); + sv_setiv(perlval, (IV)$1[i]); + av_push(av, perlval); + } + $result = newRV_noinc((SV *)av); + sv_2mortal( $result ); + argvi++; +} + +#endif + +#ifdef SWIGTCL + +%typemap(out) int [ANY] { + int i, len, l; + len = $1_dim0; + + Tcl_Obj * list = Tcl_NewListObj(len, NULL); + for(i=0; i < len; i++) { + Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj($1[i])); + } + Tcl_SetObjResult(interp, list); +} + +%typemap(varout) int [ANY] { + int i, len, l; + len = $1_dim0; + + Tcl_Obj * list = Tcl_NewListObj(len, NULL); + for(i=0; i < len; i++) { + Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj($1[i])); + } + + $result = list; +} + + #endif %apply double *OUTPUT { double *distance, double *azimuth }; @@ -52,8 +133,10 @@ %apply double *OUTPUT { double *longitude, double *latitude }; %apply char *OUTPUT { char *locator_res }; +#ifndef SWIG_CSTRING_UNIMPL /* longlat2locator */ %cstring_bounded_output(char *locator_res, 13) +#endif %immutable confparams::name; %immutable confparams::label; @@ -81,6 +164,10 @@ %include %include +%inline { +typedef const char * const_char_string; +} + /* * The Rig "class" */ diff --git a/bindings/perltest.pl b/bindings/perltest.pl index edd4ad654..310d657c2 100755 --- a/bindings/perltest.pl +++ b/bindings/perltest.pl @@ -40,6 +40,9 @@ $rig->set_mode($Hamlib::RIG_MODE_CW, $Hamlib::RIG_PASSBAND_NORMAL); print "ITU region:\t\t$rig->{state}->{itu_region}\n"; print "Backend copyright:\t$rig->{caps}->{copyright}\n"; +print "Model:\t\t\t$rig->{caps}->{model_name}\n"; +print "Manufacturer:\t\t$rig->{caps}->{mfg_name}\n"; +print "Backend version:\t$rig->{caps}->{version}\n"; $inf = $rig->get_info(); print "get_info:\t\t$inf\n"; @@ -62,6 +65,9 @@ print "get_channel status:\t$rig->{error_status} = ".Hamlib::rigerror($rig->{err print "VFO:\t\t\t".Hamlib::rig_strvfo($chan->{vfo}).", $chan->{freq}\n"; +$att = $rig->{caps}->{attenuator}; +print "Attenuators:\t\t@$att\n"; + print "\nSending Morse, '73'\n"; $rig->send_morse($Hamlib::RIG_VFO_A, "73"); diff --git a/bindings/pytest.py b/bindings/pytest.py index 552a926d1..05a9f81b4 100755 --- a/bindings/pytest.py +++ b/bindings/pytest.py @@ -66,6 +66,7 @@ def StartUp (): print "get_channel status:\t",my_rig.error_status print "VFO:\t\t\t",Hamlib.rig_strvfo(chan.vfo),", ",chan.freq + print "Attenuators:\t\t", my_rig.caps.attenuator print "\nSending Morse, '73'" my_rig.send_morse(Hamlib.RIG_VFO_A, "73") diff --git a/bindings/rig.swg b/bindings/rig.swg index 69d7094d6..f54b98446 100644 --- a/bindings/rig.swg +++ b/bindings/rig.swg @@ -30,7 +30,6 @@ typedef struct Rig { } Rig; typedef char * char_string; -typedef const char * const_char_string; typedef channel_t * channel_t_p; typedef channel_t * const_channel_t_p; @@ -225,7 +224,9 @@ typedef channel_t * const_channel_t_p; */ %extend Rig { +#ifndef SWIG_CSTRING_UNIMPL %cstring_bounded_output(char *returnstr, MAX_RETURNSTR); +#endif Rig(int rig_model) { Rig *r; diff --git a/bindings/rotator.swg b/bindings/rotator.swg index 9e14e0797..544d98d8f 100644 --- a/bindings/rotator.swg +++ b/bindings/rotator.swg @@ -29,8 +29,6 @@ typedef struct Rot { int do_exception; } Rot; -typedef const char * const_char_string; - %} /* diff --git a/bindings/tcltest.tcl b/bindings/tcltest.tcl index c5dd223f7..722fe279d 100755 --- a/bindings/tcltest.tcl +++ b/bindings/tcltest.tcl @@ -36,6 +36,14 @@ puts "ITU_region:\t[$state cget -itu_region]" # The following works well also # puts ITU_region:[[my_rig cget -state] cget -itu_region] +set rigcaps [my_rig cget -caps] +#set model [$rigcaps cget -model_name] +puts "Model:\t\t[$rigcaps cget -model_name]" +puts "Manufacturer:\t\t[$rigcaps cget -mfg_name]" +puts "Backend version:\t[$rigcaps cget -version]" +puts "Backend license:\t[$rigcaps cget -copyright]" +puts "Attenuators:\t[$rigcaps cget -attenuator]" + puts "getinfo:\t[my_rig get_info]" my_rig set_level "VOX" 1