| 1668 | } |
| 1669 | |
| 1670 | static Local<Value> CreateMapWrapper( |
| 1671 | ::Windows::Foundation::Collections::IMap<K, V> ^ winRtInstance, |
| 1672 | const std::function<Local<Value>(K)>& keyGetterFunc, |
| 1673 | const std::function<bool(Local<Value>)>& checkKeyTypeFunc, |
| 1674 | const std::function<K(Local<Value>)>& convertToKeyTypeFunc, |
| 1675 | const std::function<Local<Value>(V)>& valueGetterFunc, |
| 1676 | const std::function<bool(Local<Value>)>& checkValueTypeFunc, |
| 1677 | const std::function<V(Local<Value>)>& convertToValueTypeFunc) { |
| 1678 | EscapableHandleScope scope; |
| 1679 | if (winRtInstance == nullptr) { |
| 1680 | return scope.Escape(Undefined()); |
| 1681 | } |
| 1682 | |
| 1683 | if (s_constructorTemplate.IsEmpty()) { |
| 1684 | Init(); |
| 1685 | } |
| 1686 | |
| 1687 | v8::Local<Value> args[] = {Undefined()}; |
| 1688 | Local<FunctionTemplate> localRef = |
| 1689 | Nan::New<FunctionTemplate>(s_constructorTemplate); |
| 1690 | Local<Object> objectInstance = |
| 1691 | Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) |
| 1692 | .ToLocalChecked(); |
| 1693 | if (objectInstance.IsEmpty()) { |
| 1694 | return scope.Escape(Undefined()); |
| 1695 | } |
| 1696 | |
| 1697 | MapWrapper<K, V>* wrapperInstance = new MapWrapper<K, V>( |
| 1698 | winRtInstance, keyGetterFunc, checkKeyTypeFunc, convertToKeyTypeFunc, |
| 1699 | valueGetterFunc, checkValueTypeFunc, convertToValueTypeFunc); |
| 1700 | wrapperInstance->Wrap(objectInstance); |
| 1701 | return scope.Escape(objectInstance); |
| 1702 | } |
| 1703 | |
| 1704 | virtual ::Platform::Object ^ GetObjectInstance() const override { |
| 1705 | return _instance; |