[foreign] RFR 8218153: Read/Write of Value layout should honor declared endianness

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Feb 27 19:18:50 UTC 2019


Btw, if we have this new API point, I think the parser can be simplified 
a lot?

E.g. when you see '<' or '>', just call parseLayout, and then call 
withEndianness on the result?

This way what the grammar says and what the API does are actually aligned.

Maurizio

On 27/02/2019 19:06, Maurizio Cimadamore wrote:
> Henry I think what we were suggesting was to add a new interface 
> method to Layout
>
> e.g.
>
> interface Layout
>
>     Layout withEndianness(Endianness)
> }
>
> and have the subtypes override accordingly. We want this to be usable 
> by clients.
>
> Maurizio
>
> On 27/02/2019 18:47, Henry Jen wrote:
>> Updated webrev[1] to have withEndianness(Endianness) for Value and 
>> Group based layouts. The helper function is now protected static 
>> function in Group instead of Util.
>>
>> As the jextract change, it’s quite simple, basically as following(I 
>> need to see if AsmCodeFactoryExt needs same treatment), but we need 
>> to fix Runner test templates, other tests seems passing just fine as 
>> we expected.
>>
>> However, since I am not a fan of this, I  like to keep that separate 
>> so we clearly know what changes are made for that purpose. Regarding 
>> to your EA concern, it won’t be long before I complete review and 
>> fixes for jextract. Sounds fair?
>>
>> Cheers,
>> Henry
>>
>>
>>> @@ -235,6 +220,12 @@
>>>
>>>       @Override
>>>       public Boolean visitVar(VarTree varTree, JType jt) {
>>> +        Layout layout = varTree.layout();
>>> +        if (layout instanceof Value) {
>>> +            layout = ((Value) 
>>> layout).withEndianness(Value.Endianness.hostEndian());
>>> +        } else if (layout instanceof Group) {
>>> +            layout = ((Group) 
>>> layout).withEndianness(Value.Endianness.hostEndian());
>>> +        }
>>> global_layouts.add(varTree.layout().withAnnotation(Layout.NAME, 
>>> varTree.name()));
>>>           return addField(global_cw, varTree, null);
>>>       }
>>> @@ -295,6 +286,9 @@
>>>
>>>           AnnotationVisitor av = cw.visitAnnotation(NATIVE_STRUCT, 
>>> true);
>>>           Layout structLayout = structTree.layout();
>>> +        if (structLayout instanceof Group) {
>>> +            structLayout = ((Group) 
>>> structLayout).withEndianness(Value.Endianness.hostEndian());
>>> +        }
>>>           av.visit("value", structLayout.toString());
>>>           av.visitEnd();
>>>           cw.visitInnerClass(name, headerClassName, intf, ACC_PUBLIC 
>>> | ACC_STATIC | ACC_ABSTRACT | ACC_INTERFACE);
>> [1] http://cr.openjdk.java.net/~henryjen/panama/8218153/2/webrev/
>>
>>
>>> On Feb 27, 2019, at 2:55 AM, Maurizio Cimadamore 
>>> <maurizio.cimadamore at oracle.com> wrote:
>>>
>>>
>>> On 27/02/2019 03:31, John Rose wrote:
>>>> The use case of reversing a previous set layout
>>>> suggested by Henry can be covered by reassembling
>>>> the layout from scratch.  And the use case of detecting
>>>> that there is some subpart that already has > or <
>>>> can be covered by traversing from scratch. Both of
>>>> those use cases seem less interesting to me than
>>>> composing a perfectly nice layout with a prepended
>>> Exactly - this is the use case I was after!
>>>
>>> Maurizio
>>>


More information about the panama-dev mailing list