That link took me to the FormatDescriptor class.
The FormatDescriptor exception is a side-effect of having naked
static initialization code. We want to defer static initialization
until it is really needed so that the load order of classes doesn’t
matter as much (or at all).
My current opinion (again without spending too much time thinking
about it) is to convert the var into a get function. Most other
methods in TextConverter access _descriptor and thus would
initialize it just-in-time as it is needed. Something like:
Static private var __descriptors:Array;
static public function get _descriptors():Array
{
If (!__descriptors) {
_descriptors = [];
addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
TextLayoutExporter, TEXT_LAYOUT_FORMAT,__descriptors);
addFormat(TEXT_FIELD_HTML_FORMAT,
TextFieldHtmlImporter, TextFieldHtmlExporter, null,__descriptors);
addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
PlainTextExporter, "air:text", __descriptors);
}
}
And add an optional last param to addFormat to specify the array to
add to, so it doesn’t access the getter during initialization.
HTH,
-Alex
From: Serkan Taş <serkan....@likyateknoloji.com>
Reply-To: "users@royale.apache.org" <users@royale.apache.org>
Date: Tuesday, November 26, 2019 at 8:14 PM
To: "users@royale.apache.org" <users@royale.apache.org>
Subject: Re: TextConverter method call
Alex, I have implemented in other way, here it is : ====>
https://drive.google.com/open?id=1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&data=02%7C01%7Caharui%40adobe.com%7Cf1bcbef8545341e8ec6e08d772f049d8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104248674874151&sdata=Aw7jIEhZttahHiV5zlDJjKC7X0Rkz10E0W2l0QiZKT0%3D&reserved=0>
But I have another exception in other thread , can you check it ?
subject : "org.apache.royale.textLayout.conversion.FormatDescriptor
is not a constructor"
27.11.2019 01:34 tarihinde Alex Harui yazdı:
Nevermind, that won’t work in this case. I think you still need to
initialize _descriptors with a static initializer. I think I would
use an internal version of addFormat for doing that. Or maybe
manually code _descriptors as a get/set.
HTH,
-Alex
From: Alex Harui <aha...@adobe.com><mailto:aha...@adobe.com>
Reply-To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Date: Tuesday, November 26, 2019 at 2:22 PM
To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Subject: Re: TextConverter method call
Yes, probably a good idea, in which I case I would just use a dummy
initializer
/** @private */
static public function setFormatsToDefault():Boolean // No PMD
{
_descriptors = [];
addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,
TextFieldHtmlExporter, null);
addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
PlainTextExporter, "air:text");
return true;
}
static public var _descriptors:Array;
static private var formatsSet:Boolean = setFormatsToDefault()
From: Serkan Taş
<serkan....@likyateknoloji.com><mailto:serkan....@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Date: Tuesday, November 26, 2019 at 11:44 AM
To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Subject: Re: TextConverter method call
Do I have to keep addFormat and addFormatAt compatible for external
usage, because they are public may be called from other classes ?
26.11.2019 21:15 tarihinde Alex Harui yazdı:
It “should” but we are not fully supporting “naked code” (code not
in methods) right now. I’ve never liked the pattern and I’m not
sure all minifiers know how to handle it, so the easiest answer for
now is to rewrite the pattern.
One way to rewrite is to have setFormatDefaults return an array and
initialize _descriptors. Something like:
// register standard importers and exporters
setFormatsToDefault();
/** @private */
static public function setFormatsToDefault():Array // No PMD
{
var arr:Array = [];
addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter,
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
addFormat(arr, TEXT_FIELD_HTML_FORMAT,
TextFieldHtmlImporter, TextFieldHtmlExporter, null);
addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter,
PlainTextExporter, "air:text");
return arr;
}
static public var _descriptors:Array = setFormatsToDefault()
You’ll have to change addFormat to accept the array to modify.
HTH,
-Alex
From: Serkan Taş
<serkan....@likyateknoloji.com><mailto:serkan....@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Date: Tuesday, November 26, 2019 at 9:13 AM
To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Subject: Re: TextConverter method call
Unfortunately there is not a getter for the property, but the call
for setFormatsToDefault is in the class body.
public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";
// Descriptors - ordered list of all FormatDescriptors
/** @private */
static public var _descriptors:Array = [];
// register standard importers and exporters
setFormatsToDefault();
/** @private */
static public function setFormatsToDefault():void // No PMD
{
_descriptors = [];
addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,
TextFieldHtmlExporter, null);
addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
PlainTextExporter, "air:text");
}
Shouldn't it be called while the class is initialized ?
Thanks,
Serkan
26.11.2019 08:06 tarihinde Alex Harui yazdı:
Without looking at more of the code, I’m guessing there is a
“descriptors” property that returns the “_descriptors” array. If
that’s the case, then I would add a check to the descriptors getter
to check if _descriptors has been initialized and if not, call
setFormatsToDefault.
-Alex
From: Serkan Taş
<serkan....@likyateknoloji.com><mailto:serkan....@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Date: Monday, November 25, 2019 at 12:55 PM
To: "users@royale.apache.org"<mailto:users@royale.apache.org>
<users@royale.apache.org><mailto:users@royale.apache.org>
Subject: TextConverter method call
Hi,
TextConverter has a method named setFormatsToDefault() and called
while the application is loaded - I guess automatically because I
could not find any reference - in Flex, but never called in Royale.
Source piece Royale :
// register standard importers and exporters
setFormatsToDefault();
/** @private */
static public function setFormatsToDefault():void // No PMD
{
_descriptors = [];
addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,
TextFieldHtmlExporter, null);
addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
PlainTextExporter, "air:text");
}
Flex :
// register standard importers and exporters
setFormatsToDefault();
/** @private */
static tlf_internal function setFormatsToDefault():void // No PMD
{
_descriptors = [];
addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,
TextFieldHtmlExporter, null);
addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,
PlainTextExporter, "air:text");
}
How should be the mechanism for the flow in Royale ?
Thanks,
Serkan