i have made a small wrapper with hours · Issue #15 · rtitec/tiny-js · GitHub
Skip to content

i have made a small wrapper with hours  #15

Open

Description

@GoogleCodeExporter
when add callback function,just like this:

class cboy
{
public:
    int add_age(int n) 
    {
        m_age += n;
        return m_age; 
    }

    void set_name(string name) 
    {
    }

    string do_some_thing(int n, double d, string str)
    {
        return "ok";
    }
private:
    int m_age;
};

static double mySqr(double d)
{ 
    return d*d;
}


static string myStringConcat(string strL, string strR) 
{
    return strL+strR;
}

static double myDoSomeThing(int n, double d, string str1, string str2)
{
    return n+d;
}

void test(CString str1)
{
    CTinyJS_Wrapper s;

    cboy boy;
    s.addExFun( MakeFunObj<int, Seq<int>>("add_boy_age", &boy, &cboy::add_age) );
    s.addExFun( MakeFunObj<void, Seq<string>>("set_boy_name", &boy, &cboy::set_name) );
    s.addExFun( MakeFunObj<string, Seq<int,double,string>>("boy_do_some_thing", &boy, &cboy::do_some_thing) );

    s.addExFun( MakeFunObj<double, Seq<double>>("sqr", &mySqr) );
    s.addExFun( MakeFunObj<string, Seq<string, string>>("strcon", &myStringConcat) );
    s.addExFun( MakeFunObj<double, Seq<int, double, string, string>>("do_some_thing", &myDoSomeThing) );

...
}


my email:kanbang@163.com
sorry for poor english

Original issue reported on code.google.com by kanb...@163.com on 22 Mar 2013 at 11:37

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions