Implementation of libpointer

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Implementation of libpointer

rezahousseini
Hello

I try to implement the libpointer function [1]. It is used for example in the calllib function [2]. Therefore a new type declaration is needed and I was wondering where and how to implement them. Is it correct that it need to be placed in libinterp/octave-value? And should it be some derived struct class, with fixed size, like:

    class
    octave_pointer : public octave_struct
    {
      ...
    }

Or inherit directly from octave_map?

Thanks for any advice,

Cheers Reza

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

John W. Eaton
Administrator
On 09/24/2013 05:57 AM, Reza Housseini wrote:

> Hello
>
> I try to implement the libpointer function [1]. It is used for example
> in the calllib function [2]. Therefore a new type declaration is needed
> and I was wondering where and how to implement them. Is it correct that
> it need to be placed in libinterp/octave-value? And should it be some
> derived struct class, with fixed size, like:
>
>      class
>      octave_pointer : public octave_struct
>      {
>        ...
>      }
>
> Or inherit directly from octave_map?

If you want to create a new value type in Octave, then it ultimately
needs to be derived from octave_base_value.  So deriving from
octave_struct could work.  It could also be derived directly from
octave_base_value and contain an octave_scalar_map object (or can a
libpointer object have non-scalar dimensions?)

But since it appears that the libpointer object only ever contains two
fields, maybe it should just be a separate kind of object that doesn't
use a structure for its implementation.

Is libpointer a handle class object in Matlab?  If so, you'll have some
difficulty getting full compatibility

If you are working on calllib and would eventually like for it to be a
part of Octave, maybe it would be helpful if you would share your code
with us so we could provide some early feedback.

jwe

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

rezahousseini
Thanks John

I already made a public repository [1] but it's far from complete and I didn't found time working on that recently. I just thought using the octave_struct base class because of the similar interface which matlab uses with "mypointer.Value" but probably it's also possible to have the same behaviour without the octave_struct base class. There is this lib.pointer class [2] if you mean that when talking about handle class object?




On Tue, Sep 24, 2013 at 3:40 PM, John W. Eaton <[hidden email]> wrote:
On 09/24/2013 05:57 AM, Reza Housseini wrote:
Hello

I try to implement the libpointer function [1]. It is used for example
in the calllib function [2]. Therefore a new type declaration is needed
and I was wondering where and how to implement them. Is it correct that
it need to be placed in libinterp/octave-value? And should it be some
derived struct class, with fixed size, like:

     class
     octave_pointer : public octave_struct
     {
       ...
     }

Or inherit directly from octave_map?

If you want to create a new value type in Octave, then it ultimately needs to be derived from octave_base_value.  So deriving from octave_struct could work.  It could also be derived directly from octave_base_value and contain an octave_scalar_map object (or can a libpointer object have non-scalar dimensions?)

But since it appears that the libpointer object only ever contains two fields, maybe it should just be a separate kind of object that doesn't use a structure for its implementation.

Is libpointer a handle class object in Matlab?  If so, you'll have some difficulty getting full compatibility

If you are working on calllib and would eventually like for it to be a part of Octave, maybe it would be helpful if you would share your code with us so we could provide some early feedback.

jwe


Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

John W. Eaton
Administrator
On 09/24/2013 10:42 AM, Reza Housseini wrote:
> Thanks John
>
> I already made a public repository [1] but it's far from complete and I
> didn't found time working on that recently. I just thought using the
> octave_struct base class because of the similar interface which matlab
> uses with "mypointer.Value" but probably it's also possible to have the
> same behaviour without the octave_struct base class. There is this
> lib.pointer class [2] if you mean that when talking about handle class
> object?

OK, so the lib.pointer class is what the libpointer function returns.
I'm guessing this is a handle class object.  And it's in a package
called "lib".  So to get full compatibility, we really need to do this
with a classdef object inside a package.

Also, if you are interested in having your code included in Octave,
would you please follow the Octave coding style?  It will make it easier
for us to include later.

Thanks,

jwe
Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

rezahousseini



On Tue, Sep 24, 2013 at 4:50 PM, John W. Eaton <[hidden email]> wrote:
On 09/24/2013 10:42 AM, Reza Housseini wrote:
Thanks John

I already made a public repository [1] but it's far from complete and I
didn't found time working on that recently. I just thought using the
octave_struct base class because of the similar interface which matlab
uses with "mypointer.Value" but probably it's also possible to have the
same behaviour without the octave_struct base class. There is this
lib.pointer class [2] if you mean that when talking about handle class
object?

OK, so the lib.pointer class is what the libpointer function returns. I'm guessing this is a handle class object.  And it's in a package called "lib".  So to get full compatibility, we really need to do this with a classdef object inside a package.

Also, if you are interested in having your code included in Octave, would you please follow the Octave coding style?  It will make it easier for us to include later.

Thanks,

jwe

I have no experience with classdef objects. Can you give me any implementation details?
Am I correct that the  coding style inherits to the GNU coding style?

Cheers
Reza 

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

John W. Eaton
Administrator
On 09/25/2013 10:41 AM, Reza Housseini wrote:

> I have no experience with classdef objects. Can you give me any
> implementation details?

Classdef is a new style of objects in Matlab.  It is not completely
implemented in Octave.  The current implementation is on the classdef
branch.

> Am I correct that the  coding style inherits to the GNU coding style?

