Author Topic: list of inherited objects  (Read 388 times)

claude

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
    • mathr.co.uk
list of inherited objects
« on: May 01, 2019, 02:46:37 PM »
Trying to compile an old AmigaE project, I have fixed lots of FLOAT issues, and annoying `ENDPROC SUPER self.end()` issues complaining about bad number of return values (similarly Throw() has 0 return values when it should have any type at all), and finally got stuck with this big problem:

Code: [Select]
ERROR: list of inherited objects is not supported
Hint: but please let me know that you need this feature.

My code is in a git repository, browse here: https://code.mathr.co.uk/slab/tree/97213a5702c8422909839e98ac186a28207408f4 git clone https://code.mathr.co.uk/slab.git ; cd slab ; git checkout portable

I am using the Windows compiler in WINE on Linux:
Code: [Select]
code.mathr.co.uk/slab/Source$ ~/.wine/drive_c/PortablE/bin/PortablE.exe main.e OS=AROS OPTAMIGAE OPTPOINTER
Target OS=AROS, language=CPP.
Loading module 'Z:/home/claude/code/code.mathr.co.uk/slab/Source/main'.
Loading module 'z:/home/claude/code/code.mathr.co.uk/slab/source/cli'.
Loading module 'z:/home/claude/code/code.mathr.co.uk/slab/source/kernel'.
Parsing module 'z:/home/claude/code/code.mathr.co.uk/slab/source/kernel'.     

ERROR: list of inherited objects is not supported
LINE 61: #define __addclass(name,func) add(self.classes, NEW [ NIL, NIL, 'name', CALLBACK func() ] : ##classnode##)
 Hint: but please let me know that you need this feature.

PortablE

  • Moderator
  • Newbie
  • *****
  • Posts: 5
  • Karma: +0/-0
    • The homepage of Chris Handley
Re: list of inherited objects
« Reply #1 on: May 19, 2019, 06:44:17 PM »
Hi

Sorry I didn't see your reply earlier.  GMail isn't very good at telling me I've got new email, since I switched to having different categories for my Inbox :-/

It looks like this code:
Code: [Select]
NEW [ NIL, NIL, 'name', CALLBACK func() ] : classnode
is being used to create a new object.

Because you are using the "OPTAMIGAE" switch, I think (I may be wrong) it's automatically making all objects be CLASSes (i.e. inherit from the "class" object).
This unfortunately means you run into a PortablE limitation, where it doesn't allow arrays/lists of class objects.  In reality you are only creating a single new class object, so you shouldn't really get this error, but I don't have time to fix PortablE at the moment, so the best I can suggest is some work-arounds. 

The simplest work-around is (probably) to get rid of that OPTAMIGAE switch, and instead add OPT AMIGAE at the top of each module *except* for the "list.e" module (which defines the parent "node" object).  With luck that will solve your problem (you will also need to tweak the "list.e" module to use PortablE syntax, e.g. get rid of EXPORT).
 

But if that doesn't solve your problem, then you might need to do small rewriting of your code.  Looking at the definition of "classnode" I see:
Code: [Select]
EXPORT OBJECT classnode OF node
newf    : LONG
ENDOBJECT

While "node" is defined in the "list.e" module as:
Code: [Select]
OBJECT node
next    : PTR TO node
prev    : PTR TO node
name    : PTR TO CHAR
ENDOBJECT

So what I suggest is that you change how new objects (like "classnode") are created.  Let's have a procedure call do the job instead.  In the "classnode.e" module add this:
Code: [Select]
PROC new_classnode(next:PTR TO node, prev:PTR TO node, name:PTR TO CHAR, newf:LONG) RETURNS self:PTR TO classnode
NEW self
self.next := next
self.prev := prev
self.name := name
self.newf := newf
ENDPROC

Then replace this code:
Code: [Select]
NEW [ NIL, NIL, 'name', CALLBACK func() ] : classnode
With this:
Code: [Select]
new_classnode( NIL, NIL, 'name', CALLBACK func() )
The above code is untested, but should work (!).  Let me know how you get on!
« Last Edit: May 19, 2019, 06:47:40 PM by PortablE »
ChrisH
--
Author of the PortablE programming language.

claude

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
    • mathr.co.uk
Re: list of inherited objects
« Reply #2 on: May 20, 2019, 04:09:22 PM »
So what I suggest is that you change how new objects (like "classnode") are created.  Let's have a procedure call do the job instead.

Thanks!  With that change and a couple of other small fixes PortablE.exe in WINE now successfully compiles my project to a C++ source file for AROS. Next step is setting up a C++ cross-compiler from Linux to AROS.

PortablE

  • Moderator
  • Newbie
  • *****
  • Posts: 5
  • Karma: +0/-0
    • The homepage of Chris Handley
Re: list of inherited objects
« Reply #3 on: May 20, 2019, 07:40:20 PM »
Hi

Is there any reason for not compiling C++ directly on AROS?
ChrisH
--
Author of the PortablE programming language.