Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

[Buffer] length is not a readonly attribute #172

Closed
haoxli opened this issue Sep 12, 2016 · 6 comments
Closed

[Buffer] length is not a readonly attribute #172

haoxli opened this issue Sep 12, 2016 · 6 comments

Comments

@haoxli
Copy link
Contributor

haoxli commented Sep 12, 2016

readonly attribute unsigned long length;

In buffer.md, the length of Buffer should be readonly, but actually it can be modified.

var buff = new Buffer(8);
var original = buff.length;
buff.length = buff.length + 1;
print(original);
print(buff.length);

The print result is 9, not the expected 8.

@haoxli haoxli changed the title [Buffer] length is not readonly attribute [Buffer] length is a not readonly attribute Sep 12, 2016
@haoxli haoxli changed the title [Buffer] length is a not readonly attribute [Buffer] length is not a readonly attribute Sep 12, 2016
@jimmy-huang
Copy link
Contributor

this is probably a limitation of jerryscript, there's not a way for us to set a read-only attribute on any js objects, at least I am not aware of any, @brianjjones?

@pfalcon
Copy link
Contributor

pfalcon commented Oct 27, 2016

Quick grep over JrS codebase:

  length_prop_value_p = ecma_create_named_data_property (obj_p,
                                                         length_magic_string_p,
                                                         ECMA_PROPERTY_FLAG_WRITABLE,
                                                         NULL);

(read-only should be "not writable" in javascript-speak).

@jimmy-huang
Copy link
Contributor

@pfalcon thanks for pointing that out, but ecma_ are internal apis, not the public apis we can use, we should file a feature request to have a jerry_ api to allow setting the property

@grgustaf grgustaf self-assigned this Dec 5, 2016
grgustaf added a commit to grgustaf/zephyr.js-1 that referenced this issue Dec 23, 2016
Fixes issue intel#172.

Signed-off-by: Geoff Gustafson <[email protected]>
@grgustaf
Copy link
Contributor

Fixed by PR #576. This makes test-buffer.js pass all 18/18 subtests.

@grgustaf
Copy link
Contributor

BTW @jimmy-huang and @pfalcon, I found that this and more can be done using jerry_define_own_property.

@grgustaf grgustaf added the fixed label Dec 23, 2016
grgustaf added a commit to grgustaf/zephyr.js-1 that referenced this issue Jan 4, 2017
Fixes issue intel#172.

Signed-off-by: Geoff Gustafson <[email protected]>
grgustaf added a commit that referenced this issue Jan 4, 2017
Fixes issue #172.

Signed-off-by: Geoff Gustafson <[email protected]>
@xiaolongx
Copy link
Contributor

This issue cannot reproduce on both Arduino 101 and FRDM-K64F with commit 2345f96.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants