Loading...
Searching...
No Matches
mjs_object.h
1/*
2 * Copyright (c) 2016 Cesanta Software Limited
3 * All rights reserved
4 */
5
6#ifndef MJS_OBJECT_H_
7#define MJS_OBJECT_H_
8
9#include "mjs_object_public.h"
10#include "mjs_internal.h"
11
12#if defined(__cplusplus)
13extern "C" {
14#endif /* __cplusplus */
15
16struct mjs;
17
19 struct mjs_property* next; /* Linkage in struct mjs_object::properties */
20 mjs_val_t name; /* Property name (a string) */
21 mjs_val_t value; /* Property value */
22};
23
24struct mjs_object {
25 struct mjs_property* properties;
26};
27
28MJS_PRIVATE struct mjs_object* get_object_struct(mjs_val_t v);
29MJS_PRIVATE struct mjs_property*
30 mjs_get_own_property(struct mjs* mjs, mjs_val_t obj, const char* name, size_t len);
31
32MJS_PRIVATE struct mjs_property*
33 mjs_get_own_property_v(struct mjs* mjs, mjs_val_t obj, mjs_val_t key);
34
35/*
36 * A worker function for `mjs_set()` and `mjs_set_v()`: it takes name as both
37 * ptr+len and mjs_val_t. If `name` pointer is not NULL, it takes precedence
38 * over `name_v`.
39 */
40MJS_PRIVATE mjs_err_t mjs_set_internal(
41 struct mjs* mjs,
42 mjs_val_t obj,
43 mjs_val_t name_v,
44 char* name,
45 size_t name_len,
46 mjs_val_t val);
47
48/*
49 * Implementation of `Object.create(proto)`
50 */
51MJS_PRIVATE void mjs_op_create_object(struct mjs* mjs);
52
53/*
54 * Stub of `Object.defineProperty()`
55 */
56MJS_PRIVATE void mjs_op_object_define_property(struct mjs* mjs);
57
58/*
59 * Cell destructor for object arena
60 */
61MJS_PRIVATE void mjs_obj_destructor(struct mjs* mjs, void* cell);
62
63#define MJS_PROTO_PROP_NAME "__p" /* Make it < 5 chars */
64
65#if defined(__cplusplus)
66}
67#endif /* __cplusplus */
68
69#endif /* MJS_OBJECT_H_ */
Definition mjs_object.h:24
Definition mjs_object.h:18
Definition mjs_core.h:63