1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "js/GlobalObject.h"
6 #include "jsapi-tests/tests.h"
9 * Bug 689101 - jsval is technically a non-POD type because it has a private
10 * data member. On gcc, this doesn't seem to matter. On MSVC, this prevents
11 * returning a jsval from a function between C and C++ because it will use a
12 * retparam in C++ and a direct return value in C.
14 * Bug 712289 - jsval alignment was different on 32-bit platforms between C and
15 * C++ because the default alignments of js::Value and jsval_layout differ.
20 extern bool C_ValueToObject(JSContext
* cx
, jsval v
, JSObject
** obj
);
22 extern jsval
C_GetEmptyStringValue(JSContext
* cx
);
24 extern size_t C_jsvalAlignmentTest();
27 BEGIN_TEST(testValueABI_retparam
) {
28 JS::RootedObject
obj(cx
, JS::CurrentGlobalOrNull(cx
));
29 RootedValue
v(cx
, ObjectValue(*obj
));
31 CHECK(C_ValueToObject(cx
, v
, obj
.address()));
33 RootedValue
v2(cx
, ObjectValue(*obj
));
34 CHECK(JS_StrictlyEqual(cx
, v
, v2
, &equal
));
37 v
= C_GetEmptyStringValue(cx
);
42 END_TEST(testValueABI_retparam
)
44 BEGIN_TEST(testValueABI_alignment
) {
49 CHECK(C_jsvalAlignmentTest() == sizeof(AlignTest
));
53 END_TEST(testValueABI_alignment
)