SWC compilation marks all methods as public

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

SWC compilation marks all methods as public

Cameron D
Hello everyone,

I've been working on a small project in haXe for the Flash platform. I compiled my classes into an SWC file so that it can be used by AS3 code written within, say, the Flash IDE. It all works great, but every method and property in the SWC's ABC byte-code is marked as public (even the ones that were originally private in haXe). Because 90% of my methods and variables are private, it makes for a confusing (and potentially hazardous) auto-complete drop-down for the end developer.

I understand that this was done on purpose for better compatibility, and is not a bug. However, I was wondering if there's a way to turn off this behaviour? If there isn't, could such an option be added?

Thanks,
Cameron

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: SWC compilation marks all methods as public

luca deltodesco
you can use the @:protected metadata before fields/methods which will make them be compiled as private values in the SWC, but you need to be aware that this can easily break your code as the private/public property seems to be enforced at runtime in the flash player, so you 'cannot' make an inline method protected for instance, nor can you inline any method which calls protected methods or accesses protected fields as it causes flash player to throw a runtime error abuot accessing a private attribute! (yaay)

For nape, I ended up having a 'public' and 'private' package, and apart from some extra internal classes, every class has a public and private side of things. the public side providing an interface to the private inner object so that the only field cluttering drop down menus and such as a single 'zpp_inner' field which appears at the bottom of the list to reference the inner type.


From: [hidden email]
Date: Fri, 2 Sep 2011 01:52:09 -0400
To: [hidden email]
Subject: [haXe] SWC compilation marks all methods as public

Hello everyone,

I've been working on a small project in haXe for the Flash platform. I compiled my classes into an SWC file so that it can be used by AS3 code written within, say, the Flash IDE. It all works great, but every method and property in the SWC's ABC byte-code is marked as public (even the ones that were originally private in haXe). Because 90% of my methods and variables are private, it makes for a confusing (and potentially hazardous) auto-complete drop-down for the end developer.

I understand that this was done on purpose for better compatibility, and is not a bug. However, I was wondering if there's a way to turn off this behaviour? If there isn't, could such an option be added?

Thanks,
Cameron

-- haXe - an open source web programming language http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SWC compilation marks all methods as public

Cameron D
Excellent, thank you! I went with a public wrapper with a haxe-private "__impl" member of a @:protected private implementation class in the same module.

It works perfectly, and clears the interface up beautifully!

It still boggles my mind that protected is enforced at run-time (no wonder function calls are slow) even from functions within the same class (I don't quite understand why that seems to only affect inlined methods, though).

On Fri, Sep 2, 2011 at 4:54 AM, luca deltodesco <[hidden email]> wrote:
you can use the @:protected metadata before fields/methods which will make them be compiled as private values in the SWC, but you need to be aware that this can easily break your code as the private/public property seems to be enforced at runtime in the flash player, so you 'cannot' make an inline method protected for instance, nor can you inline any method which calls protected methods or accesses protected fields as it causes flash player to throw a runtime error abuot accessing a private attribute! (yaay)

For nape, I ended up having a 'public' and 'private' package, and apart from some extra internal classes, every class has a public and private side of things. the public side providing an interface to the private inner object so that the only field cluttering drop down menus and such as a single 'zpp_inner' field which appears at the bottom of the list to reference the inner type.


From: [hidden email]
Date: Fri, 2 Sep 2011 01:52:09 -0400
To: [hidden email]
Subject: [haXe] SWC compilation marks all methods as public


Hello everyone,

I've been working on a small project in haXe for the Flash platform. I compiled my classes into an SWC file so that it can be used by AS3 code written within, say, the Flash IDE. It all works great, but every method and property in the SWC's ABC byte-code is marked as public (even the ones that were originally private in haXe). Because 90% of my methods and variables are private, it makes for a confusing (and potentially hazardous) auto-complete drop-down for the end developer.

I understand that this was done on purpose for better compatibility, and is not a bug. However, I was wondering if there's a way to turn off this behaviour? If there isn't, could such an option be added?

Thanks,
Cameron

-- haXe - an open source web programming language http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SWC compilation marks all methods as public

Yanis Benson

If you access private method/field from inlined method it is ok and all logical. But when the inlining takes places, this access can happen from whatever place you accessed you inlined method from and in most cases the field/method you access won't be accessible anymore.

On 3 Sep 2011 03:45, "Cameron D" <[hidden email]> wrote:
> Excellent, thank you! I went with a public wrapper with a haxe-private
> "__impl" member of a @:protected private implementation class in the same
> module.
>
> It works perfectly, and clears the interface up beautifully!
>
> It still boggles my mind that protected is enforced at run-time (no wonder
> function calls are slow) even from functions within the same class (I don't
> quite understand why that seems to only affect inlined methods, though).
>
> On Fri, Sep 2, 2011 at 4:54 AM, luca deltodesco <[hidden email]>wrote:
>
>> you can use the @:protected metadata before fields/methods which will make
>> them be compiled as private values in the SWC, but you need to be aware that
>> this can easily break your code as the private/public property seems to be
>> enforced at runtime in the flash player, so you 'cannot' make an inline
>> method protected for instance, nor can you inline any method which calls
>> protected methods or accesses protected fields as it causes flash player to
>> throw a runtime error abuot accessing a private attribute! (yaay)
>>
>> For nape, I ended up having a 'public' and 'private' package, and apart
>> from some extra internal classes, every class has a public and private side
>> of things. the public side providing an interface to the private inner
>> object so that the only field cluttering drop down menus and such as a
>> single 'zpp_inner' field which appears at the bottom of the list to
>> reference the inner type.
>>
>> ------------------------------
>> From: [hidden email]
>> Date: Fri, 2 Sep 2011 01:52:09 -0400
>> To: [hidden email]
>> Subject: [haXe] SWC compilation marks all methods as public
>>
>>
>> Hello everyone,
>>
>> I've been working on a small project in haXe for the Flash platform. I
>> compiled my classes into an SWC file so that it can be used by AS3 code
>> written within, say, the Flash IDE. It all works great, but every method and
>> property in the SWC's ABC byte-code is marked as public (even the ones that
>> were originally private in haXe). Because 90% of my methods and variables
>> are private, it makes for a confusing (and potentially hazardous)
>> auto-complete drop-down for the end developer.
>>
>> I understand that this was done on purpose<http://code.google.com/p/polygonal/wiki/UsingActionScript3#Public_and_private>for better compatibility, and is not a bug. However, I was wondering if
>> there's a way to turn off this behaviour? If there isn't, could such an
>> option be added?
>>
>> Thanks,
>> Cameron
>>
>> -- haXe - an open source web programming language http://haxe.org
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SWC compilation marks all methods as public

