• [Incr Tcl] and configbody concepts

    From David Gravereaux@davygrvy@pobox.com to comp.lang.tcl on Sat Apr 20 16:46:37 2024
    From Newsgroup: comp.lang.tcl

    Hi,

    I'm writing an [Incr Tcl] extension to an API that uses quite a lot of
    Set/Get calls:

    PMDCFunc PMDSetProfileMode (PMDAxisInterface axis_intf,
    PMDuint16 mode);
    PMDCFunc PMDGetProfileMode (PMDAxisInterface axis_intf,
    PMDuint16* mode);
    PMDCFunc PMDSetPosition (PMDAxisInterface axis_intf,
    PMDint32 position);
    PMDCFunc PMDGetPosition (PMDAxisInterface axis_intf,
    PMDint32* position);
    PMDCFunc PMDSetVelocity (PMDAxisInterface axis_intf,
    PMDint32 velocity);
    PMDCFunc PMDGetVelocity (PMDAxisInterface axis_intf,
    PMDint32* velocity);
    ...etc.

    The hooks are currently set as this sourced from the pkgIndex:


    load [file join [file dirname [info script]] CMoTcl10.[info sharedlibextension]]

    itcl::class ::pmd::cmotion {
    constructor {} { _init }
    destructor { _destroy }
    public {
    method GetCMotionVersion {} @CMo-GetCMotionVersion

    # Profile Generation
    method SetProfileMode {} @CMo-SetProfileMode
    method GetProfileMode {} @CMo-GetProfileMode
    method SetPosition {} @CMo-SetPosition
    method GetPosition {} @CMo-GetPosition
    method SetVelocity {} @CMo-SetVelocity
    method GetVelocity {} @CMo-GetVelocity
    ...


    Is there a way to use configbody to differentiate the [G|S]et calls? IOW,

    $instance config -ProfileMode

    routes to PMDGetProfileMode() for returning the value and

    $instance config -ProfileMode <somevalue>

    routes to PMDSetProfileMode() for setting it? Thanks in advance. https://github.com/davygrvy/CMoTcl

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Gravereaux@davygrvy@pobox.com to comp.lang.tcl on Sat Apr 20 17:27:51 2024
    From Newsgroup: comp.lang.tcl

    Maybe with
    itcl::configbody ProfileMode @CMo-somefunc

    $instance config -ProfileMode ?someValue?

    will get called with objc of 2 for a value (a set) or 1 with nothing (a
    get). I will check
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From David Gravereaux@davygrvy@pobox.com to comp.lang.tcl on Sun Apr 21 02:06:57 2024
    From Newsgroup: comp.lang.tcl

    My concept is completely off. I think I'm conceptualizing
    Tcl_TraceVar() with the TCL_TRACE_READS and TCL_TRACE_WRITES flags.

    This won't do what I think it does:

    itcl::class foo {
    public variable ProfileMode @myGetSetProc
    }
    --- Synchronet 3.20a-Linux NewsLink 1.114