Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "mozilla/HoldDropJSObjects.h"
8 : #include "mozilla/dom/TypedArray.h"
9 : #include "mozilla/dom/Pose.h"
10 :
11 : namespace mozilla {
12 : namespace dom {
13 :
14 : NS_IMPL_CYCLE_COLLECTION_CLASS(Pose)
15 :
16 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Pose)
17 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
18 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
19 0 : tmp->mPosition = nullptr;
20 0 : tmp->mLinearVelocity = nullptr;
21 0 : tmp->mLinearAcceleration = nullptr;
22 0 : tmp->mOrientation = nullptr;
23 0 : tmp->mAngularVelocity = nullptr;
24 0 : tmp->mAngularAcceleration = nullptr;
25 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
26 :
27 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Pose)
28 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
29 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
30 :
31 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Pose)
32 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
33 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mPosition)
34 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mLinearVelocity)
35 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mLinearAcceleration)
36 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mOrientation)
37 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAngularVelocity)
38 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAngularAcceleration)
39 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
40 :
41 0 : NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(Pose, AddRef)
42 0 : NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(Pose, Release)
43 :
44 :
45 0 : Pose::Pose(nsISupports* aParent)
46 : : mParent(aParent),
47 : mPosition(nullptr),
48 : mLinearVelocity(nullptr),
49 : mLinearAcceleration(nullptr),
50 : mOrientation(nullptr),
51 : mAngularVelocity(nullptr),
52 0 : mAngularAcceleration(nullptr)
53 : {
54 0 : mozilla::HoldJSObjects(this);
55 0 : }
56 :
57 0 : Pose::~Pose()
58 : {
59 0 : mozilla::DropJSObjects(this);
60 0 : }
61 :
62 : nsISupports*
63 0 : Pose::GetParentObject() const
64 : {
65 0 : return mParent;
66 : }
67 :
68 : void
69 0 : Pose::SetFloat32Array(JSContext* aJSContext, JS::MutableHandle<JSObject*> aRetVal,
70 : JS::Heap<JSObject*>& aObj, float* aVal, uint32_t sizeOfVal,
71 : bool bCreate, ErrorResult& aRv)
72 : {
73 0 : if (bCreate) {
74 0 : aObj = Float32Array::Create(aJSContext, this,
75 0 : sizeOfVal, aVal);
76 0 : if (!aObj) {
77 0 : aRv.NoteJSContextException(aJSContext);
78 0 : return;
79 : }
80 : }
81 :
82 0 : aRetVal.set(aObj);
83 : }
84 :
85 : } // namespace dom
86 : } // namespace mozilla
|