@@ -45,6 +45,26 @@ CustomExternalWrapperObject::CustomExternalWrapperObject(CustomExternalWrapperTy
4545 }
4646}
4747
48+ CustomExternalWrapperObject::CustomExternalWrapperObject (CustomExternalWrapperObject * instance, bool deepCopy) :
49+ Js::DynamicObject(instance, deepCopy),
50+ initialized(instance->initialized)
51+ {
52+ if (instance->GetInlineSlotSize () != 0 )
53+ {
54+ this ->slotType = SlotType::Inline;
55+ this ->u .inlineSlotSize = instance->GetInlineSlotSize ();
56+ if (instance->GetInlineSlots ())
57+ {
58+ memcpy_s (this ->GetInlineSlots (), this ->GetInlineSlotSize (), instance->GetInlineSlots (), instance->GetInlineSlotSize ());
59+ }
60+ }
61+ else
62+ {
63+ this ->slotType = SlotType::External;
64+ this ->u .slot = instance->GetInlineSlots ();
65+ }
66+ }
67+
4868/* static */
4969CustomExternalWrapperObject* CustomExternalWrapperObject::Create (void *data, uint inlineSlotSize, JsTraceCallback traceCallback, JsFinalizeCallback finalizeCallback, JsGetterSetterInterceptor ** getterSetterInterceptor, Js::RecyclableObject * prototype, Js::ScriptContext *scriptContext)
5070{
@@ -120,32 +140,24 @@ BOOL CustomExternalWrapperObject::EnsureInitialized(ScriptContext* requestContex
120140 return TRUE ;
121141}
122142
123- CustomExternalWrapperObject * CustomExternalWrapperObject::Clone (CustomExternalWrapperObject * source, ScriptContext * scriptContext )
143+ CustomExternalWrapperObject* CustomExternalWrapperObject::Copy ( bool deepCopy )
124144{
125- Js::CustomExternalWrapperType * externalType = source->GetExternalType ();
126- Js::JsGetterSetterInterceptor * originalInterceptors = externalType->GetJsGetterSetterInterceptor ();
127- Js::JsGetterSetterInterceptor * newInterceptors = originalInterceptors;
128- Js::CustomExternalWrapperObject * target = Js::CustomExternalWrapperObject::Create (
129- source->GetSlotData (),
130- source->GetInlineSlotSize (),
131- externalType->GetJsTraceCallback (),
132- externalType->GetJsFinalizeCallback (),
133- &newInterceptors,
134- source->GetPrototype (),
135- scriptContext);
136- target->initialized = source->initialized ;
137-
138- bool success = target->TryCopy (source, true );
139- AssertOrFailFast (success);
140-
141- // TODO:akatti: We will always used a cached type, so the following code can be removed.
142- // If we are using type from the cache we don't need to copy the interceptors over.
143- if (newInterceptors != originalInterceptors)
144- {
145- memcpy_s (newInterceptors, sizeof (Js::JsGetterSetterInterceptor), originalInterceptors, sizeof (Js::JsGetterSetterInterceptor));
146- }
147-
148- return target;
145+ Recycler* recycler = this ->GetRecycler ();
146+ CustomExternalWrapperType* externalType = this ->GetExternalType ();
147+ int inlineSlotSize = this ->GetInlineSlotSize ();
148+
149+ if (externalType->GetJsTraceCallback () != nullptr )
150+ {
151+ return RecyclerNewTrackedPlus (recycler, inlineSlotSize, CustomExternalWrapperObject, this , deepCopy);
152+ }
153+ else if (externalType->GetJsFinalizeCallback () != nullptr )
154+ {
155+ return RecyclerNewFinalizedPlus (recycler, inlineSlotSize, CustomExternalWrapperObject, this , deepCopy);
156+ }
157+ else
158+ {
159+ return RecyclerNewPlus (recycler, inlineSlotSize, CustomExternalWrapperObject, this , deepCopy);
160+ }
149161}
150162
151163BOOL CustomExternalWrapperObject::IsObjectAlive ()
0 commit comments