[fpc-devel] FPC-JVM: Breaking up a cycle

Sven Barth pascaldragon at googlemail.com
Sat Aug 27 00:46:27 CEST 2011


On 27.08.2011 00:31, Jonas Maebe wrote:
>
> On 27 Aug 2011, at 00:16, Sven Barth wrote:
>
>> There is a class AVView, a class AVViewGroup and an interface AVViewManager. AVViewGroup extends AVView and implements AVViewGroup. Also it defines a nested class InnerLayoutParam.
>>
>> So far all is ok, but now the problematic part:
>> AVView and AViewManager both contain a parameter and/or result value of type AVViewGroup.InnerLayoutParam.
>>
>> Is there a way to solve this quite nasty circle?
>
> Not in a clean way. The only way you can do it is by removing AVViewGroup.InnerLayoutParam from the AVViewGroup class and declare it as an empty class up front (empty because I don't think it will be handled correctly if you add methods etc to it and try to call those later):
>
>    AVViewGroup_InnerLayoutParam = class external 'Android.V_add_rest_of_package_name' name 'ViewGroup$Layoutparam' (parentclass,parentintf1,parentintf2, ...)
>    end;
>
> And then replace all references to AVViewGroup.InnerLayoutParam with references to AVViewGroup_InnerLayoutParam.

Ok, thank you. I'll play around with that

> It's a limitation of the Pascal language compared to Java (no way to refer to inner classes before the parent class has been defined), and even if we would choose to lift it somehow (e.g. by allowing something like "AVViewGroup.InnerLayoutParam = class;" as a top level declaration) I'm not immediately sure how we to implement that efficiently in the compiler.

Well... as long as the "workaround" will work I'm rather happy :)

Regards,
Sven



More information about the fpc-devel mailing list