Cameron D
*Aha* that makes sense. Thanks!

On Sat, Sep 3, 2011 at 5:13 AM, Yanis Benson <[hidden email]> wrote:

If you access private method/field from inlined method it is ok and all logical. But when the inlining takes places, this access can happen from whatever place you accessed you inlined method from and in most cases the field/method you access won't be accessible anymore.

On 3 Sep 2011 03:45, "Cameron D" <[hidden email]> wrote:
> Excellent, thank you! I went with a public wrapper with a haxe-private
> "__impl" member of a @:protected private implementation class in the same
> module.
>
> It works perfectly, and clears the interface up beautifully!
>
> It still boggles my mind that protected is enforced at run-time (no wonder
> function calls are slow) even from functions within the same class (I don't
> quite understand why that seems to only affect inlined methods, though).
>
> On Fri, Sep 2, 2011 at 4:54 AM, luca deltodesco <[hidden email]>wrote:
>
>> you can use the @:protected metadata before fields/methods which will make
>> them be compiled as private values in the SWC, but you need to be aware that
>> this can easily break your code as the private/public property seems to be
>> enforced at runtime in the flash player, so you 'cannot' make an inline
>> method protected for instance, nor can you inline any method which calls
>> protected methods or accesses protected fields as it causes flash player to
>> throw a runtime error abuot accessing a private attribute! (yaay)
>>
>> For nape, I ended up having a 'public' and 'private' package, and apart
>> from some extra internal classes, every class has a public and private side
>> of things. the public side providing an interface to the private inner
>> object so that the only field cluttering drop down menus and such as a
>> single 'zpp_inner' field which appears at the bottom of the list to
>> reference the inner type.
>>
>> ------------------------------
>> From: [hidden email]
>> Date: Fri, 2 Sep 2011 01:52:09 -0400
>> To: [hidden email]
>> Subject: [haXe] SWC compilation marks all methods as public
>>
>>
>> Hello everyone,
>>
>> I've been working on a small project in haXe for the Flash platform. I
>> compiled my classes into an SWC file so that it can be used by AS3 code
>> written within, say, the Flash IDE. It all works great, but every method and
>> property in the SWC's ABC byte-code is marked as public (even the ones that
>> were originally private in haXe). Because 90% of my methods and variables
>> are private, it makes for a confusing (and potentially hazardous)
>> auto-complete drop-down for the end developer.
>>
>> I understand that this was done on purpose<http://code.google.com/p/polygonal/wiki/UsingActionScript3#Public_and_private>for better compatibility, and is not a bug. However, I was wondering if

>> there's a way to turn off this behaviour? If there isn't, could such an
>> option be added?
>>
>> Thanks,
>> Cameron
>>
>> -- haXe - an open source web programming language http://haxe.org
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org