I didn't found a feature request, which describes my problem.
I want to do something like this:
Code: Select all
Interface bla
test1(List())
test2(Array(1))
EndInterface
Code: Select all
Procedure test1(List())
EndProcedure
Procedure test2(Array(1))
EndProcedure
Code: Select all
Interface foo
destroy()
addList(List.l())
getList(List.l())
EndInterface
Structure foo_s
*VTable
count.l
*mem
EndStructure
Procedure foo_create()
Protected *foo.foo_s
*foo = AllocateMemory(SizeOf(foo_s))
If Not *foo : ProcedureReturn #False : EndIf
*foo\VTable = ?foo_VTable
ProcedureReturn *foo
EndProcedure
Procedure foo_destroy(*foo.foo_s)
If *foo\mem : FreeMemory(*foo\mem) : EndIf
FreeMemory(*foo)
EndProcedure
Procedure foo_addList(*foo.foo_s, List.l())
Protected toadd.l = CountList(List()), *tmp.Long, i.l
If Not toadd : ProcedureReturn #True : EndIf
*tmp = ReAllocateMemory(*foo\mem, (*foo\count + toadd) * SizeOf(Long))
If Not *tmp : ProcedureReturn #False : EndIf
*foo\mem = *tmp
*tmp + SizeOf(Long) * *foo\count
ForEach List()
*tmp\l = List()
*tmp + SizeOf(Long)
Next
*foo\count + toadd
ProcedureReturn #True
EndProcedure
Procedure foo_getList(*foo.foo_s, List.l())
Protected *p.Long, i.l
ClearList(List())
*p = *foo\mem
i = *foo\count
While i
If AddElement(List())
List() = *p\l
EndIf
*p + SizeOf(Long)
i - 1
Wend
ProcedureReturn #True
EndProcedure
DataSection
foo_VTable:
Data.l @foo_destroy(), @foo_addList(), @foo_getList()
EndDataSection
Define foo.foo, i.l
NewList elements.l()
For i = 0 To 3
If AddElement(elements())
elements() = i
EndIf
Next
foo = foo_create()
;-begin
;add the list 3 times
foo\addList(elements())
foo\addList(elements())
foo\addList(elements())
;gets the 3-times-list
foo\getList(foo, elements())
;-end
; ;add the list 3 times
; foo_addList(foo, elements())
; foo_addList(foo, elements())
; foo_addList(foo, elements())
;
; ;gets the 3-times-list
; foo_getList(foo, elements())
;debug the list
ForEach elements()
Debug elements()
Next
foo\destroy()
and the lines between ';-begin' and ';-end' out and decomment the
following lines to see, what should happen.