()
| 874 | |
| 875 | let prototype: &Object = &constructor.get(PredefinedAtom::Prototype)?; |
| 876 | prototype.set("copy", Func::from(copy))?; |
| 877 | prototype.set("subarray", Func::from(subarray))?; |
| 878 | prototype.set(PredefinedAtom::ToString, Func::from(to_string))?; |
| 879 | prototype.set("write", Func::from(write))?; |
| 880 | |
| 881 | // Set all write and read methods |
| 882 | for kind in NumberKind::iter() { |
| 883 | for (endian, name, alias) in kind.prototype() { |
| 884 | let write_func = Function::new(ctx.clone(), |t, c, v, o| { |
| 885 | write_buf(&t, &c, &v, &o, *endian, *kind) |
| 886 | })?; |
| 887 | let read_func = |
| 888 | Function::new(ctx.clone(), |t, c, o| read_buf(&t, &c, &o, *endian, *kind))?; |
| 889 | if let Some(alias) = alias { |
| 890 | prototype.set(["write", alias].concat(), write_func.clone())?; |
| 891 | prototype.set(["read", alias].concat(), read_func.clone())?; |
| 892 | } |
| 893 | prototype.set(["write", name].concat(), write_func)?; |
| 894 | prototype.set(["read", name].concat(), read_func)?; |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | //not assessable from js |
| 899 | prototype.prop(PredefinedAtom::Meta, stringify!(Buffer))?; |
| 900 | |
| 901 | ctx.globals().set(stringify!(Buffer), constructor)?; |
| 902 | |
| 903 | Ok(()) |
| 904 | } |
| 905 | |
| 906 | #[cfg(test)] |
| 907 | mod tests { |
| 908 | use llrt_test::{call_test, test_async_with, ModuleEvaluator}; |
nothing calls this directly
no test coverage detected