ffpython icon indicating copy to clipboard operation
ffpython copied to clipboard

Calling from C++ a C++ reg function by name

Open marriusco opened this issue 3 years ago • 1 comments

How do I do this ?

        FFPython ffpython;
	
        ffpython.regClass<Foo(int)>("Foo")
		.regMethod(&Foo::getValue, "getValue")
		.regMethod(&Foo::setValue, "setValue")
		.regMethod(&Foo::testStl, "testStl")
		.regField(&Foo::nValue, "nValue");

         

Then I want to call from C++

     int rv = ffpython.call????<int>("module_name", "getValue");  
     ffpython.call????<int>("module_name", "setValue", 55);

Thank you

marriusco avatar Aug 29 '22 16:08 marriusco

you mean like this: ffpython.call<Foo*>("ffpython", "Foo", 123) ?

ffpython.call to call python module function ffpython.regClass lets python can call c++ code for example: my.cpp: ffpython.regClass<Foo(int)>("Foo") .regMethod(&Foo::getValue, "getValue")

	ffpython.call<int>("my", "runPyFunc", args....)
my.py
	def runPyFunc(....):
		import ffpython
		foo = ffpython.Foo(20130426)
		return foo.getValue()

fanchy avatar Sep 28 '22 08:09 fanchy