tcl quick interface question

Jim McNamara <[email protected]> Fri, 3 Dec 2021 04:30:45 -0500
Newsgroups gmane.comp.programming.swig
Message-ID <CAEMWCRv97SYVXy7vd6fFUm4_xnDqWrtG=jSAi21BNaiBymaqBg@mail.gmail.com>
Hi-

I thought i put the right template to return the results to tcl but it is
acting quirky or I am making a mistake.

I thought I could put :

set x1 0
set y1 0

set a [rowcol $x1 $y1]

i get this for an error:

Wrong # args.:rowcol  argument 1.

I got the link for the apply typemaps here: Argument Handling (swig.org)
<http://www.swig.org/Doc4.0/Arguments.html>

I checked my c++ code and it is working. All I have to do is switch from
building an .exe in my project to yield the right results in the c++
console. When I switch it back to build a .dll, copy it to my tcl source
directory, and load the dll, it gives this error msg when I source and run
the tcl.

Am I missing something? Interface file below... I figure I must be doing
something wrong because it would break peoples swig projects.
I am building the code to interface to tablelist in TK to dynamically get
the rows and columns and display a tablelist without hard coding the rows
and columns into my application. The other code not shown here is just a
small section of demo code based on the tablelist programmer's guide I am
tinkering with.

Thanks!
roboloki

/* File : example.i */
%module korn
%include "std_vector.i"
%include "std_string.i"
%include "typemaps.i"
%apply int *OUTPUT { int *r, int *c };
%template(ransomVec) std::vector<std::string>;

%{
/* Put headers and other declarations here */
std::vector<std::string> colnames2();
std::vector<std::string> myflds();

int rowcol(int * r, int * c);

%}
std::vector<std::string> colnames2();
std::vector<std::string> myflds();

int rowcol(int * r, int * c);

c++ code:

int rowcol(int* r, int* c) {

    try
    {

        session sql(backEnd, "dbname=firestorm user=postgres
password=mypasswd");

        int i;
        soci::row v;

        statement st = (sql.prepare << "select fld1 from a1 order by fld1",
into(v));
        //soci::statement st = (sql.prepare << "SELECT * FROM SYS.USER$",
into(v));
        st.execute(true);  /* with data exchange */
        unsigned int num_fields = v.size();
        cout << "fields: " << num_fields << endl;
        num_fields = (num_fields <= 9) ? num_fields : 9;
        unsigned long num_rows = (unsigned long)st.get_affected_rows();
        cout << "rows: " << num_rows << endl;

        *c = num_fields;
        *r = num_rows;

        return 0;

    }
        catch (exception const& e)
        {
            cerr << "Error: " << e.what() << '\n';
        }

}

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user