octave-maintainers
[Top][All Lists]
Advanced

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

Re: Learning the Octave interpreter code to implement Java class dot-ref


From: Hossein Sajjadi
Subject: Re: Learning the Octave interpreter code to implement Java class dot-referencing
Date: Sat, 11 Jul 2020 18:31:38 +0430

On 7/8/20, Andrew Janke <floss@apjanke.net> wrote:
> Hi, Octave maintainers,
>
> A while ago, I took a stab at adding support for dot-reference syntax
> for Java classes. (https://savannah.gnu.org/bugs/index.php?41239) I
> totally failed, because I don't understand the Octave interpreter code
> well enough, and don't have bison/yacc skills.
>
> Can anyone point me at resources for learning about the Octave
> interpreter code, or bison/yacc generically, that would help me get good
> enough to write a patch for this?
>
> Cheers,
> Andrew
>
>

Backed by developing Octave Coder here are my insights  when trying to
create an external language interface for python and before placing it
in my TODO queue (The same concepts here are applied to java):
For each java class/ package used in an expression an equivalent
Octave classdef class / package is generated on the fly. Each class
has a data member of type ov-java.h/octave_java that holds the
underlying java object. The generated class only contains public
members. Those on the fly classes can be written to disk as .m
classdef files using a code generator. That is a simple solution but
the best and the more complex solution  is, creating in-memory
classdef classes.
For it you need to work with functions in ov-classdef.h and
ov-classdef.cc and finally use ov-classdef.h/cdef_manager to register
new on the fly packages and classes.
I'm not sure but I think some functions in ov-classdef.h have been
made private that may make that difficult. If you encounter problems
you may need help from admin to make those methods public.

When you complete developing such an interface there is no need to
have special rules to evaluate indexing expressions containing java
objects (base_expr_val.isjava () in libinterp/pt-eval.cc) and java
objects are evaluated like other classdef objects.

This idea can be extended further and an Octave classdef object that
is inherited from base java object can be sent to java. But it
requires that on-the-fly java classes are generated from octave
classdef classes.
-- 

Sincerely,
Hossein



reply via email to

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