raylib-wasm-transpiler/tools/js-class-c-struct-transpiler/test/build/Login.js

61 lines
1.7 KiB
JavaScript

/**
* @typedef {Object} Login The login object
* @property {string} Email Email of the user
* @property {string} Password Password of the user
*/
class Login {
/**
* Email of the user
* @return {string} gets the value of Email
*/
get Email() {
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 256)));
}
/**
* Email of the user
* @param {string} v sets the value of Email
*/
set Email(v) {
this._data.set(this._encoder.encode(v), 0);
}
/**
* Password of the user
* @return {string} gets the value of Password
*/
get Password() {
return this._decoder.decode(new Uint8Array(this._ptr.slice(256, 320)));
}
/**
* Password of the user
* @param {string} v sets the value of Password
*/
set Password(v) {
this._data.set(this._encoder.encode(v), 256);
}
/**
* Get the struct representation of the object
* @return {Uint8Array} u8 array of the C struct.
*/
get bytes() {
return new Uint8Array(this._ptr);
}
/**
* Constructs a new Login
*
* @param {{Email: string, Password: string, }} init The arguments to construct the object.
* @param {ArrayBuffer} ptr The pointer to the C struct.
*/
constructor(init = {}, ptr = undefined) {
this._size = 320;
this._ptr = ptr?.buffer || new ArrayBuffer(this._size);
this._data = new DataView(this._ptr);
this._encoder = new TextEncoder();
this._decoder = new TextDecoder();
for (const key of Object.keys(init)) {
this[key] = init[key];
}
}
}
export default Login