@@ -74,7 +74,8 @@ class Prop
74
74
75
75
/* * A reference to an instance of a JavaScript interpreter.
76
76
*/
77
- class Context
77
+ class MRDOX_DECL
78
+ Context
78
79
{
79
80
struct Impl ;
80
81
@@ -89,15 +90,15 @@ class Context
89
90
90
91
/* * Destructor.
91
92
*/
92
- MRDOX_DECL ~Context ();
93
+ ~Context ();
93
94
94
95
/* * Constructor.
95
96
*/
96
- MRDOX_DECL Context ();
97
+ Context ();
97
98
98
99
/* * Constructor.
99
100
*/
100
- MRDOX_DECL Context (Context const &) noexcept ;
101
+ Context (Context const &) noexcept ;
101
102
};
102
103
103
104
// ------------------------------------------------
@@ -140,95 +141,6 @@ class Scope
140
141
141
142
// ------------------------------------------------
142
143
143
- /* * A bound value which can be passed to JavaScript.
144
-
145
- Objects of this type are used as parameter
146
- types in signatures of C++ functions. They
147
- should not be used anywhere else, otherwise
148
- the behavior is undefined.
149
- */
150
- class MRDOX_DECL
151
- Param
152
- {
153
- enum class Kind
154
- {
155
- Undefined,
156
- Null,
157
- Boolean ,
158
- Integer,
159
- Unsigned,
160
- Double,
161
- String,
162
- Value,
163
- DomArray,
164
- DomObject
165
- };
166
-
167
- Kind kind_ = Kind::Undefined;
168
-
169
- union
170
- {
171
- bool b_;
172
- int i_;
173
- unsigned int u_;
174
- double d_;
175
- int idx_; // for Value
176
- std::string_view s_;
177
- dom::Array arr_;
178
- dom::Object obj_;
179
- };
180
-
181
- friend struct Access ;
182
- void push (Scope&) const ;
183
- Param (Param&&) noexcept ;
184
-
185
- public:
186
- ~Param ();
187
- Param (std::nullptr_t ) noexcept ;
188
- Param (int ) noexcept ;
189
- Param (unsigned int ) noexcept ;
190
- Param (double ) noexcept ;
191
- Param (std::string_view s) noexcept ;
192
- Param (Value const & value) noexcept ;
193
- Param (dom::Array const & arr) noexcept ;
194
- Param (dom::Object const & obj) noexcept ;
195
- Param (dom::Value const & value) noexcept ;
196
-
197
- Param (Param const &) = delete ;
198
- Param& operator =(Param const &) = delete ;
199
-
200
- template <class Boolean >
201
- requires std::is_same_v<Boolean , bool >
202
- Param (Boolean const & b) noexcept
203
- : kind_(Kind::Boolean )
204
- , b_(b)
205
- {
206
- }
207
-
208
- Param (char const * s) noexcept
209
- : Param(std::string_view(s))
210
- {
211
- }
212
-
213
- template <class String >
214
- requires std::is_convertible_v<
215
- String, std::string_view>
216
- Param (String const & s)
217
- : Param(std::string_view(s))
218
- {
219
- }
220
-
221
- template <class Enum >
222
- requires std::is_enum_v<Enum>
223
- Param (Enum v) noexcept
224
- : kind_(Kind::Integer)
225
- , i_(static_cast <int >(v))
226
- {
227
- }
228
- };
229
-
230
- // ------------------------------------------------
231
-
232
144
/* * An ECMAScript value.
233
145
*/
234
146
class Value
@@ -262,14 +174,14 @@ class Value
262
174
std::string getString () const ;
263
175
264
176
void setlog ();
177
+
265
178
/* * Call a function.
266
179
*/
267
180
template <class ... Args>
268
181
Expected<Value>
269
182
call (Args&&... args) const
270
183
{
271
- std::array<Param, sizeof ...(args)> va{ Param (args)... };
272
- return callImpl (va.data (), va.size ());
184
+ return callImpl ({ dom::Value (std::forward<Args>(args))... });
273
185
}
274
186
275
187
/* * Call a function.
@@ -289,23 +201,21 @@ void setlog();
289
201
std::string_view prop,
290
202
Args&&... args) const
291
203
{
292
- std::array<Param, sizeof ...(args)> va{ Param (args)... };
293
- return callPropImpl (prop, va. data (), va. size () );
204
+ return callPropImpl (prop,
205
+ { dom::Value (std::forward<Args>(args))... } );
294
206
}
295
207
296
208
private:
297
209
MRDOX_DECL
298
210
Expected<Value>
299
211
callImpl (
300
- Param const * data,
301
- std::size_t size) const ;
212
+ std::initializer_list<dom::Value> args) const ;
302
213
303
214
MRDOX_DECL
304
215
Expected<Value>
305
216
callPropImpl (
306
217
std::string_view prop,
307
- Param const * data,
308
- std::size_t size) const ;
218
+ std::initializer_list<dom::Value> args) const ;
309
219
};
310
220
311
221
inline bool Value::isUndefined () const noexcept
0 commit comments