|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include <elements/metavirtctor.h> |
|
22 |
|
23 |
|
24 #ifdef _DEBUG |
|
25 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
26 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
27 _LIT(KSpecAssert_ElemNetMetaMtVrt, "ElemNetMetaMtVrt"); |
|
28 #endif |
|
29 |
|
30 #if !defined(VERIFY_RESULT) && defined(_DEBUG) |
|
31 #define VERIFY_RESULT(c,d) __ASSERT_DEBUG(c==d, User::Panic(KSpecAssert_ElemNetMetaMtVrt, 1)) |
|
32 #else |
|
33 #define VERIFY_RESULT(c,d) ((void)(c)) |
|
34 #endif |
|
35 |
|
36 using namespace Meta; |
|
37 |
|
38 _LIT(KMetaDataNetCtorPanic, "MetaDataNetCtor"); |
|
39 enum TMetaDataNetCtorPanic |
|
40 { |
|
41 EConstructedObjectTooBig = 0 |
|
42 }; |
|
43 |
|
44 /** Thin helper to in-place construction in a descriptor (eg TBuf8) |
|
45 */ |
|
46 EXPORT_C TAny* SMetaDataNetCtor::operator new(TUint aSize, TDes8& aBuff) |
|
47 { |
|
48 __ASSERT_ALWAYS(aSize <= static_cast<TUint>(aBuff.MaxSize()), User::Panic(KMetaDataNetCtorPanic, EConstructedObjectTooBig)); |
|
49 return const_cast<TUint8*>(aBuff.Ptr()); |
|
50 } |
|
51 |
|
52 EXPORT_C SMetaDataNetCtor* CMetaDataVirtualCtorInPlace::New(const Meta::STypeId& aType, TDes8& aBuff) const |
|
53 { |
|
54 return static_cast<SMetaDataNetCtor*>(VC::CVirtualCtorInPlace::New(aType, aBuff)); |
|
55 } |
|
56 |
|
57 EXPORT_C SMetaDataNetCtor* CMetaDataVirtualCtorInPlace::New(const Meta::STypeId& aType, TPtrC8& aParams, TDes8& aBuff) const |
|
58 { |
|
59 SMetaDataNetCtor* self = CMetaDataVirtualCtorInPlace::New(aType,aBuff); |
|
60 if (self) |
|
61 { |
|
62 VERIFY_RESULT(self->Load(aParams), KErrNone); |
|
63 } |
|
64 return self; |
|
65 } |
|
66 |
|
67 EXPORT_C SMetaDataNetCtor* CMetaDataVirtualCtorInPlace::New(TPtrC8& aParams, TDes8& aBuff) const |
|
68 { |
|
69 __ASSERT_DEBUG(aParams.Length() >= sizeof(Meta::STypeId), User::Panic(KSpecAssert_ElemNetMetaMtVrt, 2)); |
|
70 const Meta::STypeId* typeId = reinterpret_cast<const Meta::STypeId*>(aParams.Ptr()); |
|
71 if (typeId==NULL) |
|
72 { |
|
73 return NULL; |
|
74 } |
|
75 typeId->Check(aParams); //Strip the buffer |
|
76 return New(*typeId, aParams, aBuff); |
|
77 } |
|
78 |
|
79 |