octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave C++ API - - Calling an m-file function of an object using its


From: Mike Miller
Subject: Re: Octave C++ API - - Calling an m-file function of an object using its octave_value in c++
Date: Tue, 23 May 2017 10:23:15 -0700
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, May 23, 2017 at 20:05:11 +0530, Abhinav Tripathi wrote:
> Hi,
> I am trying to see how to call a function of an object (octave class) in C
> API and get the result. I have tried to check the docs but couldn't find it.
> .
> For example:
> There is an octave class (either old style or classdef) named "baseclass"
> in m-file. There's an object "a" of that class. Now the m file passes it to
> c++ where it is represented by "octave_value". How to call a m-file
> function of baseclass in the c++ code to get the result?
> I tried using subsref on the octave_value but it doesn't work!

There are quite a few examples in the ov-class and ov-classdef files in
the Octave code base. The function feval is used to call any function on
Octave's load path with an argument list. The function can be specified
by a string, if you know it exists for example, or by a function handle
that you've been given, stored, or looked up.

> This is for trying something in pytave where if the octave class has a
> "_pyobject" function defined then it should be called in the c++ code.

There is actually already half an example of what you want to do in the
pytave code base, look for 'feval ("id", …' which calls the id method on
a pyobject after checking that the argument is in fact a pyobject.

Since you are not looking for a particular type, I suggest you look at
the examples in ov-class.cc that search for a particular method by name
using symbol_table::find_method and call it if it exists.

HTH,

-- 
mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]