Custom little/big endian data structure


(Adrian Zubarev) #1

Hi there,

is there actually a way to build a custom data structure that will automatically be converted to little/big endian on a little/big endian system, just like (U)Int16/32/64 do?

I could build as a workaround a mechanism that will do that for me, but I’m curious if this is possible with some workaround.

Specifically, I’m talking about a 128 Bit data structure.

Best regards,

···

--
Adrian Zubarev
Sent with Airmail


(Chris Lattner) #2

Hi Adrian,

This isn’t something that Swift provides a magic answer to today, but it seems possible that the “property behaviors” proposal (which is currently shelved, but will hopefully come back in the future) could be used to address this.

-Chris

···

On Oct 30, 2016, at 12:50 PM, Adrian Zubarev via swift-users <swift-users@swift.org> wrote:

Hi there,

is there actually a way to build a custom data structure that will automatically be converted to little/big endian on a little/big endian system, just like (U)Int16/32/64 do?

I could build as a workaround a mechanism that will do that for me, but I’m curious if this is possible with some workaround.


(Adrian Zubarev) #3

Hi Chris,

thank you for your answer. I can’t wait for property behaviors, it’s going to be such a powerful feature. :slight_smile:

···

--
Adrian Zubarev
Sent with Airmail

Am 1. November 2016 um 18:34:55, Chris Lattner (clattner@apple.com) schrieb:

On Oct 30, 2016, at 12:50 PM, Adrian Zubarev via swift-users <swift-users@swift.org> wrote:

Hi there,

is there actually a way to build a custom data structure that will automatically be converted to little/big endian on a little/big endian system, just like (U)Int16/32/64 do?

I could build as a workaround a mechanism that will do that for me, but I’m curious if this is possible with some workaround.

Hi Adrian,

This isn’t something that Swift provides a magic answer to today, but it seems possible that the “property behaviors” proposal (which is currently shelved, but will hopefully come back in the future) could be used to address this.

-Chris