Perfect. Thanks for working with me on this.

I’m not going to be working until September 29. Let’s further discuss options 
for XML sorting then.

Harbs

> On Sep 20, 2021, at 1:55 AM, Edward Stangler <estang...@bradmark.com> wrote:
> 
> 
> I've moved the Language changes and some related changes in Basic
> org.apache.royale.html.util.getLabelFromData to PR #1150.
> 
> (I've left the related changes in MX mx.collections.SortField and MX
> mx.controls.beads.AdvancedDataGridItemRendererInitializer on this PR,
> since they only affect MX.)
> 
> 
> 
> On 9/19/2021 8:08 AM, Harbs wrote:
>> I think there’s some confusion here.
>> 
>> The issue is not that there couldn’t be a dependency on XML, but rather to 
>> properly parse E4X, the XML type needs to be known at compile time. That’s 
>> because we actually rewrite bracket and E4X access into function calls.
>> 
>> TreeXMLItemRenderer takes an untyped object which is not known to be XML.
>> 
>> It sounds like sortOn has a similar problem. You’re sorting an array of 
>> possible xml objects, but since the type is not known, the values cannot be 
>> resolved.
>> 
>> So basically, a special function is needed when sorting xml objects.
>> 
>> The vast majority of apps will not need this.
>> 
>> I think the correct way to do change Array.sortOn would be to have a bead 
>> which modifies the function used for sorting.
>> 
>> However, I’m not convinced that Array.sortOn really needs to be XML aware at 
>> all. It seems like a component which accepts XML data can just call a 
>> specialized XML sort method instead.
>> 
>> Thoughts?
>> Harbs
>> 
>>> On Sep 17, 2021, at 2:00 PM, Edward Stangler wrote:
>>> 
>>> 
>>> Every Array.sortOn() calls Language.sortOn(), a static function that
>>> calls the (Language) static function compareNumber,
>>> compareStringCaseinsensitive, or compareString, depending on options.
>>> 
>>> Inside those compareXX() static functions, it would access the sort
>>> field value using "a[n]" or "b[n]" (n = field name string).  But that
>>> doesn't work for XML objects, on the JS side.
>>> 
>>> Aside:  previously, Basic TreeXMLItemRenderer needed to get a value from
>>> an XML object, but to avoid depending on the XML project, it had some
>>> code to manually get the values it needed.  I started with that code,
>>> refined it a bit to handle more cases, and put that code into various
>>> places (in order to read an XML object without depending on the XML
>>> project).
>>> 
>>> So in this case, I created a new static function Language.getValue() to
>>> replace "a[n]" and "b[n]" (with getValue(a, n) and getValue(b, n),
>>> respectively).  The code in getValue() is too much to inline, in my opinion.
>>> 
>>> 
>>> 1.  The code is needed for XML objects in the Array.sortOn(), i.e.
>>> sorting on a column in a grid with data that is XML (if I remember
>>> correctly;  eventually goes through class Sort, which can call
>>> Array.sortOn()).  The code is to avoid depending on the XML project.
>>> 
>>> 2.  I can't think of any possible way, in this case.
>>> 
>>> 
>>> Why go through so much trouble to avoid depending on the XML project? 
>>> Well, I don't know why XML was separated into its own project.  Perhaps
>>> for PAYG?  If so, then I suppose we could create some extensible system
>>> in Language where you could specify custom functions, like getValue(),
>>> residing in other projects, to get the sort field values for custom
>>> object types;  that would be PAYG.  But is it worth it for 204 bytes,
>>> for an object type (XML) built into Flex?  What would be the hook (the
>>> step at runtime) for XML to tell Language about its custom function? 
>>> I'm not sure the extensible system would take less than 204 bytes,
>>> either.  (The performance of getValue() is mostly PAYG;  it does the
>>> extra JS code for XML only if the regular method "a[n]" is null.)
>>> 
>>> 
>>> 
>>> On 9/17/2021 1:30 AM, Harbs wrote:
>>>> Basically not PAYG.
>>>> 
>>>> FYI there are some ongoing tasks to reduce the PAYG debt. I don’t want to 
>>>> add to it. https://github.com/apache/royale-asjs/issues/641
>>>> 
>>>> Most of the code in Language.as gets stripped out if not used.
>>>> 
>>>> If that’s not the case here, I’m going to ask some more questions.
>>>> 
>>>> 1. Where/why is this code needed? You made a comment about XML not being 
>>>> available. Why would that be an issue?
>>>> 2. Is there another way to achieve the same result that’s more PAYG?
>>>> 
>>>> Thanks,
>>>> Harbs
>>>> 
>>>>> On Sep 17, 2021, at 4:44 AM, Edward Stangler wrote:
>>>>> 
>>>>> 
>>>>> 204 bytes (~0.03% of small program) in JS release
>>>>> 
>>>>> (presumably mostly due to the one new static function)
>>>>> (develop vs. develop + just these Language changes)
>>>>> (no difference between full rebuild or just Language rebuild)
>>>>> 
>>>>> TestSetClipboard.swf
>>>>> release - before: 87,634
>>>>> release - after: 87,634
>>>>> debug - before: 176,590
>>>>> debug - after: 176,590
>>>>> 
>>>>> TestSetClipboard JS directory
>>>>> release - before: 620,221
>>>>> release - after: 620,425
>>>>> debug - before: 3,145,663
>>>>> debug - after: 3,146,567
>>>>> 
>>>>> 
>>>>> (Test case from issue #995)  Test.swf
>>>>> release - before: 121,852
>>>>> release - after: 121,777
>>>>> debug - before: 244,914
>>>>> debug - after: 244,916
>>>>> 
>>>>> (Test case from issue #995)  Test JS directory
>>>>> release - before: 831,174
>>>>> release - after: 831,378
>>>>> debug - before: 4,003,520
>>>>> debug - after: 4,004,424
>>>>> 
>>>>> 
>>>>> TestSetClipboard.mxml:
>>>>> <?xml version="1.0" encoding="utf-8"?>
>>>>> <mx:Application 
>>>>> xmlns:fx="http://ns.adobe.com/mxml/2009";<http://ns.adobe.com/mxml/2009>
>>>>>      xmlns:js="library://ns.apache.org/royale/express"
>>>>>      xmlns:mx="library://ns.apache.org/royale/mx">
>>>>> 
>>>>>      <fx:Script>
>>>>>              <![CDATA[
>>>>>                      import mx.system.System;
>>>>> 
>>>>>                      public function testSetClipboard() : void
>>>>>                      {
>>>>>                              System.setClipboard("   This has three 
>>>>> spaces in front.");
>>>>>                      }
>>>>>              ]]>
>>>>>      </fx:Script>
>>>>> 
>>>>>      <mx:Button label="Go" click="testSetClipboard();" />
>>>>> </mx:Application>
>>>>> 
>>>>> 
>>>>> 
>>>>> On 9/16/2021 12:25 PM, Harbs wrote:
>>>>> 
>>>>> One question I had:
>>>>> 
>>>>> Do the changes to Language.as add to application size for applications 
>>>>> which don't need it?
>>>>> 
>>>>> 
>>>>> 
>>>>> On Sep 16, 2021, at 9:20 AM, Piotr Zarzycki wrote:
>>>>> 
>>>>> This fixes seems to be helpful. Do you think we should merge them ?
>>>>> 
>>>>> czw., 16 wrz 2021 o 00:41 estanglerbm 
>>>>> <notificati...@github.com><mailto:notificati...@github.com> napisa?(a):
>>>>> 
>>>>> 
>>>>> 
>>>>> Don't forget about these fixes.
>>>>> 
>>>>> -
>>>>> You are receiving this because you are subscribed to this thread.
>>>>> Reply to this email directly, view it on GitHub
>>>>> <https://github.com/apache/royale-asjs/pull/1127#issuecomment-920434990><https://github.com/apache/royale-asjs/pull/1127#issuecomment-920434990>,
>>>>> or unsubscribe
>>>>> <https://github.com/notifications/unsubscribe-auth/AF3K2K72XOPFFUX4P335WNLUCEOILANCNFSM5AFBH67Q><https://github.com/notifications/unsubscribe-auth/AF3K2K72XOPFFUX4P335WNLUCEOILANCNFSM5AFBH67Q>
>>>>> .
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> 
>>>>> Piotr Zarzycki

Reply via email to