Yes.  See also the contributor guidelines in the Octave manual.

jwe

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

rezahousseini



On Wed, Sep 25, 2013 at 6:50 PM, John W. Eaton <[hidden email]> wrote:
On 09/25/2013 10:41 AM, Reza Housseini wrote:

I have no experience with classdef objects. Can you give me any
implementation details?

Classdef is a new style of objects in Matlab.  It is not completely implemented in Octave.  The current implementation is on the classdef branch.


Am I correct that the  coding style inherits to the GNU coding style?

Yes.  See also the contributor guidelines in the Octave manual.

jwe


What is a package in Octave and how do I create a package? Is there any documentation available about this?
Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

Richard Crozier
On 09/10/2013 13:47, Reza Housseini wrote:
>

> What is a package in Octave and how do I create a package? Is there any
> documentation available about this?


There is information on packages, including creating them, in the manual.

http://www.gnu.org/software/octave/doc/interpreter/Packages.html#Packages

Many octave packages are hosted on SourceForge in the OctaveForge project:

http://octave.sourceforge.net/index.html

Richard

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

rezahousseini



On Wed, Oct 9, 2013 at 2:50 PM, Richard Crozier <[hidden email]> wrote:
On 09/10/2013 13:47, Reza Housseini wrote:


What is a package in Octave and how do I create a package? Is there any
documentation available about this?


There is information on packages, including creating them, in the manual.

http://www.gnu.org/software/octave/doc/interpreter/Packages.html#Packages

Many octave packages are hosted on SourceForge in the OctaveForge project:

http://octave.sourceforge.net/index.html

Richard

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


Sorry if my question wasn't that clear.
I thought Octave packages are equal to Matlab toolboxes and I was wondering how Matlab packages are represented in Octave?
Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

Richard Crozier
On 09/10/2013 13:55, Reza Housseini wrote:
>
>
> Sorry if my question wasn't that clear.
> I thought Octave packages are equal to Matlab toolboxes and I was
> wondering how Matlab packages are represented in Octave?

equal no, but similar in concept, yes, except they are free, and do not
come preinstalled by default to avoid clutter. The links I sent have
instructions for installation etc.

Virtually all of the packages available are in OctaveForge. You will
find there are some that do the same as some Matlab Toolboxes, but you
would have to investigate them yourself to see what meets your needs.

Richard

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

Michael Goffioul
On Wed, Oct 9, 2013 at 9:00 AM, Richard Crozier <[hidden email]> wrote:
On 09/10/2013 13:55, Reza Housseini wrote:


Sorry if my question wasn't that clear.
I thought Octave packages are equal to Matlab toolboxes and I was
wondering how Matlab packages are represented in Octave?

equal no, but similar in concept, yes, except they are free, and do not come preinstalled by default to avoid clutter. The links I sent have instructions for installation etc.

Virtually all of the packages available are in OctaveForge. You will find there are some that do the same as some Matlab Toolboxes, but you would have to investigate them yourself to see what meets your needs.

I think that what Reza meant with "package" is a +-folder, which is more like a namespace. There is partial support for packages in the classdef branch. What is not implemented yet is support for "import".

Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

c.-2
In reply to this post by Richard Crozier

On 9 Oct 2013, at 14:50, Richard Crozier <[hidden email]> wrote:

> On 09/10/2013 13:47, Reza Housseini wrote:
>>
>
>> What is a package in Octave and how do I create a package? Is there any
>> documentation available about this?
>
>
> There is information on packages, including creating them, in the manual.
>
> http://www.gnu.org/software/octave/doc/interpreter/Packages.html#Packages
>
> Many octave packages are hosted on SourceForge in the OctaveForge project:
>
> http://octave.sourceforge.net/index.html
>
> Richard

I think that is not what jwe was referring to ...

The confusion is generated by the fact that Octave had something called "packages"
before Matlab did then, later, Matlab used the name "package" for something different:

http://www.mathworks.it/it/help/matlab/matlab_oop/scoping-classes-with-packages.html

that's why it has been suggested to rename current Octave "packages" to a different name,
probably "bundles" will be chosen.

Reza, to use packages you need to work with the classedef branch of Octave sources.

c.
Reply | Threaded
Open this post in threaded view
|

Re: Implementation of libpointer

rezahousseini



On Wed, Oct 9, 2013 at 3:07 PM, c. <[hidden email]> wrote:

On 9 Oct 2013, at 14:50, Richard Crozier <[hidden email]> wrote:

> On 09/10/2013 13:47, Reza Housseini wrote:
>>
>
>> What is a package in Octave and how do I create a package? Is there any
>> documentation available about this?
>
>
> There is information on packages, including creating them, in the manual.
>
> http://www.gnu.org/software/octave/doc/interpreter/Packages.html#Packages
>
> Many octave packages are hosted on SourceForge in the OctaveForge project:
>
> http://octave.sourceforge.net/index.html
>
> Richard

I think that is not what jwe was referring to ...

The confusion is generated by the fact that Octave had something called "packages"
before Matlab did then, later, Matlab used the name "package" for something different:

http://www.mathworks.it/it/help/matlab/matlab_oop/scoping-classes-with-packages.html

that's why it has been suggested to rename current Octave "packages" to a different name,
probably "bundles" will be chosen.

Reza, to use packages you need to work with the classedef branch of Octave sources.

c.

Thanks all for the clarification!
I will check out the classdef branch.