diff --git a/build/electron-projection/MIDI Project electron projection notes.txt b/build/electron-projection/MIDI Project electron projection notes.txt index c5cc7a52a..863128285 100644 --- a/build/electron-projection/MIDI Project electron projection notes.txt +++ b/build/electron-projection/MIDI Project electron projection notes.txt @@ -21,7 +21,9 @@ npm config edit msvs_version=2022 -nodert\src\NodeRTCmd\bin\Debug\NodeRTCmd.exe --winmd ..\Windows.Devices.Midi2.winmd --outdir .\projection +nodert\src\NodeRTCmd\bin\Debug\NodeRTCmd.exe --winmd ..\staging\api\x64\Windows.Devices.Midi2.winmd --outdir .\projection + +open the build/binding solution In VS C++ project, for all configurations, update the AdditionalUsingDirectories property to include %Program Files (x86)%\Windows Kits\10\UnionMetadata\10.0.20348.0 diff --git a/build/electron-projection/projection3/windows.devices.midi2/.npmignore b/build/electron-projection/projection3/windows.devices.midi2/.npmignore new file mode 100644 index 000000000..f5c9ab246 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/.npmignore @@ -0,0 +1,6 @@ +*.vcxproj +*.filters +*.user +Debug +Release +test \ No newline at end of file diff --git a/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverter.h b/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverter.h new file mode 100644 index 000000000..76f6ce371 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverter.h @@ -0,0 +1,280 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once +#include +#include +#include "CollectionsConverterUtils.h" +#include "NodeRtUtils.h" +#include "nan.h" + +namespace NodeRT { +namespace Collections { + +Nan::Persistent g_keyProp; +Nan::Persistent g_valueProp; + +static void initProps() { + if (g_keyProp.IsEmpty()) + g_keyProp.Reset(Nan::New("key").ToLocalChecked()); + + if (g_valueProp.IsEmpty()) + g_valueProp.Reset(Nan::New("value").ToLocalChecked()); +} + +static std::function)> checkStringFunc = + [](v8::Local value) -> bool { return value->IsString(); }; + +template + static ::Platform::Collections::Map ^ + JsArrayToWinrtMap( + v8::Local arr, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map stdMap; + if (!FillMapFromJsArray(arr, checkKeyTypeFunc, convertToKeyTypeFunc, + checkValueTypeFunc, convertToValueTypeFunc, + stdMap)) { + return nullptr; + } + + // TODO: michfa: consider using std::move (here & everywhere), e.g: return + // ref new ::Platform::Collections::Map(std::move(stdMap)); + // std::move will give a more efficient initialization from std::map, will + // invalidate stdMap however- some types will throw while moving + return ref new ::Platform::Collections::Map(stdMap); + } + + template + static ::Platform::Collections::MapView ^ + JsArrayToWinrtMapView( + v8::Local arr, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map stdMap; + if (!FillMapFromJsArray(arr, checkKeyTypeFunc, convertToKeyTypeFunc, + checkValueTypeFunc, convertToValueTypeFunc, + stdMap)) { + return nullptr; + } + + return ref new ::Platform::Collections::MapView(stdMap); + } + + // A special implementation for the case were the map's keys are strings + // In this case we expect a non-array JS object. + template + static ::Platform::Collections::Map ^ + JsObjectToWinrtMap( + v8::Local obj, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map<::Platform::String ^, V> stdMap; + + if (!FillMapFromJsObject( + obj, checkStringFunc, NodeRT::Utils::V8StringToPlatformString, + checkValueTypeFunc, convertToValueTypeFunc, stdMap)) { + return nullptr; + } + + return ref new ::Platform::Collections::Map<::Platform::String ^, V>( + stdMap); + } + + template + static ::Platform::Collections::MapView ^ + JsObjectToWinrtMapView( + v8::Local obj, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map<::Platform::String ^, V> stdMap; + if (!FillMapFromJsObject( + obj, checkStringFunc, NodeRT::Utils::V8StringToPlatformString, + checkValueTypeFunc, convertToValueTypeFunc, stdMap)) { + return nullptr; + } + + return ref new ::Platform::Collections::MapView<::Platform::String ^, V>( + stdMap); + } + + template + static ::Platform::Collections::Vector ^ + JsArrayToWinrtVector( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::vector vec(arr->Length()); + if (!FillVector&, V>(arr, checkValueTypeFunc, + convertToValueTypeFunc, vec)) { + return nullptr; + } + + return ref new ::Platform::Collections::Vector(vec); + } + + template + static ::Platform::Collections::VectorView ^ + JsArrayToWinrtVectorView( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::vector vec(arr->Length()); + + if (!FillVector&, V>(arr, checkValueTypeFunc, + convertToValueTypeFunc, vec)) { + return nullptr; + } + + return ref new ::Platform::Collections::VectorView(vec); + } + + template + static ::Platform::Array ^ + JsArrayToWinrtArray( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + auto vec = ref new ::Platform::Array(arr->Length()); + if (!FillVector<::Platform::Array ^, V>(arr, checkValueTypeFunc, + convertToValueTypeFunc, vec)) { + return nullptr; + } + + return vec; + } +} // namespace Collections + +template +static void InsertToVector( + uint32_t index, + v8::Local value, + const std::function)>& convertToValueTypeFunc, + std::vector& vec) { + vec[index] = convertToValueTypeFunc(value); +} + +template +static void InsertToVector( + uint32_t index, + v8::Local value, + const std::function)>& convertToValueTypeFunc, + ::Platform::Array ^ vec) { + vec->set(index, convertToValueTypeFunc(value)); +} + +// assumption: vec length >= arr length +template +static bool FillVector( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc, + T vec) { + for (uint32_t i = 0; i < arr->Length(); i++) { + Local value = Nan::Get(arr, i).ToLocalChecked(); + + if (!checkValueTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Received array with unexpected value type"))); + return false; + } + + InsertToVector(i, value, convertToValueTypeFunc, vec); + } + + return true; +} + +template +static bool FillMapFromJsArray( + v8::Local arr, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc, + std::map& stdMap) { + initProps(); + + // expect that each element in the array will be an object with 2 properties: + // key and value (with types that match K and V respectively) + for (uint32_t i = 0; i < arr->Length(); i++) { + Local curr = Nan::Get(arr, i).ToLocalChecked(); + + if (!curr->IsObject()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Array elements are expected to be javascript objects"))); + return false; + } + + v8::Local obj = curr.As(); + + if (!obj->Has(g_keyProp) || !obj->Has(g_valueProp)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Array elements are expected to be javascript objects with \'key\' " + L"and \'value\' properties"))); + return false; + } + + Local key = Nan::Get(obj, g_keyProp).ToLocalChecked(); + Local value = Nan::Get(obj, g_valueProp).ToLocalChecked(); + + if (!checkKeyTypeFunc(key)) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Array element has invalid key type"))); + return false; + } + + if (!checkValueTypeFunc(value)) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Array element has invalid value type"))); + return false; + } + + stdMap.insert(std::pair(convertToKeyTypeFunc(key), + convertToValueTypeFunc(value))); + } + + return true; +} + +template +static bool FillMapFromJsObject( + v8::Local obj, + const std::function)>& checkKeyTypeFunc, + const std::function<::Platform::String ^ (v8::Local)>& + convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc, + std::map<::Platform::String ^, V>& stdMap) { + Local objProps = Nan::GetPropertyNames(obj).ToLocalChecked(); + for (uint32_t i = 0; i < objProps->Length(); i++) { + Local key = Nan::Get(objProps, i).ToLocalChecked(); + Local value = Nan::Get(obj, key).ToLocalChecked(); + if (!checkValueTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Received object with unexpected value type"))); + return false; + } + + stdMap.insert(std::pair<::Platform::String ^, V>( + convertToKeyTypeFunc(key), convertToValueTypeFunc(value))); + } + return true; +} +}; // namespace NodeRT diff --git a/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverterUtils.cpp b/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverterUtils.cpp new file mode 100644 index 000000000..be071ac7b --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverterUtils.cpp @@ -0,0 +1,44 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#include "CollectionsConverterUtils.h" + +namespace std { +bool operator==(const ::Windows::Foundation::TimeSpan& first, + const ::Windows::Foundation::TimeSpan& second) { + return first.Duration == second.Duration; +} + +bool operator==( + const ::Windows::Devices::Geolocation::BasicGeoposition& first, + const ::Windows::Devices::Geolocation::BasicGeoposition& second) { + return (first.Altitude == second.Altitude) && + (first.Latitude == second.Latitude) && + (first.Longitude == second.Longitude); +} + +bool operator==(const ::Windows::Storage::Search::SortEntry& first, + const ::Windows::Storage::Search::SortEntry& second) { + return (first.AscendingOrder == second.AscendingOrder) && + (first.PropertyName == second.PropertyName); +} + +bool operator==(const ::Windows::Data::Text::TextSegment& first, + const ::Windows::Data::Text::TextSegment& second) { + return (first.Length == second.Length) && + (first.StartPosition == second.StartPosition); +} + +} // namespace std diff --git a/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverterUtils.h b/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverterUtils.h new file mode 100644 index 000000000..180a443c8 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/CollectionsConverterUtils.h @@ -0,0 +1,37 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +// Every type used in Vector or VectorView template instantiation must have +// operator== Implement operator== for types that don't have an operator== +// implementation available and there is no acceptable conversion to an existing +// operator== +namespace std { + +bool operator==(const ::Windows::Foundation::TimeSpan& first, + const ::Windows::Foundation::TimeSpan& second); + +bool operator==( + const ::Windows::Devices::Geolocation::BasicGeoposition& first, + const ::Windows::Devices::Geolocation::BasicGeoposition& second); + +bool operator==(const ::Windows::Storage::Search::SortEntry& first, + const ::Windows::Storage::Search::SortEntry& second); + +bool operator==(const ::Windows::Data::Text::TextSegment& first, + const ::Windows::Data::Text::TextSegment& second); + +} // namespace std diff --git a/build/electron-projection/projection3/windows.devices.midi2/CollectionsWrap.h b/build/electron-projection/projection3/windows.devices.midi2/CollectionsWrap.h new file mode 100644 index 000000000..330453961 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/CollectionsWrap.h @@ -0,0 +1,1989 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. +#pragma once + +#include +#include "NodeRtUtils.h" +#include "OpaqueWrapper.h" +#include "WrapperBase.h" +#include "nan.h" + +#include + +namespace NodeRT { +namespace Collections { + +using Nan::False; +using Nan::HandleScope; +using Nan::MaybeLocal; +using Nan::Null; +using Nan::Persistent; +using Nan::True; +using Nan::Undefined; +using v8::Boolean; +using v8::FunctionTemplate; +using v8::Integer; +using v8::Local; +using v8::String; +using v8::Value; + +template +class ArrayWrapper : NodeRT::WrapperBase { + public: + static void Init() { + EscapableHandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + + localRef->SetClassName( + Nan::New("Windows::Foundation::Array").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + Nan::SetIndexedPropertyHandler(localRef->InstanceTemplate(), Get, Set); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), LengthGetter); + + return; + } + + static Local CreateArrayWrapper( + ::Platform::Array ^ winRtInstance, + const std::function(T)>& getterFunc = nullptr, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + ArrayWrapper* wrapperInstance = new ArrayWrapper( + winRtInstance, getterFunc, checkTypeFunc, convertToTypeFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + ArrayWrapper( + ::Platform::Array ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) + : _instance(winRtInstance), + _getterFunc(getterFunc), + _checkTypeFunc(checkTypeFunc), + _convertToTypeFunc(convertToTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void LengthGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info.This())) { + return; + } + + ArrayWrapper* wrapper = + ArrayWrapper::Unwrap>(info.This()); + + try { + unsigned int result = wrapper->_instance->Length; + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Get(uint32_t index, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info.This())) { + return; + } + + ArrayWrapper* wrapper = + ArrayWrapper::Unwrap>(info.This()); + + if (wrapper->_instance->Length <= index) { + return; + } + + if (wrapper->_getterFunc == nullptr) { + info.GetReturnValue().Set(CreateOpaqueWrapper(wrapper->_instance[index])); + } else { + info.GetReturnValue().Set( + wrapper->_getterFunc(wrapper->_instance[index])); + } + } + + static void Set(uint32_t index, + Local value, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info.This())) { + return; + } + + ArrayWrapper* wrapper = + ArrayWrapper::Unwrap>(info.This()); + + if (wrapper->_checkTypeFunc && !wrapper->_checkTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"The argument to set isn't of the expected type or internal WinRt " + L"object was disposed"))); + return; + } + + if (wrapper->_instance->Length <= index) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Given index exceeded array length"))); + return; + } + + if (wrapper->_convertToTypeFunc) { + try { + wrapper->_instance[index] = wrapper->_convertToTypeFunc(value); + } catch (::Platform::Exception ^ e) { + NodeRT::Utils::ThrowWinRtExceptionInJs(e); + } + } + + return; + } + + private: + ::Platform::Array ^ _instance; + std::function(T)> _getterFunc; + std::function)> _checkTypeFunc; + std::function)> _convertToTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent ArrayWrapper::s_constructorTemplate; + +template +class IteratorWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IIterator") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "getMany", GetMany); + Nan::SetPrototypeMethod(localRef, "moveNext", MoveNext); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("current").ToLocalChecked(), + CurrentGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("hasCurrent").ToLocalChecked(), + HasCurrentGetter); + + return; + } + + static Local CreateIteratorWrapper( + ::Windows::Foundation::Collections::IIterator ^ winRtInstance, + const std::function(T)>& getterFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + IteratorWrapper* wrapperInstance = + new IteratorWrapper(winRtInstance, getterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + IteratorWrapper(::Windows::Foundation::Collections::IIterator ^ + winRtInstance, + const std::function(T)>& getterFunc) + : _instance(winRtInstance), _getterFunc(getterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + info.GetReturnValue().Set(info.This()); + } + + static void MoveNext(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterator ^>(info.This())) { + return; + } + + IteratorWrapper* wrapper = + IteratorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + bool result; + result = wrapper->_instance->MoveNext(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + // Not supporting this for now since we need to initialize the array ourselves + // and don't know which size to use + static void GetMany(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + return; + } + + static void CurrentGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterator ^>(info.This())) { + return; + } + + IteratorWrapper* wrapper = + IteratorWrapper::Unwrap>(info.This()); + + try { + T current = wrapper->_instance->Current; + + if (wrapper->_getterFunc != nullptr) { + info.GetReturnValue().Set(wrapper->_getterFunc(current)); + } else { + info.GetReturnValue().Set(CreateOpaqueWrapper(current)); + } + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void HasCurrentGetter( + Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterator ^>(info.This())) { + return; + } + + IteratorWrapper* wrapper = + IteratorWrapper::Unwrap>(info.This()); + + try { + bool result = wrapper->_instance->HasCurrent; + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IIterator ^ _instance; + std::function(T)> _getterFunc; + static Persistent s_constructorTemplate; +}; + +template +class IterableWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IIterable") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "first", First); + + return; + } + + static Local CreateIterableWrapper( + ::Windows::Foundation::Collections::IIterable ^ winRtInstance, + const std::function(T)>& getterFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + IterableWrapper* wrapperInstance = + new IterableWrapper(winRtInstance, getterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + IterableWrapper(::Windows::Foundation::Collections::IIterable ^ + winRtInstance, + const std::function(T)>& getterFunc) + : _instance(winRtInstance), _getterFunc(getterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This().Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + info.GetReturnValue().Set(info.This()); + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterable ^>(info.This())) { + return; + } + + IterableWrapper* wrapper = + IterableWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IIterator ^ result = + wrapper->_instance->First(); + + info.GetReturnValue().Set(IteratorWrapper::CreateIteratorWrapper( + result, wrapper->_getterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + private: + ::Windows::Foundation::Collections::IIterable ^ _instance; + std::function(T)> _getterFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent IterableWrapper::s_constructorTemplate; + +template +Persistent IteratorWrapper::s_constructorTemplate; + +template +class VectorViewWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IVectorView") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + Nan::SetIndexedPropertyHandler(localRef->InstanceTemplate(), Get); + + Nan::SetPrototypeMethod(localRef, "getMany", GetMany); + Nan::SetPrototypeMethod(localRef, "getAt", GetAt); + Nan::SetPrototypeMethod(localRef, "indexOf", IndexOf); + Nan::SetPrototypeMethod(localRef, "first", First); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateVectorViewWrapper( + ::Windows::Foundation::Collections::IVectorView ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + VectorViewWrapper* wrapperInstance = + new VectorViewWrapper(winRtInstance, getterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + VectorViewWrapper( + ::Windows::Foundation::Collections::IVectorView ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) + : _instance(winRtInstance), + _getterFunc(getterFunc), + _checkTypeFunc(checkTypeFunc), + _convertToTypeFunc(convertToTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void Get(uint32_t index, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (wrapper->_instance->Size <= index) { + return; + } + + if (wrapper->_getterFunc == nullptr) { + info.GetReturnValue().Set( + CreateOpaqueWrapper(wrapper->_instance->GetAt(index))); + } else { + info.GetReturnValue().Set( + wrapper->_getterFunc(wrapper->_instance->GetAt(index))); + } + } + + static void GetAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && info[0]->IsUint32()) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + if (index >= wrapper->_instance->Size) { + return; + } + T result; + result = wrapper->_instance->GetAt(index); + + if (wrapper->_getterFunc) { + info.GetReturnValue().Set(wrapper->_getterFunc(result)); + } + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void GetMany(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + return; + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + info.GetReturnValue().Set(IteratorWrapper::CreateIteratorWrapper( + wrapper->_instance->First(), wrapper->_getterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void IndexOf(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (wrapper->_convertToTypeFunc == nullptr || + wrapper->_checkTypeFunc == nullptr) { + Nan::ThrowError( + Nan::Error(NodeRT::Utils::NewString(L"Method isn't supported"))); + return; + } + + if (info.Length() == 1 && wrapper->_checkTypeFunc(info[0])) { + try { + T item = wrapper->_convertToTypeFunc(info[0]); + + unsigned int index; + bool result = wrapper->_instance->IndexOf(item, &index); + + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("boolean").ToLocalChecked(), + Nan::New(result)); + Nan::Set(resObj, Nan::New("index").ToLocalChecked(), + Nan::New(index)); + info.GetReturnValue().Set(resObj); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IVectorView ^ _instance; + std::function(T)> _getterFunc; + std::function)> _checkTypeFunc; + std::function)> _convertToTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent VectorViewWrapper::s_constructorTemplate; + +template +class VectorWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IVector") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + Nan::SetIndexedPropertyHandler(localRef->InstanceTemplate(), Get, Set); + + Nan::SetPrototypeMethod(localRef, "getMany", GetMany); + Nan::SetPrototypeMethod(localRef, "getAt", GetAt); + Nan::SetPrototypeMethod(localRef, "indexOf", IndexOf); + Nan::SetPrototypeMethod(localRef, "first", First); + Nan::SetPrototypeMethod(localRef, "append", Append); + Nan::SetPrototypeMethod(localRef, "clear", Clear); + Nan::SetPrototypeMethod(localRef, "getView", GetView); + Nan::SetPrototypeMethod(localRef, "insertAt", InsertAt); + Nan::SetPrototypeMethod(localRef, "removeAt", RemoveAt); + Nan::SetPrototypeMethod(localRef, "removeAtEnd", RemoveAtEnd); + Nan::SetPrototypeMethod(localRef, "replaceAll", ReplaceAll); + Nan::SetPrototypeMethod(localRef, "setAt", SetAt); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateVectorWrapper( + ::Windows::Foundation::Collections::IVector ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + VectorWrapper* wrapperInstance = new VectorWrapper( + winRtInstance, getterFunc, checkTypeFunc, convertToTypeFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + VectorWrapper( + ::Windows::Foundation::Collections::IVector ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) + : _instance(winRtInstance), + _getterFunc(getterFunc), + _checkTypeFunc(checkTypeFunc), + _convertToTypeFunc(convertToTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void Get(uint32_t index, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (wrapper->_instance->Size <= index) { + return; + } + + if (wrapper->_getterFunc == nullptr) { + info.GetReturnValue().Set( + CreateOpaqueWrapper(wrapper->_instance->GetAt(index))); + } else { + info.GetReturnValue().Set( + wrapper->_getterFunc(wrapper->_instance->GetAt(index))); + } + } + + static void Set(uint32 index, + Local value, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (!wrapper->_checkTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"The value to set isn't of the expected type"))); + return; + } + + try { + T item = wrapper->_convertToTypeFunc(value); + + wrapper->_instance->SetAt(index, item); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + return; + } + + static void Append(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkTypeFunc(info[0])) { + try { + T value = wrapper->_convertToTypeFunc(info[0]); + + wrapper->_instance->Append(value); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Clear(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + wrapper->_instance->Clear(); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void GetMany(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + return; + } + + static void GetView(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IVectorView ^ result = + wrapper->_instance->GetView(); + info.GetReturnValue().Set(VectorViewWrapper::CreateVectorViewWrapper( + result, wrapper->_getterFunc, wrapper->_checkTypeFunc, + wrapper->_convertToTypeFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void InsertAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 2 && info[0]->IsUint32() && + wrapper->_checkTypeFunc(info[1])) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + T value = wrapper->_convertToTypeFunc(info[1]); + wrapper->_instance->InsertAt(index, value); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void RemoveAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && info[0]->IsUint32()) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + wrapper->_instance->RemoveAt(index); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void RemoveAtEnd(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + wrapper->_instance->RemoveAtEnd(); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ReplaceAll(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && + NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info[0])) { + try { + WrapperBase* itemsWrapper = + WrapperBase::Unwrap(info[0].As()); + ::Platform::Array ^ items = + (::Platform::Array ^) itemsWrapper->GetObjectInstance(); + wrapper->_instance->ReplaceAll(items); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && info[0]->IsUint32()) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + if (index >= wrapper->_instance->Size) { + return; + } + T result; + result = wrapper->_instance->GetAt(index); + + if (wrapper->_getterFunc) { + info.GetReturnValue().Set(wrapper->_getterFunc(result)); + } + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SetAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 2 && info[0]->IsUint32() && + wrapper->_checkTypeFunc(info[1])) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + if (index >= wrapper->_instance->Size) { + return; + } + + T item = wrapper->_convertToTypeFunc(info[1]); + + wrapper->_instance->SetAt(index, item); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + info.GetReturnValue().Set(IteratorWrapper::CreateIteratorWrapper( + wrapper->_instance->First(), wrapper->_getterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void IndexOf(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (wrapper->_convertToTypeFunc == nullptr || + wrapper->_checkTypeFunc == nullptr) { + Nan::ThrowError( + Nan::Error(NodeRT::Utils::NewString(L"Method isn't supported"))); + return; + } + + if (info.Length() == 1 && wrapper->_checkTypeFunc(info[0])) { + try { + T item = wrapper->_convertToTypeFunc(info[0]); + + unsigned int index; + bool result = wrapper->_instance->IndexOf(item, &index); + + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("boolean").ToLocalChecked(), + Nan::New(result)); + Nan::Set(resObj, Nan::New("index").ToLocalChecked(), + Nan::New(index)); + info.GetReturnValue().Set(resObj); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IVector ^ _instance; + std::function(T)> _getterFunc; + std::function)> _checkTypeFunc; + std::function)> _convertToTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent VectorWrapper::s_constructorTemplate; + +template +class KeyValuePairWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IKeyValuePair") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("key").ToLocalChecked(), KeyGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("value").ToLocalChecked(), ValueGetter); + + return; + } + + static Local CreateKeyValuePairWrapper( + ::Windows::Foundation::Collections::IKeyValuePair ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function(V)>& valueGetterFunc) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + KeyValuePairWrapper* wrapperInstance = new KeyValuePairWrapper( + winRtInstance, keyGetterFunc, valueGetterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + KeyValuePairWrapper(::Windows::Foundation::Collections::IKeyValuePair ^ + winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function(V)>& valueGetterFunc) + : _instance(winRtInstance), + _keyGetterFunc(keyGetterFunc), + _valueGetterFunc(valueGetterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + info.GetReturnValue().Set(info.This()); + } + + static void KeyGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IKeyValuePair ^>( + info.This())) { + return; + } + + KeyValuePairWrapper* wrapper = + KeyValuePairWrapper::Unwrap>( + info.This()); + + try { + info.GetReturnValue().Set( + wrapper->_keyGetterFunc(wrapper->_instance->Key)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ValueGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IKeyValuePair ^>( + info.This())) { + return; + } + + KeyValuePairWrapper* wrapper = + KeyValuePairWrapper::Unwrap>( + info.This()); + + try { + info.GetReturnValue().Set( + wrapper->_valueGetterFunc(wrapper->_instance->Value)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IKeyValuePair ^ _instance; + std::function(K)> _keyGetterFunc; + std::function(V)> _valueGetterFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent KeyValuePairWrapper::s_constructorTemplate; + +template +class MapViewWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IMapView") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "hasKey", HasKey); + Nan::SetPrototypeMethod(localRef, "lookup", Lookup); + Nan::SetPrototypeMethod(localRef, "split", Split); + Nan::SetPrototypeMethod(localRef, "first", First); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateMapViewWrapper( + ::Windows::Foundation::Collections::IMapView ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + MapViewWrapper* wrapperInstance = + new MapViewWrapper(winRtInstance, keyGetterFunc, checkKeyTypeFunc, + convertToKeyTypeFunc, valueGetterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + MapViewWrapper(::Windows::Foundation::Collections::IMapView ^ + winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc) + : _instance(winRtInstance), + _keyGetterFunc(keyGetterFunc), + _checkKeyTypeFunc(checkKeyTypeFunc), + _convertToKeyTypeFunc(convertToKeyTypeFunc), + _valueGetterFunc(valueGetterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void HasKey(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + bool result = wrapper->_instance->HasKey(key); + + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + const std::function(K)>& keyGetter = + wrapper->_keyGetterFunc; + const std::function(V)>& valueGetter = + wrapper->_valueGetterFunc; + info.GetReturnValue().Set( + IteratorWrapper< + ::Windows::Foundation::Collections::IKeyValuePair ^>:: + CreateIteratorWrapper( + wrapper->_instance->First(), + [keyGetter, valueGetter]( + ::Windows::Foundation::Collections::IKeyValuePair ^ + value) { + return KeyValuePairWrapper< + K, V>::CreateKeyValuePairWrapper(value, keyGetter, + valueGetter); + })); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Lookup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + V result = wrapper->_instance->Lookup(key); + + info.GetReturnValue().Set(wrapper->_valueGetterFunc(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Split(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IMapView ^ first; + ::Windows::Foundation::Collections::IMapView ^ second; + + wrapper->_instance->Split(&first, &second); + + Local resObj = Nan::New(); + Nan::Set( + resObj, Nan::New("first").ToLocalChecked(), + MapViewWrapper::CreateMapViewWrapper( + first, wrapper->_keyGetterFunc, wrapper->_checkTypeFunc, + wrapper->_convertToKeyTypeFunc, wrapper->_valueGetterFunc)); + Nan::Set( + resObj, Nan::New("second").ToLocalChecked(), + MapViewWrapper::CreateMapViewWrapper( + second, wrapper->_keyGetterFunc, wrapper->_checkTypeFunc, + wrapper->_convertToKeyTypeFunc, wrapper->_valueGetterFunc)); + info.GetReturnValue().Set(resObj); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IMapView ^ _instance; + std::function)> _checkTypeFunc; + std::function(K)> _keyGetterFunc; + std::function)> _convertToKeyTypeFunc; + std::function(V)> _valueGetterFunc; + std::function)> _checkKeyTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent MapViewWrapper::s_constructorTemplate; + +template +class MapWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IMap") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "hasKey", HasKey); + Nan::SetPrototypeMethod(localRef, "lookup", Lookup); + Nan::SetPrototypeMethod(localRef, "getView", GetView); + Nan::SetPrototypeMethod(localRef, "clear", Clear); + Nan::SetPrototypeMethod(localRef, "insert", Insert); + Nan::SetPrototypeMethod(localRef, "remove", Remove); + Nan::SetPrototypeMethod(localRef, "first", First); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateMapWrapper( + ::Windows::Foundation::Collections::IMap ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + MapWrapper* wrapperInstance = new MapWrapper( + winRtInstance, keyGetterFunc, checkKeyTypeFunc, convertToKeyTypeFunc, + valueGetterFunc, checkValueTypeFunc, convertToValueTypeFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + MapWrapper(::Windows::Foundation::Collections::IMap ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) + : _instance(winRtInstance), + _keyGetterFunc(keyGetterFunc), + _checkKeyTypeFunc(checkKeyTypeFunc), + _convertToKeyTypeFunc(convertToKeyTypeFunc), + _valueGetterFunc(valueGetterFunc), + _checkValueTypeFunc(checkValueTypeFunc), + _convertToValueTypeFunc(convertToValueTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void HasKey(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + bool result = wrapper->_instance->HasKey(key); + + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Remove(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + wrapper->_instance->Remove(key); + + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Insert(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 2 && wrapper->_checkKeyTypeFunc(info[0]) && + wrapper->_checkValueTypeFunc(info[1])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + V value = wrapper->_convertToValueTypeFunc(info[1]); + + bool result = wrapper->_instance->Insert(key, value); + + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + const std::function(K)>& keyGetter = + wrapper->_keyGetterFunc; + const std::function(V)>& valueGetter = + wrapper->_valueGetterFunc; + info.GetReturnValue().Set( + IteratorWrapper< + ::Windows::Foundation::Collections::IKeyValuePair ^>:: + CreateIteratorWrapper( + wrapper->_instance->First(), + [keyGetter, valueGetter]( + ::Windows::Foundation::Collections::IKeyValuePair ^ + value) { + return KeyValuePairWrapper< + K, V>::CreateKeyValuePairWrapper(value, keyGetter, + valueGetter); + })); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Lookup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + V result = wrapper->_instance->Lookup(key); + + info.GetReturnValue().Set(wrapper->_valueGetterFunc(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void GetView(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IMapView ^ result = + wrapper->_instance->GetView(); + + info.GetReturnValue().Set(MapViewWrapper::CreateMapViewWrapper( + result, wrapper->_keyGetterFunc, wrapper->_checkKeyTypeFunc, + wrapper->_convertToKeyTypeFunc, wrapper->_valueGetterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Clear(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + wrapper->_instance->Clear(); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IMap ^ _instance; + + std::function(K)> _keyGetterFunc; + std::function)> _convertToKeyTypeFunc; + std::function)> _checkKeyTypeFunc; + + std::function(V)> _valueGetterFunc; + std::function)> _convertToValueTypeFunc; + std::function)> _checkValueTypeFunc; + + static Persistent s_constructorTemplate; +}; + +template +Persistent MapWrapper::s_constructorTemplate; + +} // namespace Collections +}; // namespace NodeRT diff --git a/build/electron-projection/projection3/windows.devices.midi2/LICENSE b/build/electron-projection/projection3/windows.devices.midi2/LICENSE new file mode 100644 index 000000000..ffbdd3201 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/LICENSE @@ -0,0 +1,194 @@ +Copyright 2019, The NodeRT Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +``` +------------------------------------------------------------------------- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +``` diff --git a/build/electron-projection/projection3/windows.devices.midi2/NodeRtUtils.cpp b/build/electron-projection/projection3/windows.devices.midi2/NodeRtUtils.cpp new file mode 100644 index 000000000..ff9ca0094 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/NodeRtUtils.cpp @@ -0,0 +1,718 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#include "NodeRtUtils.h" +#include +#include +#include "OpaqueWrapper.h" +#include "nan.h" + +#define WCHART_NOT_BUILTIN_IN_NODE 1 + +namespace NodeRT { +namespace Utils { + +using Nan::EscapableHandleScope; +using Nan::False; +using Nan::HandleScope; +using Nan::MaybeLocal; +using Nan::Null; +using Nan::Persistent; +using Nan::True; +using Nan::Undefined; +using v8::Boolean; +using v8::Date; +using v8::Function; +using v8::FunctionTemplate; +using v8::Local; +using v8::Integer; +using v8::Local; +using v8::Number; +using v8::Object; +using v8::Primitive; +using v8::PropertyAttribute; +using v8::String; +using v8::Value; + +v8::Local WinRtExceptionToJsError(Platform::Exception ^ exception) { + EscapableHandleScope scope; + + if (exception == nullptr) { + return scope.Escape(Undefined()); + } + + // we use casting here in case that wchar_t is not a built-in type + const wchar_t* errorMessage = exception->Message->Data(); + unsigned int length = exception->Message->Length(); + + Local error = Nan::Error( + Nan::New(reinterpret_cast(errorMessage)) + .ToLocalChecked()); + Nan::Set(Nan::To(error).ToLocalChecked(), + Nan::New("HRESULT").ToLocalChecked(), + Nan::New(exception->HResult)); + + return scope.Escape(error); +} + +void ThrowWinRtExceptionInJs(Platform::Exception ^ exception) { + if (exception == nullptr) { + return; + } + + Nan::ThrowError(WinRtExceptionToJsError(exception)); +} + +// creates an object with the following structure: +// { +// "callback" : [callback fuction] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +Local CreateCallbackObjectInDomain(Local callback) { + EscapableHandleScope scope; + + // get the current domain: + MaybeLocal callbackObject = Nan::New(); + + Nan::Set(callbackObject.ToLocalChecked(), + Nan::New("callback").ToLocalChecked(), callback); + + MaybeLocal processVal = + Nan::Get(Nan::GetCurrentContext()->Global(), + Nan::New("process").ToLocalChecked()); + v8::Local process = + Nan::To(processVal.ToLocalChecked()).ToLocalChecked(); + if (process.IsEmpty() || Nan::Equals(process, Undefined()).FromMaybe(true)) { + return scope.Escape(callbackObject.ToLocalChecked()); + } + + MaybeLocal currentDomain = + Nan::Get(process, Nan::New("domain").ToLocalChecked()); + + if (!currentDomain.IsEmpty() && + !Nan::Equals(currentDomain.ToLocalChecked(), Undefined()) + .FromMaybe(true)) { + Nan::Set(callbackObject.ToLocalChecked(), + Nan::New("domain").ToLocalChecked(), + currentDomain.ToLocalChecked()); + } + + return scope.Escape(callbackObject.ToLocalChecked()); +} + +// Calls the callback in the appropriate domwin, expects an object in the +// following format: +// { +// "callback" : [callback function] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +Local CallCallbackInDomain(Local callbackObject, + int argc, + Local argv[]) { + Nan::AsyncResource asyncResource(Nan::New("CallCallbackInDomain").ToLocalChecked()); + return asyncResource.runInAsyncScope( + callbackObject, + Nan::New("callback").ToLocalChecked(), argc, + argv) + .FromMaybe(v8::Local()); +} + +::Platform::Object ^ + GetObjectInstance(Local value) { + // nulls are allowed when a WinRT wrapped object is expected + if (value->IsNull()) { + return nullptr; + } + + WrapperBase* wrapper = Nan::ObjectWrap::Unwrap( + Nan::To(value).ToLocalChecked()); + return wrapper->GetObjectInstance(); + } + + Local NewString(const wchar_t* str) { +#ifdef WCHART_NOT_BUILTIN_IN_NODE + return Nan::New(reinterpret_cast(str)) + .ToLocalChecked(); +#else + return Nan::New(str).ToLocalChecked(); +#endif +} + +const wchar_t* StringToWchar(v8::String::Value& str) { +#ifdef WCHART_NOT_BUILTIN_IN_NODE + return reinterpret_cast(*str); +#else + return *str; +#endif +} + +// Note: current implementation converts any JS value that has a toString method +// to a ::Platform::String^ Changes to this code might break the Collection +// Convertor logic +::Platform::String ^ + V8StringToPlatformString(Local value) { + v8::String::Value stringVal(v8::Isolate::GetCurrent(), value); +#ifdef WCHART_NOT_BUILTIN_IN_NODE + return ref new Platform::String( + reinterpret_cast(*stringVal)); +#else + return ref new Platform::String(*stringVal); +#endif + } + +#ifndef min + size_t min(size_t one, size_t two) { + if (one < two) { + return one; + } + + return two; +} +#endif + +#ifdef WCHART_NOT_BUILTIN_IN_NODE +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const uint16_t* str2) { + int maxCount = static_cast( + min(wcslen(str1), wcslen(reinterpret_cast(str2)))); + return (_wcsnicmp(str1, reinterpret_cast(str2), maxCount) == + 0); +} +#endif + +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const wchar_t* str2) { + int maxCount = static_cast(min(wcslen(str1), wcslen(str2))); + return (_wcsnicmp(str1, str2, maxCount) == 0); +} + +void RegisterNameSpace(const char* ns, Local nsExports) { + HandleScope scope; + Local global = Nan::GetCurrentContext()->Global(); + + if (!Nan::Has(global, + Nan::New("__winRtNamespaces__").ToLocalChecked()) + .FromMaybe(false)) { + Nan::ForceSet(global, + Nan::New("__winRtNamespaces__").ToLocalChecked(), + Nan::New(), + (v8::PropertyAttribute)(v8::PropertyAttribute::DontEnum & + v8::PropertyAttribute::DontDelete)); + } + + MaybeLocal nsObject = Nan::Get( + global, Nan::New("__winRtNamespaces__").ToLocalChecked()); + Nan::Set(Nan::To(nsObject.ToLocalChecked()).ToLocalChecked(), + Nan::New(ns).ToLocalChecked(), nsExports); +} + +Local CreateExternalWinRTObject(const char* ns, + const char* objectName, + ::Platform::Object ^ instance) { + EscapableHandleScope scope; + Local opaqueWrapper = CreateOpaqueWrapper(instance); + + Local global = Nan::GetCurrentContext()->Global(); + if (!Nan::Has(global, + Nan::New("__winRtNamespaces__").ToLocalChecked()) + .FromMaybe(false)) { + return scope.Escape(opaqueWrapper); + } + + Local winRtObj = + Nan::To( + Nan::Get(global, + Nan::New("__winRtNamespaces__").ToLocalChecked()) + .ToLocalChecked()) + .ToLocalChecked(); + + Local nsSymbol = Nan::New(ns).ToLocalChecked(); + if (!Nan::Has(winRtObj, nsSymbol).FromMaybe(false)) { + return scope.Escape(opaqueWrapper); + } + + v8::MaybeLocal maybeLocalRef = Nan::Get(winRtObj, nsSymbol); + + if (maybeLocalRef.IsEmpty()) { + return scope.Escape(opaqueWrapper); + } + + Local nsObjectValue = maybeLocalRef.ToLocalChecked(); + + if (Nan::Equals(nsObjectValue, Undefined()).FromMaybe(false)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Failed to obtain external namespace object"))); + return Undefined(); + } + + Local nsObject = Nan::To(nsObjectValue).ToLocalChecked(); + + Local objectNameSymbol = + Nan::New(objectName).ToLocalChecked(); + if (!Nan::Has(nsObject, objectNameSymbol).FromMaybe(false)) { + return scope.Escape(opaqueWrapper); + } + + Local objectFunc = + Nan::Get(nsObject, objectNameSymbol).ToLocalChecked().As(); + Local args[] = {opaqueWrapper}; + return scope.Escape( + Nan::NewInstance(objectFunc, _countof(args), args).ToLocalChecked()); +} + +bool IsWinRtWrapper(Local value) { + if (value.IsEmpty() || (!value->IsObject() && !value->IsNull())) { + return false; + } + + // allow passing nulls when a WinRT wrapped object is expected + if (value->IsNull()) { + return true; + } + + if (NodeRT::OpaqueWrapper::IsOpaqueWrapper(value)) { + return true; + } + + Local hiddenVal = + GetHiddenValue(Nan::To(value).ToLocalChecked(), + Nan::New("__winRtInstance__").ToLocalChecked()); + + return (!hiddenVal.IsEmpty() && hiddenVal->IsTrue()); +} + +void SetHiddenValue(Local obj, + Local symbol, + Local data) { + Nan::ForceSet(obj, symbol, data, + static_cast(v8::ReadOnly & v8::DontEnum)); +} + +void SetHiddenValueWithObject(Local obj, + Local symbol, + Local data) { + Nan::ForceSet(obj, symbol, data, + static_cast(v8::ReadOnly & v8::DontEnum)); +} + +Local GetHiddenValue(Local obj, Local symbol) { + return Nan::Get(obj, symbol).ToLocalChecked(); +} + +::Windows::Foundation::TimeSpan TimeSpanFromMilli(int64_t millis) { + ::Windows::Foundation::TimeSpan timeSpan; + timeSpan.Duration = millis * 10000; + + return timeSpan; +} + +::Windows::Foundation::DateTime DateTimeFromJSDate(Local value) { + ::Windows::Foundation::DateTime time; + time.UniversalTime = 0; + if (value->IsDate()) { + // 116444736000000000 = The time in 100 nanoseconds between 1/1/1970(UTC) to + // 1/1/1601(UTC) ux_time = (Current time since 1601 in 100 nano sec + // units)/10000 - 116444736000000000; + time.UniversalTime = value->IntegerValue(Nan::GetCurrentContext()).FromMaybe(0) * 10000 + 116444736000000000; + } + + return time; +} + +Local DateTimeToJS(::Windows::Foundation::DateTime value) { + // 116444736000000000 = The time 100 nanoseconds between 1/1/1970(UTC) to + // 1/1/1601(UTC) ux_time = (Current time since 1601 in 100 nano sec + // units)/10000 - 11644473600000; + return Nan::New(value.UniversalTime / 10000.0 - 11644473600000) + .ToLocalChecked(); +} + +bool StrToGuid(Local value, LPCLSID guid) { + if (value.IsEmpty() || !value->IsString()) { + return false; + } + + v8::String::Value stringVal(v8::Isolate::GetCurrent(), value); + std::wstring guidStr(L"{"); + guidStr += StringToWchar(stringVal); + guidStr += L"}"; + + HRESULT hr = CLSIDFromString(guidStr.c_str(), guid); + if (FAILED(hr)) { + return false; + } + + return true; +} + +bool IsGuid(Local value) { + GUID guid; + return StrToGuid(value, &guid); +} + +::Platform::Guid GuidFromJs(Local value) { + GUID guid; + if (!StrToGuid(value, &guid)) { + return ::Platform::Guid(); + } + + return ::Platform::Guid(guid); +} + +Local GuidToJs(::Platform::Guid guid) { + OLECHAR* bstrGuid; + StringFromCLSID(guid, &bstrGuid); + + Local strVal = NewString(bstrGuid); + CoTaskMemFree(bstrGuid); + return strVal; +} + +Local ColorToJs(::Windows::UI::Color color) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("G").ToLocalChecked(), + Nan::New(color.G)); + Nan::Set(obj, Nan::New("B").ToLocalChecked(), + Nan::New(color.B)); + Nan::Set(obj, Nan::New("A").ToLocalChecked(), + Nan::New(color.A)); + Nan::Set(obj, Nan::New("R").ToLocalChecked(), + Nan::New(color.R)); + + return scope.Escape(obj); +} + +::Windows::UI::Color ColorFromJs(Local value) { + ::Windows::UI::Color retVal = ::Windows::UI::Colors::Black; + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return retVal; + } + + Local obj = Nan::To(value).ToLocalChecked(); + if (!Nan::Has(obj, Nan::New("G").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("G").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + if (!Nan::Has(obj, Nan::New("A").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("A").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + if (!Nan::Has(obj, Nan::New("B").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("B").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + if (!Nan::Has(obj, Nan::New("R").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("R").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + return retVal; +} + +bool IsColor(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + if (!Nan::Has(obj, Nan::New("G").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("A").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("B").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("R").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + return true; +} + +Local RectToJs(::Windows::Foundation::Rect rect) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("bottom").ToLocalChecked(), + Nan::New(rect.Bottom)); + Nan::Set(obj, Nan::New("height").ToLocalChecked(), + Nan::New(rect.Height)); + Nan::Set(obj, Nan::New("left").ToLocalChecked(), + Nan::New(rect.Left)); + Nan::Set(obj, Nan::New("right").ToLocalChecked(), + Nan::New(rect.Right)); + Nan::Set(obj, Nan::New("top").ToLocalChecked(), + Nan::New(rect.Top)); + Nan::Set(obj, Nan::New("width").ToLocalChecked(), + Nan::New(rect.Width)); + Nan::Set(obj, Nan::New("x").ToLocalChecked(), + Nan::New(rect.X)); + Nan::Set(obj, Nan::New("y").ToLocalChecked(), + Nan::New(rect.Y)); + + return scope.Escape(obj); +} + +::Windows::Foundation::Rect RectFromJs(Local value) { + ::Windows::Foundation::Rect rect = ::Windows::Foundation::Rect::Empty; + + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return rect; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + rect.X = static_cast( + Nan::To(Nan::Get(obj, Nan::New("x").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + rect.Y = static_cast( + Nan::To(Nan::Get(obj, Nan::New("y").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + rect.Height = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("height").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + rect.Width = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("width").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + return rect; +} + +bool IsRect(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (!Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + return true; +} + +Local PointToJs(::Windows::Foundation::Point point) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("x").ToLocalChecked(), + Nan::New(point.X)); + Nan::Set(obj, Nan::New("y").ToLocalChecked(), + Nan::New(point.Y)); + + return scope.Escape(obj); +} + +::Windows::Foundation::Point PointFromJs(Local value) { + ::Windows::Foundation::Point point(0, 0); + + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return point; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + point.X = static_cast( + Nan::To(Nan::Get(obj, Nan::New("x").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + point.Y = static_cast( + Nan::To(Nan::Get(obj, Nan::New("y").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + return point; +} + +bool IsPoint(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (!Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + return true; +} + +Local SizeToJs(::Windows::Foundation::Size size) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("height").ToLocalChecked(), + Nan::New(size.Height)); + Nan::Set(obj, Nan::New("width").ToLocalChecked(), + Nan::New(size.Width)); + + return scope.Escape(obj); +} + +::Windows::Foundation::Size SizeFromJs(Local value) { + ::Windows::Foundation::Size size(0, 0); + + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return size; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + size.Height = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("height").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + size.Width = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("width").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + return size; +} + +bool IsSize(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (!Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + return true; +} + +wchar_t GetFirstChar(Local value) { + wchar_t retVal = 0; + + if (!value->IsString()) { + return retVal; + } + + Local str = Nan::To(value).ToLocalChecked(); + if (str->Length() == 0) { + return retVal; + } + + String::Value val(v8::Isolate::GetCurrent(), str); + retVal = (*val)[0]; + return retVal; +} + +Local JsStringFromChar(wchar_t value) { + wchar_t str[2]; + str[0] = value; + str[1] = L'\0'; + + return NewString(str); +} + +::Windows::Foundation::HResult HResultFromJsInt32(int32_t value) { + ::Windows::Foundation::HResult res; + res.Value = value; + return res; +} + +} // namespace Utils +} // namespace NodeRT diff --git a/build/electron-projection/projection3/windows.devices.midi2/NodeRtUtils.h b/build/electron-projection/projection3/windows.devices.midi2/NodeRtUtils.h new file mode 100644 index 000000000..a5743648e --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/NodeRtUtils.h @@ -0,0 +1,139 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +#include +#include "nan.h" + +#define WCHART_NOT_BUILTIN_IN_NODE 1 + +namespace NodeRT { +namespace Utils { + +v8::Local WinRtExceptionToJsError(Platform::Exception ^ exception); + +void ThrowWinRtExceptionInJs(Platform::Exception ^ exception); + +// creates an object with the following structure: +// { +// "callback" : [callback function] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +v8::Local CreateCallbackObjectInDomain( + v8::Local callback); + +// Calls the callback in the appropriate domwin, expects an object in the +// following format: +// { +// "callback" : [callback fuction] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +v8::Local CallCallbackInDomain(v8::Local callbackObject, + int argc, + v8::Local argv[]); + +v8::Local NewString(const wchar_t* str); + +const wchar_t* StringToWchar(v8::String::Value& str); + +::Platform::String ^ V8StringToPlatformString(v8::Local value); + +#ifdef WCHART_NOT_BUILTIN_IN_NODE +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const uint16_t* str2); +#endif + +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const wchar_t* str2); + +// registers the namespace & required object on the global object +void RegisterNameSpace(const char* ns, v8::Local nsExports); + +v8::Local CreateExternalWinRTObject(const char* ns, + const char* objectName, + ::Platform::Object ^ instance); + +bool IsWinRtWrapper(v8::Local value); + +template +bool IsWinRtWrapperOf(v8::Local value) { + if (!IsWinRtWrapper(value)) { + return false; + } + + if (value->IsNull()) { + return true; + } + + WrapperBase* wrapper = + Nan::ObjectWrap::Unwrap(value.As()); + + if (wrapper->GetObjectInstance() == nullptr) { + return false; + } + + try { + T instance = dynamic_cast(wrapper->GetObjectInstance()); + return (instance != nullptr); + } catch (...) { + return false; + } +} + +::Platform::Object ^ GetObjectInstance(v8::Local value); + +void SetHiddenValue(v8::Local obj, + v8::Local symbol, + v8::Local data); +void SetHiddenValueWithObject(v8::Local obj, + v8::Local symbol, + v8::Local data); +v8::Local GetHiddenValue(v8::Local obj, + v8::Local symbol); + +v8::Local DateTimeToJS(::Windows::Foundation::DateTime value); +::Windows::Foundation::TimeSpan TimeSpanFromMilli(int64_t millis); +::Windows::Foundation::DateTime DateTimeFromJSDate(v8::Local value); + +bool IsGuid(v8::Local value); +::Platform::Guid GuidFromJs(v8::Local value); +v8::Local GuidToJs(::Platform::Guid guid); + +v8::Local ColorToJs(::Windows::UI::Color color); +::Windows::UI::Color ColorFromJs(v8::Local value); +bool IsColor(v8::Local value); + +v8::Local RectToJs(::Windows::Foundation::Rect rect); +::Windows::Foundation::Rect RectFromJs(v8::Local value); +bool IsRect(v8::Local value); + +v8::Local PointToJs(::Windows::Foundation::Point point); +::Windows::Foundation::Point PointFromJs(v8::Local value); +bool IsPoint(v8::Local value); + +v8::Local SizeToJs(::Windows::Foundation::Size size); +::Windows::Foundation::Size SizeFromJs(v8::Local value); +bool IsSize(v8::Local value); + +wchar_t GetFirstChar(v8::Local value); +v8::Local JsStringFromChar(wchar_t value); + +::Windows::Foundation::HResult HResultFromJsInt32(int32_t value); + +} // namespace Utils +} // namespace NodeRT \ No newline at end of file diff --git a/build/electron-projection/projection3/windows.devices.midi2/OpaqueWrapper.cpp b/build/electron-projection/projection3/windows.devices.midi2/OpaqueWrapper.cpp new file mode 100644 index 000000000..dda89ede9 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/OpaqueWrapper.cpp @@ -0,0 +1,68 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing permissions +// and limitations under the License. + +#include "OpaqueWrapper.h" +#include "NodeRtUtils.h" + +using v8::String; +using v8::FunctionTemplate; + +Nan::Persistent NodeRT::OpaqueWrapper::s_constructorTemplate; + +void NodeRT::OpaqueWrapper::New(Nan::NAN_METHOD_ARGS_TYPE info) +{ + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winrtOpaqueWrapper__").ToLocalChecked(), Nan::True()); + + info.GetReturnValue().Set(info.This()); +} + + +void NodeRT::OpaqueWrapper::Init() +{ + Nan::HandleScope scope; + // Prepare constructor template + s_constructorTemplate.Reset(Nan::New(New)); + v8::Local localRef = Nan::New(s_constructorTemplate); + localRef->SetClassName(Nan::New("OpaqueWrapper").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); +} + +namespace NodeRT { + v8::Local CreateOpaqueWrapper(::Platform::Object^ winRtInstance) + { + Nan::EscapableHandleScope scope; + if (winRtInstance == nullptr) + { + return scope.Escape(Nan::Undefined()); + } + + v8::Local args[] = { Nan::Undefined() }; + if (OpaqueWrapper::s_constructorTemplate.IsEmpty()) + { + OpaqueWrapper::Init(); + } + + v8::Local localRef = Nan::New(OpaqueWrapper::s_constructorTemplate); + v8::Local objectInstance = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args).ToLocalChecked(); + if (objectInstance.IsEmpty()) + { + return scope.Escape(Nan::Undefined()); + } + OpaqueWrapper* wrapperInstance = new OpaqueWrapper(winRtInstance); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } +} + diff --git a/build/electron-projection/projection3/windows.devices.midi2/OpaqueWrapper.h b/build/electron-projection/projection3/windows.devices.midi2/OpaqueWrapper.h new file mode 100644 index 000000000..94e9a953f --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/OpaqueWrapper.h @@ -0,0 +1,67 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +#include +#include +#include +#include "NodeRTUtils.h" +#include "WrapperBase.h" +#include "nan.h" +#include "nan_object_wrap.h" + +namespace NodeRT { +class OpaqueWrapperInitializer; + +v8::Local CreateOpaqueWrapper(::Platform::Object ^ wintRtHandle); + +class OpaqueWrapper : public WrapperBase { + public: + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + static bool IsOpaqueWrapper(v8::Local value) { + if (value.IsEmpty() || !value->IsObject()) { + return false; + } + + v8::Local hiddenVal = NodeRT::Utils::GetHiddenValue( + value.As(), + Nan::New("__winrtOpaqueWrapper__").ToLocalChecked()); + + if (hiddenVal.IsEmpty() || !hiddenVal->IsBoolean()) { + return false; + } + + return hiddenVal->IsTrue(); + } + + private: + OpaqueWrapper(::Platform::Object ^ instance) : _instance(instance) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info); + static void Init(); + + private: + ::Platform::Object ^ _instance; + static Nan::Persistent s_constructorTemplate; + + friend OpaqueWrapperInitializer; + friend v8::Local CreateOpaqueWrapper(::Platform::Object ^ + wintRtInstance); +}; +} // namespace NodeRT diff --git a/build/electron-projection/projection3/windows.devices.midi2/README.md b/build/electron-projection/projection3/windows.devices.midi2/README.md new file mode 100644 index 000000000..9a88e8db0 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/README.md @@ -0,0 +1,46 @@ +windows.devices.midi2 +===== + +A Node.js wrapper for the Windows.Devices.Midi2 WinRT namespace, compatible with Windows 10 APIs. + +Using this module, you'll be able to consume the Windows.Devices.Midi2 API directly from Node.js. + +This module was automatically generated by NodeRT. +For more information on NodeRT and examples on how to use NodeRT modules, please visit the project page at: https://github.com/NodeRT/NodeRT. + +The API exposed by this module is (almost) the same as the API that is listed in: http://msdn.microsoft.com/en-us/library/windows/apps/Windows.Devices.Midi2.aspx + +The only difference in the API is in the way that asynchronous methods and events are used. (See https://github.com/NodeRT/NodeRT#ConsumingNodeRT for more details) + +This module also contains TypeScript definition files for the API exposed by the module, as well as JavaScript intellisense support for Node.js tools for Visual Studio. + +Prequisites: +============ +* Visual Studio version 2019 and above. (Express Desktop versions also work!) +* Python 2.7 (for node-gyp) +* Important: Updated versions of npm and node-gyp. (Note that the ones that are bundled with node might not be up to date). In order to install latest npm, run: +``` +npm install -g npm +``` + +In order to install latest node-gyp run: +``` +npm install -g node-gyp +``` + +Installation: +============= +In order to install this module, run npm install: + +``` +npm install windows.devices.midi2 +``` + +If you wish to rebuild this module using node-gyp, make sure to use the appropriate VS version using --msvs_version=2012/2013/2015/2017 flag: + +For example: + +``` +cd [module folder path] +node-gyp rebuild --msvs_version=2019 +``` \ No newline at end of file diff --git a/build/electron-projection/projection3/windows.devices.midi2/WrapperBase.h b/build/electron-projection/projection3/windows.devices.midi2/WrapperBase.h new file mode 100644 index 000000000..2e935a093 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/WrapperBase.h @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once +#include + +namespace NodeRT { +class WrapperBase : public Nan::ObjectWrap { + public: + virtual ::Platform::Object ^ GetObjectInstance() const = 0; +}; +} // namespace NodeRT \ No newline at end of file diff --git a/build/electron-projection/projection3/windows.devices.midi2/_nodert_generated.cpp b/build/electron-projection/projection3/windows.devices.midi2/_nodert_generated.cpp new file mode 100644 index 000000000..caa93b0ec --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/_nodert_generated.cpp @@ -0,0 +1,23019 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing permissions +// and limitations under the License. + +// TODO: Verify that this is is still needed.. +#define NTDDI_VERSION 0x06010000 + +#include +#include "nan.h" +#include +#include +#include "CollectionsConverter.h" +#include "CollectionsWrap.h" +#include "node-async.h" +#include "NodeRtUtils.h" +#include "OpaqueWrapper.h" +#include "WrapperBase.h" + +#using + +// this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search +// Some of the node header files brings windows definitions with the same names as some of the WinRT methods +#undef DocumentProperties +#undef GetObject +#undef CreateEvent +#undef FindText +#undef SendMessage + +const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__"; + +using v8::Array; +using v8::String; +using v8::Value; +using v8::Boolean; +using v8::Integer; +using v8::FunctionTemplate; +using v8::Object; +using v8::Local; +using v8::Function; +using v8::Date; +using v8::Number; +using v8::PropertyAttribute; +using v8::Primitive; +using Nan::HandleScope; +using Nan::Persistent; +using Nan::Undefined; +using Nan::True; +using Nan::False; +using Nan::Null; +using Nan::MaybeLocal; +using Nan::EscapableHandleScope; +using Nan::HandleScope; +using Nan::TryCatch; +using namespace concurrency; + +namespace NodeRT { namespace Windows { namespace Devices { namespace Midi2 { + v8::Local WrapIMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ UnwrapIMidiEndpointConnectionSettings(Local value); + + v8::Local WrapIMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ UnwrapIMidiEndpointConnectionSource(Local value); + + v8::Local WrapIMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ UnwrapIMidiEndpointMessageProcessingPlugin(Local value); + + v8::Local WrapIMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ UnwrapIMidiMessageReceivedEventSource(Local value); + + v8::Local WrapIMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ UnwrapIMidiServiceMessageProcessingPluginConfiguration(Local value); + + v8::Local WrapIMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ UnwrapIMidiServiceTransportPluginConfiguration(Local value); + + v8::Local WrapIMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiUniversalPacket^ UnwrapIMidiUniversalPacket(Local value); + + v8::Local WrapMidiChannel(::Windows::Devices::Midi2::MidiChannel^ wintRtInstance); + ::Windows::Devices::Midi2::MidiChannel^ UnwrapMidiChannel(Local value); + + v8::Local WrapMidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ wintRtInstance); + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ UnwrapMidiChannelEndpointListener(Local value); + + v8::Local WrapMidiClock(::Windows::Devices::Midi2::MidiClock^ wintRtInstance); + ::Windows::Devices::Midi2::MidiClock^ UnwrapMidiClock(Local value); + + v8::Local WrapMidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointConnection^ UnwrapMidiEndpointConnection(Local value); + + v8::Local WrapMidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ UnwrapMidiEndpointDeviceInformation(Local value); + + v8::Local WrapMidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ UnwrapMidiEndpointDeviceInformationAddedEventArgs(Local value); + + v8::Local WrapMidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ UnwrapMidiEndpointDeviceInformationRemovedEventArgs(Local value); + + v8::Local WrapMidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ UnwrapMidiEndpointDeviceInformationUpdatedEventArgs(Local value); + + v8::Local WrapMidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ UnwrapMidiEndpointDeviceWatcher(Local value); + + v8::Local WrapMidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ wintRtInstance); + ::Windows::Devices::Midi2::MidiFunctionBlock^ UnwrapMidiFunctionBlock(Local value); + + v8::Local WrapMidiGroup(::Windows::Devices::Midi2::MidiGroup^ wintRtInstance); + ::Windows::Devices::Midi2::MidiGroup^ UnwrapMidiGroup(Local value); + + v8::Local WrapMidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ wintRtInstance); + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ UnwrapMidiGroupEndpointListener(Local value); + + v8::Local WrapMidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ wintRtInstance); + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ UnwrapMidiGroupTerminalBlock(Local value); + + v8::Local WrapMidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage128^ UnwrapMidiMessage128(Local value); + + v8::Local WrapMidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage32^ UnwrapMidiMessage32(Local value); + + v8::Local WrapMidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage64^ UnwrapMidiMessage64(Local value); + + v8::Local WrapMidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage96^ UnwrapMidiMessage96(Local value); + + v8::Local WrapMidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageBuilder^ UnwrapMidiMessageBuilder(Local value); + + v8::Local WrapMidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageConverter^ UnwrapMidiMessageConverter(Local value); + + v8::Local WrapMidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ UnwrapMidiMessageReceivedEventArgs(Local value); + + v8::Local WrapMidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ UnwrapMidiMessageTypeEndpointListener(Local value); + + v8::Local WrapMidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageUtility^ UnwrapMidiMessageUtility(Local value); + + v8::Local WrapMidiService(::Windows::Devices::Midi2::MidiService^ wintRtInstance); + ::Windows::Devices::Midi2::MidiService^ UnwrapMidiService(Local value); + + v8::Local WrapMidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ UnwrapMidiServiceConfigurationResponse(Local value); + + v8::Local WrapMidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ UnwrapMidiServiceLoopbackEndpointCreationResult(Local value); + + v8::Local WrapMidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ UnwrapMidiServiceLoopbackEndpointDefinition(Local value); + + v8::Local WrapMidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ UnwrapMidiServiceMessageProcessingPluginInfo(Local value); + + v8::Local WrapMidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServicePingResponse^ UnwrapMidiServicePingResponse(Local value); + + v8::Local WrapMidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ UnwrapMidiServicePingResponseSummary(Local value); + + v8::Local WrapMidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ UnwrapMidiServiceSessionConnectionInfo(Local value); + + v8::Local WrapMidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ UnwrapMidiServiceSessionInfo(Local value); + + v8::Local WrapMidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ UnwrapMidiServiceTransportPluginInfo(Local value); + + v8::Local WrapMidiSession(::Windows::Devices::Midi2::MidiSession^ wintRtInstance); + ::Windows::Devices::Midi2::MidiSession^ UnwrapMidiSession(Local value); + + v8::Local WrapMidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ wintRtInstance); + ::Windows::Devices::Midi2::MidiSessionSettings^ UnwrapMidiSessionSettings(Local value); + + v8::Local WrapMidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ UnwrapMidiStreamConfigurationRequestReceivedEventArgs(Local value); + + v8::Local WrapMidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ wintRtInstance); + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ UnwrapMidiStreamConfigurationRequestedSettings(Local value); + + v8::Local WrapMidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ wintRtInstance); + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ UnwrapMidiStreamMessageBuilder(Local value); + + v8::Local WrapMidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ wintRtInstance); + ::Windows::Devices::Midi2::MidiUniqueId^ UnwrapMidiUniqueId(Local value); + + v8::Local WrapMidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ wintRtInstance); + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ UnwrapMidiVirtualEndpointDevice(Local value); + + v8::Local WrapMidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ wintRtInstance); + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ UnwrapMidiVirtualEndpointDeviceDefinition(Local value); + + + + + static void InitMidi1ChannelVoiceMessageStatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("Midi1ChannelVoiceMessageStatus").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("noteOff").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::NoteOff))); + Nan::Set(enumObject, Nan::New("noteOn").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::NoteOn))); + Nan::Set(enumObject, Nan::New("polyPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::PolyPressure))); + Nan::Set(enumObject, Nan::New("controlChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::ControlChange))); + Nan::Set(enumObject, Nan::New("programChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::ProgramChange))); + Nan::Set(enumObject, Nan::New("channelPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::ChannelPressure))); + Nan::Set(enumObject, Nan::New("pitchBend").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::PitchBend))); + } + + static void InitMidi2ChannelVoiceMessageStatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("Midi2ChannelVoiceMessageStatus").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("registeredPerNoteController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RegisteredPerNoteController))); + Nan::Set(enumObject, Nan::New("assignablePerNoteController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::AssignablePerNoteController))); + Nan::Set(enumObject, Nan::New("registeredController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RegisteredController))); + Nan::Set(enumObject, Nan::New("assignableController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::AssignableController))); + Nan::Set(enumObject, Nan::New("relativeRegisteredController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RelativeRegisteredController))); + Nan::Set(enumObject, Nan::New("relativeAssignableController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RelativeAssignableController))); + Nan::Set(enumObject, Nan::New("perNotePitchBend").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PerNotePitchBend))); + Nan::Set(enumObject, Nan::New("noteOff").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::NoteOff))); + Nan::Set(enumObject, Nan::New("noteOn").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::NoteOn))); + Nan::Set(enumObject, Nan::New("polyPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PolyPressure))); + Nan::Set(enumObject, Nan::New("controlChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::ControlChange))); + Nan::Set(enumObject, Nan::New("programChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::ProgramChange))); + Nan::Set(enumObject, Nan::New("channelPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::ChannelPressure))); + Nan::Set(enumObject, Nan::New("pitchBend").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PitchBend))); + Nan::Set(enumObject, Nan::New("perNoteManagement").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PerNoteManagement))); + } + + static void InitMidiEndpointDeviceInformationFiltersEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationFilters").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("includeClientUmpNative").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeClientUmpNative))); + Nan::Set(enumObject, Nan::New("includeClientByteStreamNative").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeClientByteStreamNative))); + Nan::Set(enumObject, Nan::New("allTypicalEndpoints").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::AllTypicalEndpoints))); + Nan::Set(enumObject, Nan::New("includeVirtualDeviceResponder").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeVirtualDeviceResponder))); + Nan::Set(enumObject, Nan::New("includeDiagnosticLoopback").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeDiagnosticLoopback))); + Nan::Set(enumObject, Nan::New("includeDiagnosticPing").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeDiagnosticPing))); + } + + static void InitMidiEndpointDeviceInformationSortOrderEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationSortOrder").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("none").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::None))); + Nan::Set(enumObject, Nan::New("name").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::Name))); + Nan::Set(enumObject, Nan::New("endpointDeviceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::EndpointDeviceId))); + Nan::Set(enumObject, Nan::New("deviceInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::DeviceInstanceId))); + Nan::Set(enumObject, Nan::New("containerThenName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::ContainerThenName))); + Nan::Set(enumObject, Nan::New("containerThenEndpointDeviceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::ContainerThenEndpointDeviceId))); + Nan::Set(enumObject, Nan::New("containerThenDeviceInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::ContainerThenDeviceInstanceId))); + Nan::Set(enumObject, Nan::New("transportMnemonicThenName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::TransportMnemonicThenName))); + Nan::Set(enumObject, Nan::New("transportMnemonicThenEndpointDeviceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::TransportMnemonicThenEndpointDeviceId))); + Nan::Set(enumObject, Nan::New("transportMnemonicThenDeviceInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::TransportMnemonicThenDeviceInstanceId))); + } + + static void InitMidiEndpointDevicePurposeEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDevicePurpose").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("normalMessageEndpoint").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::NormalMessageEndpoint))); + Nan::Set(enumObject, Nan::New("virtualDeviceResponder").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::VirtualDeviceResponder))); + Nan::Set(enumObject, Nan::New("inBoxGeneralMidiSynth").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::InBoxGeneralMidiSynth))); + Nan::Set(enumObject, Nan::New("diagnosticLoopback").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::DiagnosticLoopback))); + Nan::Set(enumObject, Nan::New("diagnosticPing").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::DiagnosticPing))); + } + + static void InitMidiEndpointDiscoveryRequestsEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDiscoveryRequests").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("none").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::None))); + Nan::Set(enumObject, Nan::New("requestEndpointInfo").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestEndpointInfo))); + Nan::Set(enumObject, Nan::New("requestDeviceIdentity").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestDeviceIdentity))); + Nan::Set(enumObject, Nan::New("requestEndpointName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestEndpointName))); + Nan::Set(enumObject, Nan::New("requestProductInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestProductInstanceId))); + Nan::Set(enumObject, Nan::New("requestStreamConfiguration").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestStreamConfiguration))); + } + + static void InitMidiEndpointNativeDataFormatEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointNativeDataFormat").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknown").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointNativeDataFormat::Unknown))); + Nan::Set(enumObject, Nan::New("byteStream").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointNativeDataFormat::ByteStream))); + Nan::Set(enumObject, Nan::New("universalMidiPacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointNativeDataFormat::UniversalMidiPacket))); + } + + static void InitMidiFunctionBlockDirectionEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockDirection").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("undefined").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::Undefined))); + Nan::Set(enumObject, Nan::New("blockInput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::BlockInput))); + Nan::Set(enumObject, Nan::New("blockOutput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::BlockOutput))); + Nan::Set(enumObject, Nan::New("bidirectional").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::Bidirectional))); + } + + static void InitMidiFunctionBlockDiscoveryRequestsEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockDiscoveryRequests").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("none").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests::None))); + Nan::Set(enumObject, Nan::New("requestFunctionBlockInfo").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests::RequestFunctionBlockInfo))); + Nan::Set(enumObject, Nan::New("requestFunctionBlockName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests::RequestFunctionBlockName))); + } + + static void InitMidiFunctionBlockMidi10Enum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockMidi10").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("not10").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::Not10))); + Nan::Set(enumObject, Nan::New("yesBandwidthUnrestricted").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::YesBandwidthUnrestricted))); + Nan::Set(enumObject, Nan::New("yesBandwidthRestricted").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::YesBandwidthRestricted))); + Nan::Set(enumObject, Nan::New("reserved").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::Reserved))); + } + + static void InitMidiFunctionBlockUIHintEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockUIHint").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknown").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Unknown))); + Nan::Set(enumObject, Nan::New("receiver").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Receiver))); + Nan::Set(enumObject, Nan::New("sender").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Sender))); + Nan::Set(enumObject, Nan::New("bidirectional").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Bidirectional))); + } + + static void InitMidiGroupTerminalBlockDirectionEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiGroupTerminalBlockDirection").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("bidirectional").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection::Bidirectional))); + Nan::Set(enumObject, Nan::New("blockInput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection::BlockInput))); + Nan::Set(enumObject, Nan::New("blockOutput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection::BlockOutput))); + } + + static void InitMidiGroupTerminalBlockProtocolEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiGroupTerminalBlockProtocol").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknown").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Unknown))); + Nan::Set(enumObject, Nan::New("midi1Message64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message64))); + Nan::Set(enumObject, Nan::New("midi1Message64WithJitterReduction").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message64WithJitterReduction))); + Nan::Set(enumObject, Nan::New("midi1Message128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message128))); + Nan::Set(enumObject, Nan::New("midi1Message128WithJitterReduction").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message128WithJitterReduction))); + Nan::Set(enumObject, Nan::New("midi2").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi2))); + Nan::Set(enumObject, Nan::New("midi2WithJitterReduction").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi2WithJitterReduction))); + } + + static void InitMidiMessageTypeEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiMessageType").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("utilityMessage32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::UtilityMessage32))); + Nan::Set(enumObject, Nan::New("systemCommon32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::SystemCommon32))); + Nan::Set(enumObject, Nan::New("midi1ChannelVoice32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::Midi1ChannelVoice32))); + Nan::Set(enumObject, Nan::New("dataMessage64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::DataMessage64))); + Nan::Set(enumObject, Nan::New("midi2ChannelVoice64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::Midi2ChannelVoice64))); + Nan::Set(enumObject, Nan::New("dataMessage128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::DataMessage128))); + Nan::Set(enumObject, Nan::New("futureReserved632").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved632))); + Nan::Set(enumObject, Nan::New("futureReserved732").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved732))); + Nan::Set(enumObject, Nan::New("futureReserved864").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved864))); + Nan::Set(enumObject, Nan::New("futureReserved964").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved964))); + Nan::Set(enumObject, Nan::New("futureReservedA64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedA64))); + Nan::Set(enumObject, Nan::New("futureReservedB96").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedB96))); + Nan::Set(enumObject, Nan::New("futureReservedC96").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedC96))); + Nan::Set(enumObject, Nan::New("flexData128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FlexData128))); + Nan::Set(enumObject, Nan::New("futureReservedE128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedE128))); + Nan::Set(enumObject, Nan::New("stream128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::Stream128))); + } + + static void InitMidiPacketTypeEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiPacketType").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknownOrInvalid").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UnknownOrInvalid))); + Nan::Set(enumObject, Nan::New("universalMidiPacket32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket32))); + Nan::Set(enumObject, Nan::New("universalMidiPacket64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket64))); + Nan::Set(enumObject, Nan::New("universalMidiPacket96").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket96))); + Nan::Set(enumObject, Nan::New("universalMidiPacket128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket128))); + } + + static void InitMidiProtocolEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiProtocol").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("default").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiProtocol::Default))); + Nan::Set(enumObject, Nan::New("midi1").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiProtocol::Midi1))); + Nan::Set(enumObject, Nan::New("midi2").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiProtocol::Midi2))); + } + + static void InitMidiSendMessageResultsEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiSendMessageResults").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("bufferFull").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::BufferFull))); + Nan::Set(enumObject, Nan::New("endpointConnectionClosedOrInvalid").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::EndpointConnectionClosedOrInvalid))); + Nan::Set(enumObject, Nan::New("invalidMessageTypeForWordCount").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::InvalidMessageTypeForWordCount))); + Nan::Set(enumObject, Nan::New("invalidMessageOther").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::InvalidMessageOther))); + Nan::Set(enumObject, Nan::New("dataIndexOutOfRange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::DataIndexOutOfRange))); + Nan::Set(enumObject, Nan::New("timestampOutOfRange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::TimestampOutOfRange))); + Nan::Set(enumObject, Nan::New("messageListPartiallyProcessed").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::MessageListPartiallyProcessed))); + Nan::Set(enumObject, Nan::New("other").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::Other))); + Nan::Set(enumObject, Nan::New("failed").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::Failed))); + Nan::Set(enumObject, Nan::New("succeeded").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::Succeeded))); + } + + static void InitMidiServiceConfigurationResponseStatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiServiceConfigurationResponseStatus").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("success").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::Success))); + Nan::Set(enumObject, Nan::New("errorTargetNotFound").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorTargetNotFound))); + Nan::Set(enumObject, Nan::New("errorJsonNullOrEmpty").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorJsonNullOrEmpty))); + Nan::Set(enumObject, Nan::New("errorProcessingJson").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorProcessingJson))); + Nan::Set(enumObject, Nan::New("errorNotImplemented").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorNotImplemented))); + Nan::Set(enumObject, Nan::New("errorOther").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorOther))); + } + + static void InitMidiSystemExclusive8StatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiSystemExclusive8Status").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("completeMessageInSingleMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::CompleteMessageInSingleMessagePacket))); + Nan::Set(enumObject, Nan::New("startMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::StartMessagePacket))); + Nan::Set(enumObject, Nan::New("continueMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::ContinueMessagePacket))); + Nan::Set(enumObject, Nan::New("endMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::EndMessagePacket))); + } + + static bool IsMidiMessageStructJsObject(Local value) { + if (!value->IsObject()) { + return false; + } + + Local symbol; + Local obj = Nan::To(value).ToLocalChecked(); + + symbol = Nan::New("word0").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + symbol = Nan::New("word1").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + symbol = Nan::New("word2").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + symbol = Nan::New("word3").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + return true; + } + + ::Windows::Devices::Midi2::MidiMessageStruct MidiMessageStructFromJsObject(Local value) { + HandleScope scope; + ::Windows::Devices::Midi2::MidiMessageStruct returnValue; + + if (!value->IsObject()) { + Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object"))); + return returnValue; + } + + Local obj = Nan::To(value).ToLocalChecked(); + Local symbol; + + symbol = Nan::New("word0").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word0 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + symbol = Nan::New("word1").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word1 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + symbol = Nan::New("word2").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word2 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + symbol = Nan::New("word3").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word3 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + return returnValue; + } + + Local MidiMessageStructToJsObject(::Windows::Devices::Midi2::MidiMessageStruct value) { + EscapableHandleScope scope; + + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("word0").ToLocalChecked(), Nan::New(value.Word0)); + Nan::Set(obj, Nan::New("word1").ToLocalChecked(), Nan::New(value.Word1)); + Nan::Set(obj, Nan::New("word2").ToLocalChecked(), Nan::New(value.Word2)); + Nan::Set(obj, Nan::New("word3").ToLocalChecked(), Nan::New(value.Word3)); + + return scope.Escape(obj); + } + + + class IMidiEndpointConnectionSettings : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiEndpointConnectionSettings").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settingsJson").ToLocalChecked(), SettingsJsonGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiEndpointConnectionSettings").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiEndpointConnectionSettings *wrapperInstance = new IMidiEndpointConnectionSettings(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiEndpointConnectionSettings(winRtInstance)); + } + + + + + + static void SettingsJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info.This())) { + return; + } + + IMidiEndpointConnectionSettings *wrapper = IMidiEndpointConnectionSettings::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SettingsJson; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ UnwrapIMidiEndpointConnectionSettings(Local value); + }; + + Persistent IMidiEndpointConnectionSettings::s_constructorTemplate; + + v8::Local WrapIMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiEndpointConnectionSettings::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ UnwrapIMidiEndpointConnectionSettings(Local value) { + return IMidiEndpointConnectionSettings::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiEndpointConnectionSettings(Local exports) { + IMidiEndpointConnectionSettings::Init(exports); + } + + class IMidiEndpointConnectionSource : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiEndpointConnectionSource").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiEndpointConnectionSource").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiEndpointConnectionSource *wrapperInstance = new IMidiEndpointConnectionSource(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiEndpointConnectionSource(winRtInstance)); + } + + + + + + + + private: + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ UnwrapIMidiEndpointConnectionSource(Local value); + }; + + Persistent IMidiEndpointConnectionSource::s_constructorTemplate; + + v8::Local WrapIMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiEndpointConnectionSource::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ UnwrapIMidiEndpointConnectionSource(Local value) { + return IMidiEndpointConnectionSource::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiEndpointConnectionSource(Local exports) { + IMidiEndpointConnectionSource::Init(exports); + } + + class IMidiEndpointMessageProcessingPlugin : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiEndpointMessageProcessingPlugin").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiEndpointMessageProcessingPlugin").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiEndpointMessageProcessingPlugin *wrapperInstance = new IMidiEndpointMessageProcessingPlugin(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiEndpointMessageProcessingPlugin(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ UnwrapIMidiEndpointMessageProcessingPlugin(Local value); + }; + + Persistent IMidiEndpointMessageProcessingPlugin::s_constructorTemplate; + + v8::Local WrapIMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiEndpointMessageProcessingPlugin::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ UnwrapIMidiEndpointMessageProcessingPlugin(Local value) { + return IMidiEndpointMessageProcessingPlugin::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiEndpointMessageProcessingPlugin(Local exports) { + IMidiEndpointMessageProcessingPlugin::Init(exports); + } + + class IMidiMessageReceivedEventSource : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiMessageReceivedEventSource").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiMessageReceivedEventSource").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiMessageReceivedEventSource *wrapperInstance = new IMidiMessageReceivedEventSource(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiMessageReceivedEventSource(winRtInstance)); + } + + + + + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + IMidiMessageReceivedEventSource *wrapper = IMidiMessageReceivedEventSource::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + IMidiMessageReceivedEventSource *wrapper = IMidiMessageReceivedEventSource::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ UnwrapIMidiMessageReceivedEventSource(Local value); + }; + + Persistent IMidiMessageReceivedEventSource::s_constructorTemplate; + + v8::Local WrapIMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiMessageReceivedEventSource::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ UnwrapIMidiMessageReceivedEventSource(Local value) { + return IMidiMessageReceivedEventSource::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiMessageReceivedEventSource(Local exports) { + IMidiMessageReceivedEventSource::Init(exports); + } + + class IMidiServiceMessageProcessingPluginConfiguration : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiServiceMessageProcessingPluginConfiguration").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceId").ToLocalChecked(), EndpointDeviceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isFromConfigurationFile").ToLocalChecked(), IsFromConfigurationFileGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageProcessingPluginId").ToLocalChecked(), MessageProcessingPluginIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("pluginInstanceId").ToLocalChecked(), PluginInstanceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settingsJson").ToLocalChecked(), SettingsJsonGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiServiceMessageProcessingPluginConfiguration").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiServiceMessageProcessingPluginConfiguration *wrapperInstance = new IMidiServiceMessageProcessingPluginConfiguration(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiServiceMessageProcessingPluginConfiguration(winRtInstance)); + } + + + + + + static void EndpointDeviceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsFromConfigurationFileGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsFromConfigurationFile; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageProcessingPluginIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->MessageProcessingPluginId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PluginInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->PluginInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + ::Windows::Data::Json::JsonObject^ result = wrapper->_instance->SettingsJson; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Data.Json", "JsonObject", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ UnwrapIMidiServiceMessageProcessingPluginConfiguration(Local value); + }; + + Persistent IMidiServiceMessageProcessingPluginConfiguration::s_constructorTemplate; + + v8::Local WrapIMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiServiceMessageProcessingPluginConfiguration::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ UnwrapIMidiServiceMessageProcessingPluginConfiguration(Local value) { + return IMidiServiceMessageProcessingPluginConfiguration::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiServiceMessageProcessingPluginConfiguration(Local exports) { + IMidiServiceMessageProcessingPluginConfiguration::Init(exports); + } + + class IMidiServiceTransportPluginConfiguration : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiServiceTransportPluginConfiguration").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isFromConfigurationFile").ToLocalChecked(), IsFromConfigurationFileGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settingsJson").ToLocalChecked(), SettingsJsonGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportId").ToLocalChecked(), TransportIdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiServiceTransportPluginConfiguration").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiServiceTransportPluginConfiguration *wrapperInstance = new IMidiServiceTransportPluginConfiguration(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiServiceTransportPluginConfiguration(winRtInstance)); + } + + + + + + static void IsFromConfigurationFileGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceTransportPluginConfiguration *wrapper = IMidiServiceTransportPluginConfiguration::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsFromConfigurationFile; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceTransportPluginConfiguration *wrapper = IMidiServiceTransportPluginConfiguration::Unwrap(info.This()); + + try { + ::Windows::Data::Json::JsonObject^ result = wrapper->_instance->SettingsJson; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Data.Json", "JsonObject", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceTransportPluginConfiguration *wrapper = IMidiServiceTransportPluginConfiguration::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->TransportId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ UnwrapIMidiServiceTransportPluginConfiguration(Local value); + }; + + Persistent IMidiServiceTransportPluginConfiguration::s_constructorTemplate; + + v8::Local WrapIMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiServiceTransportPluginConfiguration::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ UnwrapIMidiServiceTransportPluginConfiguration(Local value) { + return IMidiServiceTransportPluginConfiguration::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiServiceTransportPluginConfiguration(Local exports) { + IMidiServiceTransportPluginConfiguration::Init(exports); + } + + class IMidiUniversalPacket : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiUniversalPacket").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiUniversalPacket").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiUniversalPacket^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiUniversalPacket *wrapperInstance = new IMidiUniversalPacket(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiUniversalPacket^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiUniversalPacket(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiUniversalPacket^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiUniversalPacket^ UnwrapIMidiUniversalPacket(Local value); + }; + + Persistent IMidiUniversalPacket::s_constructorTemplate; + + v8::Local WrapIMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiUniversalPacket::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ UnwrapIMidiUniversalPacket(Local value) { + return IMidiUniversalPacket::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiUniversalPacket(Local exports) { + IMidiUniversalPacket::Init(exports); + } + + class MidiChannel : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiChannel").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("index").ToLocalChecked(), IndexGetter, IndexSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("numberForDisplay").ToLocalChecked(), NumberForDisplayGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "isValidChannelIndex", IsValidChannelIndex); + Nan::SetAccessor(constructor, Nan::New("labelFull").ToLocalChecked(), LabelFullGetter); + Nan::SetAccessor(constructor, Nan::New("labelShort").ToLocalChecked(), LabelShortGetter); + + + Nan::Set(exports, Nan::New("MidiChannel").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiChannel(::Windows::Devices::Midi2::MidiChannel^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiChannel^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannel^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsInt32()) + { + try { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiChannel(arg0); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiChannel(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiChannel *wrapperInstance = new MidiChannel(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiChannel^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannel^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiChannel(winRtInstance)); + } + + + + + + static void IsValidChannelIndex(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiChannel::IsValidChannelIndex(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void IndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info.This())) { + return; + } + + MidiChannel *wrapper = MidiChannel::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Index; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IndexSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info.This())) { + return; + } + + MidiChannel *wrapper = MidiChannel::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Index = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NumberForDisplayGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info.This())) { + return; + } + + MidiChannel *wrapper = MidiChannel::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->NumberForDisplay; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void LabelFullGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiChannel::LabelFull; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void LabelShortGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiChannel::LabelShort; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiChannel^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiChannel(::Windows::Devices::Midi2::MidiChannel^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiChannel^ UnwrapMidiChannel(Local value); + }; + + Persistent MidiChannel::s_constructorTemplate; + + v8::Local WrapMidiChannel(::Windows::Devices::Midi2::MidiChannel^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiChannel::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiChannel^ UnwrapMidiChannel(Local value) { + return MidiChannel::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiChannel(Local exports) { + MidiChannel::Init(exports); + } + + class MidiChannelEndpointListener : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiChannelEndpointListener").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventFiringMainMessageReceivedEvent").ToLocalChecked(), PreventFiringMainMessageReceivedEventGetter, PreventFiringMainMessageReceivedEventSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventCallingFurtherListeners").ToLocalChecked(), PreventCallingFurtherListenersGetter, PreventCallingFurtherListenersSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeGroup").ToLocalChecked(), IncludeGroupGetter, IncludeGroupSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeChannels").ToLocalChecked(), IncludeChannelsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiChannelEndpointListener").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannelEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiChannelEndpointListener(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiChannelEndpointListener *wrapperInstance = new MidiChannelEndpointListener(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannelEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiChannelEndpointListener(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void PreventFiringMainMessageReceivedEventGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventFiringMainMessageReceivedEvent; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventFiringMainMessageReceivedEvent = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreventCallingFurtherListenersGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventCallingFurtherListeners; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventCallingFurtherListenersSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventCallingFurtherListeners = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeGroupGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiGroup^ result = wrapper->_instance->IncludeGroup; + info.GetReturnValue().Set(WrapMidiGroup(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IncludeGroupSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiGroup^ winRtValue = dynamic_cast<::Windows::Devices::Midi2::MidiGroup^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->IncludeGroup = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeChannelsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiChannel^>^ result = wrapper->_instance->IncludeChannels; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiChannel^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiChannel^ val) -> Local { + return WrapMidiChannel(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiChannel^ { + return UnwrapMidiChannel(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiChannelEndpointListener^ UnwrapMidiChannelEndpointListener(Local value); + }; + + Persistent MidiChannelEndpointListener::s_constructorTemplate; + + v8::Local WrapMidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiChannelEndpointListener::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ UnwrapMidiChannelEndpointListener(Local value) { + return MidiChannelEndpointListener::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiChannelEndpointListener(Local exports) { + MidiChannelEndpointListener::Init(exports); + } + + class MidiClock : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiClock").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "convertTimestampToMicroseconds", ConvertTimestampToMicroseconds); + Nan::SetMethod(constructor, "convertTimestampToMilliseconds", ConvertTimestampToMilliseconds); + Nan::SetMethod(constructor, "convertTimestampToSeconds", ConvertTimestampToSeconds); + Nan::SetMethod(constructor, "offsetTimestampByTicks", OffsetTimestampByTicks); + Nan::SetMethod(constructor, "offsetTimestampByMicroseconds", OffsetTimestampByMicroseconds); + Nan::SetMethod(constructor, "offsetTimestampByMilliseconds", OffsetTimestampByMilliseconds); + Nan::SetMethod(constructor, "offsetTimestampBySeconds", OffsetTimestampBySeconds); + Nan::SetAccessor(constructor, Nan::New("now").ToLocalChecked(), NowGetter); + Nan::SetAccessor(constructor, Nan::New("timestampConstantSendImmediately").ToLocalChecked(), TimestampConstantSendImmediatelyGetter); + Nan::SetAccessor(constructor, Nan::New("timestampFrequency").ToLocalChecked(), TimestampFrequencyGetter); + + + Nan::Set(exports, Nan::New("MidiClock").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiClock(::Windows::Devices::Midi2::MidiClock^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiClock^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiClock^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiClock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiClock *wrapperInstance = new MidiClock(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiClock^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiClock^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiClock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiClock(winRtInstance)); + } + + + + + + static void ConvertTimestampToMicroseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + double result; + result = ::Windows::Devices::Midi2::MidiClock::ConvertTimestampToMicroseconds(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertTimestampToMilliseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + double result; + result = ::Windows::Devices::Midi2::MidiClock::ConvertTimestampToMilliseconds(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertTimestampToSeconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + double result; + result = ::Windows::Devices::Midi2::MidiClock::ConvertTimestampToSeconds(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampByTicks(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampByTicks(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampByMicroseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampByMicroseconds(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampByMilliseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampByMilliseconds(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampBySeconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampBySeconds(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void NowGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + unsigned __int64 result = ::Windows::Devices::Midi2::MidiClock::Now; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void TimestampConstantSendImmediatelyGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + unsigned __int64 result = ::Windows::Devices::Midi2::MidiClock::TimestampConstantSendImmediately; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void TimestampFrequencyGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + unsigned __int64 result = ::Windows::Devices::Midi2::MidiClock::TimestampFrequency; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiClock^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiClock(::Windows::Devices::Midi2::MidiClock^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiClock^ UnwrapMidiClock(Local value); + }; + + Persistent MidiClock::s_constructorTemplate; + + v8::Local WrapMidiClock(::Windows::Devices::Midi2::MidiClock^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiClock::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiClock^ UnwrapMidiClock(Local value) { + return MidiClock::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiClock(Local exports) { + MidiClock::Init(exports); + } + + class MidiEndpointConnection : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointConnection").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "open", Open); + Nan::SetPrototypeMethod(localRef, "addMessageProcessingPlugin", AddMessageProcessingPlugin); + Nan::SetPrototypeMethod(localRef, "removeMessageProcessingPlugin", RemoveMessageProcessingPlugin); + Nan::SetPrototypeMethod(localRef, "sendSingleMessagePacket", SendSingleMessagePacket); + //Nan::SetPrototypeMethod(localRef, "sendSingleMessageStruct", SendSingleMessageStruct); + Nan::SetPrototypeMethod(localRef, "sendSingleMessageWordArray", SendSingleMessageWordArray); + Nan::SetPrototypeMethod(localRef, "sendSingleMessageWords", SendSingleMessageWords); + Nan::SetPrototypeMethod(localRef, "sendSingleMessageBuffer", SendSingleMessageBuffer); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesWordList", SendMultipleMessagesWordList); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesWordArray", SendMultipleMessagesWordArray); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesPacketList", SendMultipleMessagesPacketList); + //Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesStructList", SendMultipleMessagesStructList); + //Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesStructArray", SendMultipleMessagesStructArray); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesBuffer", SendMultipleMessagesBuffer); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("connectionId").ToLocalChecked(), ConnectionIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceId").ToLocalChecked(), EndpointDeviceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isOpen").ToLocalChecked(), IsOpenGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageProcessingPlugins").ToLocalChecked(), MessageProcessingPluginsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settings").ToLocalChecked(), SettingsGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "getDeviceSelector", GetDeviceSelector); + Nan::SetMethod(constructor, "sendMessageSucceeded", SendMessageSucceeded); + Nan::SetMethod(constructor, "sendMessageFailed", SendMessageFailed); + + + Nan::Set(exports, Nan::New("MidiEndpointConnection").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointConnection^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointConnection^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointConnection *wrapperInstance = new MidiEndpointConnection(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointConnection^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointConnection^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointConnection(winRtInstance)); + } + + + static void Open(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + bool result; + result = wrapper->_instance->Open(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AddMessageProcessingPlugin(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ arg0 = UnwrapIMidiEndpointMessageProcessingPlugin(info[0]); + + wrapper->_instance->AddMessageProcessingPlugin(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void RemoveMessageProcessingPlugin(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsGuid(info[0])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + + wrapper->_instance->RemoveMessageProcessingPlugin(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendSingleMessagePacket(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiUniversalPacket^ arg0 = UnwrapIMidiUniversalPacket(info[0]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessagePacket(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + // static void SendSingleMessageStruct(Nan::NAN_METHOD_ARGS_TYPE info) { + // HandleScope scope; + + // if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + // return; + // } + + // MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + // if (info.Length() == 3 + // && info[0]->IsNumber() + // && info[1]->IsInt32() + // && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageStruct&^>(info[2])) + // { + // try + // { + // unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + // unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + // ::Windows::Devices::Midi2::MidiMessageStruct arg2 = MidiMessageStructFromJsObject(info[2]); + // + // ::Windows::Devices::Midi2::MidiSendMessageResults result; + // result = wrapper->_instance->SendSingleMessageStruct(arg0, arg1, arg2); + // info.GetReturnValue().Set(Nan::New(static_cast(result))); + // return; + // } catch (Platform::Exception ^exception) { + // NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + // return; + // } + // } + //else { + // Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + // return; + // } + // } + static void SendSingleMessageWordArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsInt32() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[3]) || info[3]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Platform::Array^ arg3 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[3]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWordArray(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendSingleMessageWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1, arg2); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 5 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32() + && info[4]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned int arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1, arg2, arg3, arg4); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendSingleMessageBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[3])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg3 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[3])); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageBuffer(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendMultipleMessagesWordList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable^>(info[1]) || info[1]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::Collections::IIterable^ arg1 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesWordList(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendMultipleMessagesWordArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[3]) || info[3]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Platform::Array^ arg3 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[3]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesWordArray(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendMultipleMessagesPacketList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesPacketList(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + // static void SendMultipleMessagesStructList(Nan::NAN_METHOD_ARGS_TYPE info) { + // HandleScope scope; + + // if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + // return; + // } + + // MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + // if (info.Length() == 2 + // && info[0]->IsNumber() + // && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^>(info[1]) || info[1]->IsArray())) + // { + // try + // { + // unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + // ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^ arg1 = + // [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^ + // { + // if (value->IsArray()) + // { + // return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::MidiMessageStruct>(value.As(), + // [](Local value) -> bool { + // return IsMidiMessageStructJsObject(value); + // }, + // [](Local value) -> ::Windows::Devices::Midi2::MidiMessageStruct { + // return MidiMessageStructFromJsObject(value); + // } + // ); + // } + // else + // { + // return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^>(NodeRT::Utils::GetObjectInstance(value)); + // } + // } (info[1]); + // + // ::Windows::Devices::Midi2::MidiSendMessageResults result; + // result = wrapper->_instance->SendMultipleMessagesStructList(arg0, arg1); + // info.GetReturnValue().Set(Nan::New(static_cast(result))); + // return; + // } catch (Platform::Exception ^exception) { + // NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + // return; + // } + // } + //else { + // Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + // return; + // } + // } + // static void SendMultipleMessagesStructArray(Nan::NAN_METHOD_ARGS_TYPE info) { + // HandleScope scope; + + // if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + // return; + // } + + // MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + // if (info.Length() == 4 + // && info[0]->IsNumber() + // && info[1]->IsUint32() + // && info[2]->IsUint32() + // && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^>(info[3]) || info[3]->IsArray())) + // { + // try + // { + // unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + // unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + // unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + // ::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^ arg3 = + // [] (v8::Local value) -> ::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^ + // { + // if (value->IsArray()) + // { + // return NodeRT::Collections::JsArrayToWinrtArray<::Windows::Devices::Midi2::MidiMessageStruct>(value.As(), + // [](Local value) -> bool { + // return IsMidiMessageStructJsObject(value); + // }, + // [](Local value) -> ::Windows::Devices::Midi2::MidiMessageStruct { + // return MidiMessageStructFromJsObject(value); + // } + // ); + // } + // else + // { + // return dynamic_cast<::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^>(NodeRT::Utils::GetObjectInstance(value)); + // } + // } (info[3]); + // + // ::Windows::Devices::Midi2::MidiSendMessageResults result; + // result = wrapper->_instance->SendMultipleMessagesStructArray(arg0, arg1, arg2, arg3); + // info.GetReturnValue().Set(Nan::New(static_cast(result))); + // return; + // } catch (Platform::Exception ^exception) { + // NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + // return; + // } + // } + //else { + // Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + // return; + // } + // } + static void SendMultipleMessagesBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[3])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg3 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[3])); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesBuffer(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void GetDeviceSelector(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiEndpointConnection::GetDeviceSelector(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void SendMessageSucceeded(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiSendMessageResults arg0 = static_cast<::Windows::Devices::Midi2::MidiSendMessageResults>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiEndpointConnection::SendMessageSucceeded(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void SendMessageFailed(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiSendMessageResults arg0 = static_cast<::Windows::Devices::Midi2::MidiSendMessageResults>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiEndpointConnection::SendMessageFailed(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void ConnectionIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->ConnectionId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsOpenGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsOpen; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageProcessingPluginsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>^ result = wrapper->_instance->MessageProcessingPlugins; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ val) -> Local { + return WrapIMidiEndpointMessageProcessingPlugin(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ { + return UnwrapIMidiEndpointMessageProcessingPlugin(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ result = wrapper->_instance->Settings; + info.GetReturnValue().Set(WrapIMidiEndpointConnectionSettings(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiEndpointConnection^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointConnection^ UnwrapMidiEndpointConnection(Local value); + }; + + Persistent MidiEndpointConnection::s_constructorTemplate; + + v8::Local WrapMidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointConnection::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointConnection^ UnwrapMidiEndpointConnection(Local value) { + return MidiEndpointConnection::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointConnection(Local exports) { + MidiEndpointConnection::Init(exports); + } + + class MidiEndpointDeviceInformation : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformation").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "updateFromDeviceInformation", UpdateFromDeviceInformation); + Nan::SetPrototypeMethod(localRef, "updateFromDeviceInformationUpdate", UpdateFromDeviceInformationUpdate); + Nan::SetPrototypeMethod(localRef, "getParentDeviceInformation", GetParentDeviceInformation); + Nan::SetPrototypeMethod(localRef, "getContainerInformation", GetContainerInformation); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("configuredProtocol").ToLocalChecked(), ConfiguredProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("configuredToReceiveJRTimestamps").ToLocalChecked(), ConfiguredToReceiveJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("configuredToSendJRTimestamps").ToLocalChecked(), ConfiguredToSendJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("containerId").ToLocalChecked(), ContainerIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyLsb").ToLocalChecked(), DeviceIdentityDeviceFamilyLsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyModelNumberLsb").ToLocalChecked(), DeviceIdentityDeviceFamilyModelNumberLsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyModelNumberMsb").ToLocalChecked(), DeviceIdentityDeviceFamilyModelNumberMsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyMsb").ToLocalChecked(), DeviceIdentityDeviceFamilyMsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityLastUpdateTime").ToLocalChecked(), DeviceIdentityLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentitySoftwareRevisionLevel").ToLocalChecked(), DeviceIdentitySoftwareRevisionLevelGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentitySystemExclusiveId").ToLocalChecked(), DeviceIdentitySystemExclusiveIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceInstanceId").ToLocalChecked(), DeviceInstanceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointConfigurationLastUpdateTime").ToLocalChecked(), EndpointConfigurationLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointInformationLastUpdateTime").ToLocalChecked(), EndpointInformationLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointPurpose").ToLocalChecked(), EndpointPurposeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointSuppliedName").ToLocalChecked(), EndpointSuppliedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointSuppliedNameLastUpdateTime").ToLocalChecked(), EndpointSuppliedNameLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlockCount").ToLocalChecked(), FunctionBlockCountGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocks").ToLocalChecked(), FunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocksLastUpdateTime").ToLocalChecked(), FunctionBlocksLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("groupTerminalBlocks").ToLocalChecked(), GroupTerminalBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("hasStaticFunctionBlocks").ToLocalChecked(), HasStaticFunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("manufacturerName").ToLocalChecked(), ManufacturerNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("nativeDataFormat").ToLocalChecked(), NativeDataFormatGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("productInstanceId").ToLocalChecked(), ProductInstanceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("productInstanceIdLastUpdateTime").ToLocalChecked(), ProductInstanceIdLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("properties").ToLocalChecked(), PropertiesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("recommendedCCAutomationIntervalMS").ToLocalChecked(), RecommendedCCAutomationIntervalMSGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requiresNoteOffTranslation").ToLocalChecked(), RequiresNoteOffTranslationGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMajor").ToLocalChecked(), SpecificationVersionMajorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMinor").ToLocalChecked(), SpecificationVersionMinorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi10Protocol").ToLocalChecked(), SupportsMidi10ProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi20Protocol").ToLocalChecked(), SupportsMidi20ProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMultiClient").ToLocalChecked(), SupportsMultiClientGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsReceivingJRTimestamps").ToLocalChecked(), SupportsReceivingJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsSendingJRTimestamps").ToLocalChecked(), SupportsSendingJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportId").ToLocalChecked(), TransportIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportMnemonic").ToLocalChecked(), TransportMnemonicGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedDescription").ToLocalChecked(), TransportSuppliedDescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedName").ToLocalChecked(), TransportSuppliedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedProductId").ToLocalChecked(), TransportSuppliedProductIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedSerialNumber").ToLocalChecked(), TransportSuppliedSerialNumberGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedVendorId").ToLocalChecked(), TransportSuppliedVendorIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedDescription").ToLocalChecked(), UserSuppliedDescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedLargeImagePath").ToLocalChecked(), UserSuppliedLargeImagePathGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedName").ToLocalChecked(), UserSuppliedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedSmallImagePath").ToLocalChecked(), UserSuppliedSmallImagePathGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createFromId", CreateFromId); + Nan::SetMethod(constructor, "findAll", FindAll); + Nan::SetMethod(constructor, "getAdditionalPropertiesList", GetAdditionalPropertiesList); + Nan::SetMethod(constructor, "deviceMatchesFilter", DeviceMatchesFilter); + Nan::SetAccessor(constructor, Nan::New("diagnosticsLoopbackAEndpointId").ToLocalChecked(), DiagnosticsLoopbackAEndpointIdGetter); + Nan::SetAccessor(constructor, Nan::New("diagnosticsLoopbackBEndpointId").ToLocalChecked(), DiagnosticsLoopbackBEndpointIdGetter); + Nan::SetAccessor(constructor, Nan::New("endpointInterfaceClass").ToLocalChecked(), EndpointInterfaceClassGetter); + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformation").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformation^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformation *wrapperInstance = new MidiEndpointDeviceInformation(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformation^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformation(winRtInstance)); + } + + + static void UpdateFromDeviceInformation(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Enumeration::DeviceInformation^>(info[0])) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformation^ arg0 = dynamic_cast<::Windows::Devices::Enumeration::DeviceInformation^>(NodeRT::Utils::GetObjectInstance(info[0])); + + bool result; + result = wrapper->_instance->UpdateFromDeviceInformation(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void UpdateFromDeviceInformationUpdate(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Enumeration::DeviceInformationUpdate^>(info[0])) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformationUpdate^ arg0 = dynamic_cast<::Windows::Devices::Enumeration::DeviceInformationUpdate^>(NodeRT::Utils::GetObjectInstance(info[0])); + + bool result; + result = wrapper->_instance->UpdateFromDeviceInformationUpdate(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetParentDeviceInformation(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformation^ result; + result = wrapper->_instance->GetParentDeviceInformation(); + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformation", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetContainerInformation(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformation^ result; + result = wrapper->_instance->GetContainerInformation(); + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformation", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CreateFromId(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::CreateFromId(arg0); + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformation(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void FindAll(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::FindAll(); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ { + return UnwrapMidiEndpointDeviceInformation(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder arg0 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder>(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::FindAll(arg0); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ { + return UnwrapMidiEndpointDeviceInformation(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsInt32() + && info[1]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder arg0 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder>(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters arg1 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters>(Nan::To(info[1]).FromMaybe(0)); + + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::FindAll(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ { + return UnwrapMidiEndpointDeviceInformation(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetAdditionalPropertiesList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::GetAdditionalPropertiesList(); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Platform::String^>::CreateVectorViewWrapper(result, + [](::Platform::String^ val) -> Local { + return NodeRT::Utils::NewString(val->Data()); + }, + [](Local value) -> bool { + return value->IsString(); + }, + [](Local value) -> ::Platform::String^ { + return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void DeviceMatchesFilter(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info[0]) + && info[1]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ arg0 = UnwrapMidiEndpointDeviceInformation(info[0]); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters arg1 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters>(Nan::To(info[1]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::DeviceMatchesFilter(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConfiguredProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiProtocol result = wrapper->_instance->ConfiguredProtocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ConfiguredToReceiveJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->ConfiguredToReceiveJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ConfiguredToSendJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->ConfiguredToSendJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ContainerIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->ContainerId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyModelNumberLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyModelNumberLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyModelNumberMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyModelNumberMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->DeviceIdentityLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentitySoftwareRevisionLevelGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Array^ result = wrapper->_instance->DeviceIdentitySoftwareRevisionLevel; + info.GetReturnValue().Set(NodeRT::Collections::ArrayWrapper::CreateArrayWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentitySystemExclusiveIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Array^ result = wrapper->_instance->DeviceIdentitySystemExclusiveId; + info.GetReturnValue().Set(NodeRT::Collections::ArrayWrapper::CreateArrayWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->DeviceInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointConfigurationLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EndpointConfigurationLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointInformationLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EndpointInformationLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointPurposeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiEndpointDevicePurpose result = wrapper->_instance->EndpointPurpose; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointSuppliedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointSuppliedName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointSuppliedNameLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EndpointSuppliedNameLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlockCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->FunctionBlockCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView^ result = wrapper->_instance->FunctionBlocks; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper::CreateMapViewWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + }, + [](::Windows::Devices::Midi2::MidiFunctionBlock^ val) -> Local { + return WrapMidiFunctionBlock(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->FunctionBlocksLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void GroupTerminalBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>^ result = wrapper->_instance->GroupTerminalBlocks; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiGroupTerminalBlock^ val) -> Local { + return WrapMidiGroupTerminalBlock(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ { + return UnwrapMidiGroupTerminalBlock(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void HasStaticFunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->HasStaticFunctionBlocks; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ManufacturerNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ManufacturerName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NativeDataFormatGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiEndpointNativeDataFormat result = wrapper->_instance->NativeDataFormat; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProductInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ProductInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProductInstanceIdLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->ProductInstanceIdLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PropertiesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView<::Platform::String^, ::Platform::Object^>^ result = wrapper->_instance->Properties; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper<::Platform::String^,::Platform::Object^>::CreateMapViewWrapper(result, + [](::Platform::String^ val) -> Local { + return NodeRT::Utils::NewString(val->Data()); + }, + [](Local value) -> bool { + return value->IsString(); + }, + [](Local value) -> ::Platform::String^ { + return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + }, + [](::Platform::Object^ val) -> Local { + return CreateOpaqueWrapper(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RecommendedCCAutomationIntervalMSGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->RecommendedCCAutomationIntervalMS; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequiresNoteOffTranslationGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequiresNoteOffTranslation; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMajorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMajor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMinorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMinor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi10ProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi10Protocol; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi20ProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi20Protocol; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMultiClientGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMultiClient; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsReceivingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsReceivingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsSendingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsSendingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->TransportId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportMnemonicGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportMnemonic; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedDescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedDescription; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedProductIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->TransportSuppliedProductId; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedSerialNumberGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedSerialNumber; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedVendorIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->TransportSuppliedVendorId; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedDescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedDescription; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedLargeImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedLargeImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedSmallImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedSmallImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void DiagnosticsLoopbackAEndpointIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::DiagnosticsLoopbackAEndpointId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void DiagnosticsLoopbackBEndpointIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::DiagnosticsLoopbackBEndpointId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void EndpointInterfaceClassGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::EndpointInterfaceClass; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ UnwrapMidiEndpointDeviceInformation(Local value); + }; + + Persistent MidiEndpointDeviceInformation::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformation::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ UnwrapMidiEndpointDeviceInformation(Local value) { + return MidiEndpointDeviceInformation::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformation(Local exports) { + MidiEndpointDeviceInformation::Init(exports); + } + + class MidiEndpointDeviceInformationAddedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformationAddedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("addedDevice").ToLocalChecked(), AddedDeviceGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationAddedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformationAddedEventArgs *wrapperInstance = new MidiEndpointDeviceInformationAddedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformationAddedEventArgs(winRtInstance)); + } + + + + + + static void AddedDeviceGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationAddedEventArgs *wrapper = MidiEndpointDeviceInformationAddedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ result = wrapper->_instance->AddedDevice; + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformation(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ UnwrapMidiEndpointDeviceInformationAddedEventArgs(Local value); + }; + + Persistent MidiEndpointDeviceInformationAddedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformationAddedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ UnwrapMidiEndpointDeviceInformationAddedEventArgs(Local value) { + return MidiEndpointDeviceInformationAddedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformationAddedEventArgs(Local exports) { + MidiEndpointDeviceInformationAddedEventArgs::Init(exports); + } + + class MidiEndpointDeviceInformationRemovedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformationRemovedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceInformationUpdate").ToLocalChecked(), DeviceInformationUpdateGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationRemovedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformationRemovedEventArgs *wrapperInstance = new MidiEndpointDeviceInformationRemovedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformationRemovedEventArgs(winRtInstance)); + } + + + + + + static void DeviceInformationUpdateGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationRemovedEventArgs *wrapper = MidiEndpointDeviceInformationRemovedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Enumeration::DeviceInformationUpdate^ result = wrapper->_instance->DeviceInformationUpdate; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformationUpdate", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationRemovedEventArgs *wrapper = MidiEndpointDeviceInformationRemovedEventArgs::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ UnwrapMidiEndpointDeviceInformationRemovedEventArgs(Local value); + }; + + Persistent MidiEndpointDeviceInformationRemovedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformationRemovedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ UnwrapMidiEndpointDeviceInformationRemovedEventArgs(Local value) { + return MidiEndpointDeviceInformationRemovedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformationRemovedEventArgs(Local exports) { + MidiEndpointDeviceInformationRemovedEventArgs::Init(exports); + } + + class MidiEndpointDeviceInformationUpdatedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformationUpdatedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceInformationUpdate").ToLocalChecked(), DeviceInformationUpdateGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedAdditionalCapabilities").ToLocalChecked(), UpdatedAdditionalCapabilitiesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedDeviceIdentity").ToLocalChecked(), UpdatedDeviceIdentityGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedEndpointInformation").ToLocalChecked(), UpdatedEndpointInformationGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedFunctionBlocks").ToLocalChecked(), UpdatedFunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedName").ToLocalChecked(), UpdatedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedStreamConfiguration").ToLocalChecked(), UpdatedStreamConfigurationGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedUserMetadata").ToLocalChecked(), UpdatedUserMetadataGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationUpdatedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapperInstance = new MidiEndpointDeviceInformationUpdatedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformationUpdatedEventArgs(winRtInstance)); + } + + + + + + static void DeviceInformationUpdateGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Enumeration::DeviceInformationUpdate^ result = wrapper->_instance->DeviceInformationUpdate; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformationUpdate", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedAdditionalCapabilitiesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedAdditionalCapabilities; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedDeviceIdentityGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedDeviceIdentity; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedEndpointInformationGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedEndpointInformation; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedFunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedFunctionBlocks; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedName; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedStreamConfigurationGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedStreamConfiguration; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedUserMetadataGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedUserMetadata; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ UnwrapMidiEndpointDeviceInformationUpdatedEventArgs(Local value); + }; + + Persistent MidiEndpointDeviceInformationUpdatedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformationUpdatedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ UnwrapMidiEndpointDeviceInformationUpdatedEventArgs(Local value) { + return MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformationUpdatedEventArgs(Local exports) { + MidiEndpointDeviceInformationUpdatedEventArgs::Init(exports); + } + + class MidiEndpointDeviceWatcher : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceWatcher").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "start", Start); + Nan::SetPrototypeMethod(localRef, "stop", Stop); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("enumeratedEndpointDevices").ToLocalChecked(), EnumeratedEndpointDevicesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("status").ToLocalChecked(), StatusGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createWatcher", CreateWatcher); + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceWatcher").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceWatcher *wrapperInstance = new MidiEndpointDeviceWatcher(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceWatcher(winRtInstance)); + } + + + static void Start(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Start(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Stop(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Stop(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CreateWatcher(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters arg0 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters>(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher::CreateWatcher(arg0); + info.GetReturnValue().Set(WrapMidiEndpointDeviceWatcher(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void EnumeratedEndpointDevicesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView<::Platform::String^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result = wrapper->_instance->EnumeratedEndpointDevices; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper<::Platform::String^,::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateMapViewWrapper(result, + [](::Platform::String^ val) -> Local { + return NodeRT::Utils::NewString(val->Data()); + }, + [](Local value) -> bool { + return value->IsString(); + }, + [](Local value) -> ::Platform::String^ { + return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + }, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void StatusGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + ::Windows::Devices::Enumeration::DeviceWatcherStatus result = wrapper->_instance->Status; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"added", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Added::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = WrapMidiEndpointDeviceInformationAddedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"enumerationCompleted", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->EnumerationCompleted::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Platform::Object^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Platform::Object^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = CreateOpaqueWrapper(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"removed", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Removed::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = WrapMidiEndpointDeviceInformationRemovedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"stopped", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Stopped::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Platform::Object^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Platform::Object^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = CreateOpaqueWrapper(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"updated", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Updated::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = WrapMidiEndpointDeviceInformationUpdatedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"added", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"enumerationCompleted", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"removed", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"stopped", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"updated", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"added", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Added::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"enumerationCompleted", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->EnumerationCompleted::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"removed", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Removed::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"stopped", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Stopped::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"updated", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Updated::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ UnwrapMidiEndpointDeviceWatcher(Local value); + }; + + Persistent MidiEndpointDeviceWatcher::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceWatcher::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ UnwrapMidiEndpointDeviceWatcher(Local value) { + return MidiEndpointDeviceWatcher::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceWatcher(Local exports) { + MidiEndpointDeviceWatcher::Init(exports); + } + + class MidiFunctionBlock : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiFunctionBlock").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "includesGroup", IncludesGroup); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("uIHint").ToLocalChecked(), UIHintGetter, UIHintSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("number").ToLocalChecked(), NumberGetter, NumberSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("midiCIMessageVersionFormat").ToLocalChecked(), MidiCIMessageVersionFormatGetter, MidiCIMessageVersionFormatSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("midi10Connection").ToLocalChecked(), Midi10ConnectionGetter, Midi10ConnectionSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("maxSystemExclusive8Streams").ToLocalChecked(), MaxSystemExclusive8StreamsGetter, MaxSystemExclusive8StreamsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isActive").ToLocalChecked(), IsActiveGetter, IsActiveSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("groupCount").ToLocalChecked(), GroupCountGetter, GroupCountSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("firstGroupIndex").ToLocalChecked(), FirstGroupIndexGetter, FirstGroupIndexSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("direction").ToLocalChecked(), DirectionGetter, DirectionSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isReadOnly").ToLocalChecked(), IsReadOnlyGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiFunctionBlock").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiFunctionBlock^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiFunctionBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiFunctionBlock(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiFunctionBlock *wrapperInstance = new MidiFunctionBlock(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiFunctionBlock^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiFunctionBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiFunctionBlock(winRtInstance)); + } + + + static void IncludesGroup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiGroup^ arg0 = UnwrapMidiGroup(info[0]); + + bool result; + result = wrapper->_instance->IncludesGroup(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void UIHintGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiFunctionBlockUIHint result = wrapper->_instance->UIHint; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UIHintSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiFunctionBlockUIHint winRtValue = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockUIHint>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->UIHint = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NumberGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Number; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NumberSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Number = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MidiCIMessageVersionFormatGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->MidiCIMessageVersionFormat; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MidiCIMessageVersionFormatSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MidiCIMessageVersionFormat = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Midi10ConnectionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiFunctionBlockMidi10 result = wrapper->_instance->Midi10Connection; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Midi10ConnectionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiFunctionBlockMidi10 winRtValue = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockMidi10>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Midi10Connection = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MaxSystemExclusive8StreamsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->MaxSystemExclusive8Streams; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MaxSystemExclusive8StreamsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MaxSystemExclusive8Streams = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsActiveGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsActive; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsActiveSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsActive = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void GroupCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->GroupCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void GroupCountSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->GroupCount = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void FirstGroupIndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->FirstGroupIndex; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FirstGroupIndexSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->FirstGroupIndex = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DirectionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiFunctionBlockDirection result = wrapper->_instance->Direction; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DirectionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiFunctionBlockDirection winRtValue = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockDirection>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Direction = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsReadOnlyGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsReadOnly; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiFunctionBlock^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiFunctionBlock^ UnwrapMidiFunctionBlock(Local value); + }; + + Persistent MidiFunctionBlock::s_constructorTemplate; + + v8::Local WrapMidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiFunctionBlock::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiFunctionBlock^ UnwrapMidiFunctionBlock(Local value) { + return MidiFunctionBlock::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiFunctionBlock(Local exports) { + MidiFunctionBlock::Init(exports); + } + + class MidiGroup : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiGroup").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("index").ToLocalChecked(), IndexGetter, IndexSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("numberForDisplay").ToLocalChecked(), NumberForDisplayGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "isValidGroupIndex", IsValidGroupIndex); + Nan::SetAccessor(constructor, Nan::New("labelFull").ToLocalChecked(), LabelFullGetter); + Nan::SetAccessor(constructor, Nan::New("labelShort").ToLocalChecked(), LabelShortGetter); + + + Nan::Set(exports, Nan::New("MidiGroup").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiGroup(::Windows::Devices::Midi2::MidiGroup^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiGroup^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroup^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsInt32()) + { + try { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiGroup(arg0); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiGroup(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiGroup *wrapperInstance = new MidiGroup(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiGroup^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroup^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiGroup(winRtInstance)); + } + + + + + + static void IsValidGroupIndex(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiGroup::IsValidGroupIndex(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void IndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info.This())) { + return; + } + + MidiGroup *wrapper = MidiGroup::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Index; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IndexSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info.This())) { + return; + } + + MidiGroup *wrapper = MidiGroup::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Index = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NumberForDisplayGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info.This())) { + return; + } + + MidiGroup *wrapper = MidiGroup::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->NumberForDisplay; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void LabelFullGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiGroup::LabelFull; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void LabelShortGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiGroup::LabelShort; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiGroup^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiGroup(::Windows::Devices::Midi2::MidiGroup^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiGroup^ UnwrapMidiGroup(Local value); + }; + + Persistent MidiGroup::s_constructorTemplate; + + v8::Local WrapMidiGroup(::Windows::Devices::Midi2::MidiGroup^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiGroup::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiGroup^ UnwrapMidiGroup(Local value) { + return MidiGroup::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiGroup(Local exports) { + MidiGroup::Init(exports); + } + + class MidiGroupEndpointListener : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiGroupEndpointListener").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventFiringMainMessageReceivedEvent").ToLocalChecked(), PreventFiringMainMessageReceivedEventGetter, PreventFiringMainMessageReceivedEventSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventCallingFurtherListeners").ToLocalChecked(), PreventCallingFurtherListenersGetter, PreventCallingFurtherListenersSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeGroups").ToLocalChecked(), IncludeGroupsGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiGroupEndpointListener").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiGroupEndpointListener(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiGroupEndpointListener *wrapperInstance = new MidiGroupEndpointListener(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiGroupEndpointListener(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventFiringMainMessageReceivedEvent; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventFiringMainMessageReceivedEvent = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreventCallingFurtherListenersGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventCallingFurtherListeners; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventCallingFurtherListenersSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventCallingFurtherListeners = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeGroupsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiGroup^>^ result = wrapper->_instance->IncludeGroups; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiGroup^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiGroup^ val) -> Local { + return WrapMidiGroup(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiGroup^ { + return UnwrapMidiGroup(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiGroupEndpointListener^ UnwrapMidiGroupEndpointListener(Local value); + }; + + Persistent MidiGroupEndpointListener::s_constructorTemplate; + + v8::Local WrapMidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiGroupEndpointListener::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ UnwrapMidiGroupEndpointListener(Local value) { + return MidiGroupEndpointListener::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiGroupEndpointListener(Local exports) { + MidiGroupEndpointListener::Init(exports); + } + + class MidiGroupTerminalBlock : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiGroupTerminalBlock").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "includesGroup", IncludesGroup); + Nan::SetPrototypeMethod(localRef, "asEquivalentFunctionBlock", AsEquivalentFunctionBlock); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("calculatedMaxDeviceInputBandwidthBitsPerSecond").ToLocalChecked(), CalculatedMaxDeviceInputBandwidthBitsPerSecondGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("calculatedMaxDeviceOutputBandwidthBitsPerSecond").ToLocalChecked(), CalculatedMaxDeviceOutputBandwidthBitsPerSecondGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("direction").ToLocalChecked(), DirectionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("firstGroupIndex").ToLocalChecked(), FirstGroupIndexGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("groupCount").ToLocalChecked(), GroupCountGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("maxDeviceInputBandwidthIn4KBitsPerSecondUnits").ToLocalChecked(), MaxDeviceInputBandwidthIn4KBitsPerSecondUnitsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("maxDeviceOutputBandwidthIn4KBitsPerSecondUnits").ToLocalChecked(), MaxDeviceOutputBandwidthIn4KBitsPerSecondUnitsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("number").ToLocalChecked(), NumberGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("protocol").ToLocalChecked(), ProtocolGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiGroupTerminalBlock").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupTerminalBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiGroupTerminalBlock *wrapperInstance = new MidiGroupTerminalBlock(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupTerminalBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiGroupTerminalBlock(winRtInstance)); + } + + + static void IncludesGroup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiGroup^ arg0 = UnwrapMidiGroup(info[0]); + + bool result; + result = wrapper->_instance->IncludesGroup(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AsEquivalentFunctionBlock(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiFunctionBlock^ result; + result = wrapper->_instance->AsEquivalentFunctionBlock(); + info.GetReturnValue().Set(WrapMidiFunctionBlock(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CalculatedMaxDeviceInputBandwidthBitsPerSecondGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->CalculatedMaxDeviceInputBandwidthBitsPerSecond; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void CalculatedMaxDeviceOutputBandwidthBitsPerSecondGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->CalculatedMaxDeviceOutputBandwidthBitsPerSecond; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DirectionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection result = wrapper->_instance->Direction; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FirstGroupIndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->FirstGroupIndex; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void GroupCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->GroupCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MaxDeviceInputBandwidthIn4KBitsPerSecondUnitsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->MaxDeviceInputBandwidthIn4KBitsPerSecondUnits; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MaxDeviceOutputBandwidthIn4KBitsPerSecondUnitsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->MaxDeviceOutputBandwidthIn4KBitsPerSecondUnits; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NumberGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Number; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol result = wrapper->_instance->Protocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ UnwrapMidiGroupTerminalBlock(Local value); + }; + + Persistent MidiGroupTerminalBlock::s_constructorTemplate; + + v8::Local WrapMidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiGroupTerminalBlock::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ UnwrapMidiGroupTerminalBlock(Local value) { + return MidiGroupTerminalBlock::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiGroupTerminalBlock(Local exports) { + MidiGroupTerminalBlock::Init(exports); + } + + class MidiMessage128 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage128").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word3").ToLocalChecked(), Word3Getter, Word3Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word2").ToLocalChecked(), Word2Getter, Word2Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word1").ToLocalChecked(), Word1Getter, Word1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage128").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage128^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage128^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage128(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 5 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32() + && info[4]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned int arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage128(arg0,arg1,arg2,arg3,arg4); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[1]) || info[1]->IsArray())) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Platform::Array^ arg1 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage128(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage128 *wrapperInstance = new MidiMessage128(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage128^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage128^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage128(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word3Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word3; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word3Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word3 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word2Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word2; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word2Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word2 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage128^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage128^ UnwrapMidiMessage128(Local value); + }; + + Persistent MidiMessage128::s_constructorTemplate; + + v8::Local WrapMidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage128::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage128^ UnwrapMidiMessage128(Local value) { + return MidiMessage128::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage128(Local exports) { + MidiMessage128::Init(exports); + } + + class MidiMessage32 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage32").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage32").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage32^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage32^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage32(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage32(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage32 *wrapperInstance = new MidiMessage32(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage32^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage32^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage32(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage32^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage32^ UnwrapMidiMessage32(Local value); + }; + + Persistent MidiMessage32::s_constructorTemplate; + + v8::Local WrapMidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage32::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage32^ UnwrapMidiMessage32(Local value) { + return MidiMessage32::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage32(Local exports) { + MidiMessage32::Init(exports); + } + + class MidiMessage64 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage64").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word1").ToLocalChecked(), Word1Getter, Word1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage64").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage64^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage64^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage64(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage64(arg0,arg1,arg2); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[1]) || info[1]->IsArray())) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Platform::Array^ arg1 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage64(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage64 *wrapperInstance = new MidiMessage64(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage64^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage64^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage64(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage64^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage64^ UnwrapMidiMessage64(Local value); + }; + + Persistent MidiMessage64::s_constructorTemplate; + + v8::Local WrapMidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage64::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage64^ UnwrapMidiMessage64(Local value) { + return MidiMessage64::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage64(Local exports) { + MidiMessage64::Init(exports); + } + + class MidiMessage96 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage96").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word2").ToLocalChecked(), Word2Getter, Word2Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word1").ToLocalChecked(), Word1Getter, Word1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage96").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage96^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage96^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage96(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage96(arg0,arg1,arg2,arg3); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[1]) || info[1]->IsArray())) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Platform::Array^ arg1 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage96(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage96 *wrapperInstance = new MidiMessage96(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage96^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage96^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage96(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word2Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word2; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word2Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word2 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage96^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage96^ UnwrapMidiMessage96(Local value); + }; + + Persistent MidiMessage96::s_constructorTemplate; + + v8::Local WrapMidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage96::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage96^ UnwrapMidiMessage96(Local value) { + return MidiMessage96::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage96(Local exports) { + MidiMessage96::Init(exports); + } + + class MidiMessageBuilder : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageBuilder").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "buildUtilityMessage", BuildUtilityMessage); + Nan::SetMethod(constructor, "buildSystemMessage", BuildSystemMessage); + Nan::SetMethod(constructor, "buildMidi1ChannelVoiceMessage", BuildMidi1ChannelVoiceMessage); + Nan::SetMethod(constructor, "buildSystemExclusive7Message", BuildSystemExclusive7Message); + Nan::SetMethod(constructor, "buildMidi2ChannelVoiceMessage", BuildMidi2ChannelVoiceMessage); + Nan::SetMethod(constructor, "buildSystemExclusive8Message", BuildSystemExclusive8Message); + Nan::SetMethod(constructor, "buildMixedDataSetChunkHeaderMessage", BuildMixedDataSetChunkHeaderMessage); + Nan::SetMethod(constructor, "buildMixedDataSetChunkDataMessage", BuildMixedDataSetChunkDataMessage); + Nan::SetMethod(constructor, "buildFlexDataMessage", BuildFlexDataMessage); + Nan::SetMethod(constructor, "buildStreamMessage", BuildStreamMessage); + + + Nan::Set(exports, Nan::New("MidiMessageBuilder").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageBuilder^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageBuilder^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageBuilder *wrapperInstance = new MidiMessageBuilder(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageBuilder^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageBuilder^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageBuilder(winRtInstance)); + } + + + + + + static void BuildUtilityMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildUtilityMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildSystemMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 5 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildSystemMessage(arg0, arg1, arg2, arg3, arg4); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMidi1ChannelVoiceMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 6 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[3]) + && info[4]->IsInt32() + && info[5]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus arg2 = static_cast<::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus>(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg3 = UnwrapMidiChannel(info[3]); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMidi1ChannelVoiceMessage(arg0, arg1, arg2, arg3, arg4, arg5); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildSystemExclusive7Message(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage64^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildSystemExclusive7Message(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapMidiMessage64(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMidi2ChannelVoiceMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 6 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[3]) + && info[4]->IsInt32() + && info[5]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus arg2 = static_cast<::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus>(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg3 = UnwrapMidiChannel(info[3]); + unsigned short arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned int arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage64^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMidi2ChannelVoiceMessage(arg0, arg1, arg2, arg3, arg4, arg5); + info.GetReturnValue().Set(WrapMidiMessage64(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildSystemExclusive8Message(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 18 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32() + && info[10]->IsInt32() + && info[11]->IsInt32() + && info[12]->IsInt32() + && info[13]->IsInt32() + && info[14]->IsInt32() + && info[15]->IsInt32() + && info[16]->IsInt32() + && info[17]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi2::MidiSystemExclusive8Status arg2 = static_cast<::Windows::Devices::Midi2::MidiSystemExclusive8Status>(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + unsigned char arg10 = static_cast(Nan::To(info[10]).FromMaybe(0)); + unsigned char arg11 = static_cast(Nan::To(info[11]).FromMaybe(0)); + unsigned char arg12 = static_cast(Nan::To(info[12]).FromMaybe(0)); + unsigned char arg13 = static_cast(Nan::To(info[13]).FromMaybe(0)); + unsigned char arg14 = static_cast(Nan::To(info[14]).FromMaybe(0)); + unsigned char arg15 = static_cast(Nan::To(info[15]).FromMaybe(0)); + unsigned char arg16 = static_cast(Nan::To(info[16]).FromMaybe(0)); + unsigned char arg17 = static_cast(Nan::To(info[17]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildSystemExclusive8Message(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMixedDataSetChunkHeaderMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned short arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned short arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned short arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned short arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned short arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned short arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned short arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMixedDataSetChunkHeaderMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMixedDataSetChunkDataMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 17 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32() + && info[10]->IsInt32() + && info[11]->IsInt32() + && info[12]->IsInt32() + && info[13]->IsInt32() + && info[14]->IsInt32() + && info[15]->IsInt32() + && info[16]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + unsigned char arg10 = static_cast(Nan::To(info[10]).FromMaybe(0)); + unsigned char arg11 = static_cast(Nan::To(info[11]).FromMaybe(0)); + unsigned char arg12 = static_cast(Nan::To(info[12]).FromMaybe(0)); + unsigned char arg13 = static_cast(Nan::To(info[13]).FromMaybe(0)); + unsigned char arg14 = static_cast(Nan::To(info[14]).FromMaybe(0)); + unsigned char arg15 = static_cast(Nan::To(info[15]).FromMaybe(0)); + unsigned char arg16 = static_cast(Nan::To(info[16]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMixedDataSetChunkDataMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFlexDataMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[4]) + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsUint32() + && info[8]->IsUint32() + && info[9]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg4 = UnwrapMidiChannel(info[4]); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned int arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned int arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned int arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildFlexDataMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildStreamMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 7 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsUint32() + && info[5]->IsUint32() + && info[6]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned short arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned short arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned int arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned int arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned int arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildStreamMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageBuilder^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageBuilder^ UnwrapMidiMessageBuilder(Local value); + }; + + Persistent MidiMessageBuilder::s_constructorTemplate; + + v8::Local WrapMidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageBuilder::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageBuilder^ UnwrapMidiMessageBuilder(Local value) { + return MidiMessageBuilder::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageBuilder(Local exports) { + MidiMessageBuilder::Init(exports); + } + + class MidiMessageConverter : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageConverter").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "convertMidi1Message", ConvertMidi1Message); + Nan::SetMethod(constructor, "convertMidi1ChannelPressureMessage", ConvertMidi1ChannelPressureMessage); + Nan::SetMethod(constructor, "convertMidi1NoteOffMessage", ConvertMidi1NoteOffMessage); + Nan::SetMethod(constructor, "convertMidi1NoteOnMessage", ConvertMidi1NoteOnMessage); + Nan::SetMethod(constructor, "convertMidi1PitchBendChangeMessage", ConvertMidi1PitchBendChangeMessage); + Nan::SetMethod(constructor, "convertMidi1PolyphonicKeyPressureMessage", ConvertMidi1PolyphonicKeyPressureMessage); + Nan::SetMethod(constructor, "convertMidi1ProgramChangeMessage", ConvertMidi1ProgramChangeMessage); + Nan::SetMethod(constructor, "convertMidi1TimeCodeMessage", ConvertMidi1TimeCodeMessage); + Nan::SetMethod(constructor, "convertMidi1SongPositionPointerMessage", ConvertMidi1SongPositionPointerMessage); + Nan::SetMethod(constructor, "convertMidi1SongSelectMessage", ConvertMidi1SongSelectMessage); + Nan::SetMethod(constructor, "convertMidi1TuneRequestMessage", ConvertMidi1TuneRequestMessage); + Nan::SetMethod(constructor, "convertMidi1TimingClockMessage", ConvertMidi1TimingClockMessage); + Nan::SetMethod(constructor, "convertMidi1StartMessage", ConvertMidi1StartMessage); + Nan::SetMethod(constructor, "convertMidi1ContinueMessage", ConvertMidi1ContinueMessage); + Nan::SetMethod(constructor, "convertMidi1StopMessage", ConvertMidi1StopMessage); + Nan::SetMethod(constructor, "convertMidi1ActiveSensingMessage", ConvertMidi1ActiveSensingMessage); + Nan::SetMethod(constructor, "convertMidi1SystemResetMessage", ConvertMidi1SystemResetMessage); + + + Nan::Set(exports, Nan::New("MidiMessageConverter").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageConverter^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageConverter^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageConverter^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageConverter *wrapperInstance = new MidiMessageConverter(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageConverter^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageConverter^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageConverter^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageConverter(winRtInstance)); + } + + + + + + static void ConvertMidi1Message(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1Message(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1Message(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 5 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1Message(arg0, arg1, arg2, arg3, arg4); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ChannelPressureMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiChannelPressureMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiChannelPressureMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiChannelPressureMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ChannelPressureMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1NoteOffMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiNoteOffMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiNoteOffMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiNoteOffMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1NoteOffMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1NoteOnMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiNoteOnMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiNoteOnMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiNoteOnMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1NoteOnMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1PitchBendChangeMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiPitchBendChangeMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiPitchBendChangeMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiPitchBendChangeMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1PitchBendChangeMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1PolyphonicKeyPressureMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiPolyphonicKeyPressureMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiPolyphonicKeyPressureMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiPolyphonicKeyPressureMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1PolyphonicKeyPressureMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ProgramChangeMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiProgramChangeMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiProgramChangeMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiProgramChangeMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ProgramChangeMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1TimeCodeMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiTimeCodeMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiTimeCodeMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiTimeCodeMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1TimeCodeMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1SongPositionPointerMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiSongPositionPointerMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiSongPositionPointerMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiSongPositionPointerMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1SongPositionPointerMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1SongSelectMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiSongSelectMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiSongSelectMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiSongSelectMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1SongSelectMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1TuneRequestMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiTuneRequestMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiTuneRequestMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiTuneRequestMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1TuneRequestMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1TimingClockMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiTimingClockMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiTimingClockMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiTimingClockMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1TimingClockMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1StartMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiStartMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiStartMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiStartMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1StartMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ContinueMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiContinueMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiContinueMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiContinueMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ContinueMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1StopMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiStopMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiStopMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiStopMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1StopMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ActiveSensingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiActiveSensingMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiActiveSensingMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiActiveSensingMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ActiveSensingMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1SystemResetMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiSystemResetMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiSystemResetMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiSystemResetMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1SystemResetMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageConverter^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageConverter^ UnwrapMidiMessageConverter(Local value); + }; + + Persistent MidiMessageConverter::s_constructorTemplate; + + v8::Local WrapMidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageConverter::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageConverter^ UnwrapMidiMessageConverter(Local value) { + return MidiMessageConverter::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageConverter(Local exports) { + MidiMessageConverter::Init(exports); + } + + class MidiMessageReceivedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageReceivedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getMessagePacket", GetMessagePacket); + Nan::SetPrototypeMethod(localRef, "fillWords", FillWords); + Nan::SetPrototypeMethod(localRef, "fillMessageStruct", FillMessageStruct); + Nan::SetPrototypeMethod(localRef, "fillMessage32", FillMessage32); + Nan::SetPrototypeMethod(localRef, "fillMessage64", FillMessage64); + Nan::SetPrototypeMethod(localRef, "fillMessage96", FillMessage96); + Nan::SetPrototypeMethod(localRef, "fillMessage128", FillMessage128); + Nan::SetPrototypeMethod(localRef, "fillWordArray", FillWordArray); + Nan::SetPrototypeMethod(localRef, "fillByteArray", FillByteArray); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "appendWordsToList", AppendWordsToList); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessageReceivedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageReceivedEventArgs *wrapperInstance = new MidiMessageReceivedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageReceivedEventArgs(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetMessagePacket(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = wrapper->_instance->GetMessagePacket(); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int arg0; + unsigned int arg1; + unsigned int arg2; + unsigned int arg3; + + unsigned char result; + result = wrapper->_instance->FillWords(&arg0, &arg1, &arg2, &arg3); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("number").ToLocalChecked(), Nan::New(result)); + Nan::Set(resObj, Nan::New("word0").ToLocalChecked(), Nan::New(arg0)); + Nan::Set(resObj, Nan::New("word1").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("word2").ToLocalChecked(), Nan::New(arg2)); + Nan::Set(resObj, Nan::New("word3").ToLocalChecked(), Nan::New(arg3)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessageStruct(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiMessageStruct arg0; + + unsigned char result; + result = wrapper->_instance->FillMessageStruct(&arg0); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("number").ToLocalChecked(), Nan::New(result)); + Nan::Set(resObj, Nan::New("message").ToLocalChecked(), MidiMessageStructToJsObject(arg0)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage32(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage32^ arg0 = UnwrapMidiMessage32(info[0]); + + bool result; + result = wrapper->_instance->FillMessage32(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage64(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage64^ arg0 = UnwrapMidiMessage64(info[0]); + + bool result; + result = wrapper->_instance->FillMessage64(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage96(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage96^ arg0 = UnwrapMidiMessage96(info[0]); + + bool result; + result = wrapper->_instance->FillMessage96(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage128(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage128^ arg0 = UnwrapMidiMessage128(info[0]); + + bool result; + result = wrapper->_instance->FillMessage128(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillWordArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + } + static void FillByteArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ UnwrapMidiMessageReceivedEventArgs(Local value); + }; + + Persistent MidiMessageReceivedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageReceivedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ UnwrapMidiMessageReceivedEventArgs(Local value) { + return MidiMessageReceivedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageReceivedEventArgs(Local exports) { + MidiMessageReceivedEventArgs::Init(exports); + } + + class MidiMessageTypeEndpointListener : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageTypeEndpointListener").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventFiringMainMessageReceivedEvent").ToLocalChecked(), PreventFiringMainMessageReceivedEventGetter, PreventFiringMainMessageReceivedEventSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventCallingFurtherListeners").ToLocalChecked(), PreventCallingFurtherListenersGetter, PreventCallingFurtherListenersSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeMessageTypes").ToLocalChecked(), IncludeMessageTypesGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessageTypeEndpointListener").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageTypeEndpointListener *wrapperInstance = new MidiMessageTypeEndpointListener(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageTypeEndpointListener(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventFiringMainMessageReceivedEvent; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventFiringMainMessageReceivedEvent = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreventCallingFurtherListenersGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventCallingFurtherListeners; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventCallingFurtherListenersSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventCallingFurtherListeners = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeMessageTypesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiMessageType>^ result = wrapper->_instance->IncludeMessageTypes; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiMessageType>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiMessageType val) -> Local { + return Nan::New(static_cast(val)); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiMessageType { + return static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ UnwrapMidiMessageTypeEndpointListener(Local value); + }; + + Persistent MidiMessageTypeEndpointListener::s_constructorTemplate; + + v8::Local WrapMidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageTypeEndpointListener::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ UnwrapMidiMessageTypeEndpointListener(Local value) { + return MidiMessageTypeEndpointListener::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageTypeEndpointListener(Local exports) { + MidiMessageTypeEndpointListener::Init(exports); + } + + class MidiMessageUtility : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageUtility").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "validateMessage32MessageType", ValidateMessage32MessageType); + Nan::SetMethod(constructor, "validateMessage64MessageType", ValidateMessage64MessageType); + Nan::SetMethod(constructor, "validateMessage96MessageType", ValidateMessage96MessageType); + Nan::SetMethod(constructor, "validateMessage128MessageType", ValidateMessage128MessageType); + Nan::SetMethod(constructor, "getMessageTypeFromMessageFirstWord", GetMessageTypeFromMessageFirstWord); + Nan::SetMethod(constructor, "getPacketTypeFromMessageFirstWord", GetPacketTypeFromMessageFirstWord); + Nan::SetMethod(constructor, "messageTypeHasGroupField", MessageTypeHasGroupField); + Nan::SetMethod(constructor, "replaceGroupInMessageFirstWord", ReplaceGroupInMessageFirstWord); + Nan::SetMethod(constructor, "getGroupFromMessageFirstWord", GetGroupFromMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromUtilityMessage", GetStatusFromUtilityMessage); + Nan::SetMethod(constructor, "getStatusFromMidi1ChannelVoiceMessage", GetStatusFromMidi1ChannelVoiceMessage); + Nan::SetMethod(constructor, "getStatusFromMidi2ChannelVoiceMessageFirstWord", GetStatusFromMidi2ChannelVoiceMessageFirstWord); + Nan::SetMethod(constructor, "getStatusBankFromFlexDataMessageFirstWord", GetStatusBankFromFlexDataMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromFlexDataMessageFirstWord", GetStatusFromFlexDataMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromSystemCommonMessage", GetStatusFromSystemCommonMessage); + Nan::SetMethod(constructor, "getStatusFromDataMessage64FirstWord", GetStatusFromDataMessage64FirstWord); + Nan::SetMethod(constructor, "getNumberOfBytesFromDataMessage64FirstWord", GetNumberOfBytesFromDataMessage64FirstWord); + Nan::SetMethod(constructor, "getStatusFromDataMessage128FirstWord", GetStatusFromDataMessage128FirstWord); + Nan::SetMethod(constructor, "getNumberOfBytesFromDataMessage128FirstWord", GetNumberOfBytesFromDataMessage128FirstWord); + Nan::SetMethod(constructor, "messageTypeHasChannelField", MessageTypeHasChannelField); + Nan::SetMethod(constructor, "replaceChannelInMessageFirstWord", ReplaceChannelInMessageFirstWord); + Nan::SetMethod(constructor, "getChannelFromMessageFirstWord", GetChannelFromMessageFirstWord); + Nan::SetMethod(constructor, "getFormFromStreamMessageFirstWord", GetFormFromStreamMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromStreamMessageFirstWord", GetStatusFromStreamMessageFirstWord); + Nan::SetMethod(constructor, "getMessageFriendlyNameFromFirstWord", GetMessageFriendlyNameFromFirstWord); + Nan::SetMethod(constructor, "getPacketListFromWordList", GetPacketListFromWordList); + Nan::SetMethod(constructor, "getWordListFromPacketList", GetWordListFromPacketList); + + + Nan::Set(exports, Nan::New("MidiMessageUtility").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageUtility^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageUtility^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageUtility^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageUtility *wrapperInstance = new MidiMessageUtility(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageUtility^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageUtility^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageUtility^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageUtility(winRtInstance)); + } + + + + + + static void ValidateMessage32MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage32MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ValidateMessage64MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage64MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ValidateMessage96MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage96MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ValidateMessage128MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage128MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetMessageTypeFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessageType result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetMessageTypeFromMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetPacketTypeFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiPacketType result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetPacketTypeFromMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void MessageTypeHasGroupField(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiMessageType arg0 = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::MessageTypeHasGroupField(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ReplaceGroupInMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + + unsigned int result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ReplaceGroupInMessageFirstWord(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetGroupFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiGroup^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetGroupFromMessageFirstWord(arg0); + info.GetReturnValue().Set(WrapMidiGroup(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromUtilityMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromUtilityMessage(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromMidi1ChannelVoiceMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromMidi1ChannelVoiceMessage(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromMidi2ChannelVoiceMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromMidi2ChannelVoiceMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusBankFromFlexDataMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusBankFromFlexDataMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromFlexDataMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromFlexDataMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromSystemCommonMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromSystemCommonMessage(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromDataMessage64FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromDataMessage64FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetNumberOfBytesFromDataMessage64FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetNumberOfBytesFromDataMessage64FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromDataMessage128FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromDataMessage128FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetNumberOfBytesFromDataMessage128FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetNumberOfBytesFromDataMessage128FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void MessageTypeHasChannelField(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiMessageType arg0 = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::MessageTypeHasChannelField(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ReplaceChannelInMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg1 = UnwrapMidiChannel(info[1]); + + unsigned int result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ReplaceChannelInMessageFirstWord(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetChannelFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiChannel^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetChannelFromMessageFirstWord(arg0); + info.GetReturnValue().Set(WrapMidiChannel(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetFormFromStreamMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetFormFromStreamMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromStreamMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned short result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromStreamMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetMessageFriendlyNameFromFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetMessageFriendlyNameFromFirstWord(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetPacketListFromWordList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable^>(info[1]) || info[1]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::Collections::IIterable^ arg1 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetPacketListFromWordList(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetWordListFromPacketList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + ::Windows::Foundation::Collections::IVector^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetWordListFromPacketList(arg0); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageUtility^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageUtility^ UnwrapMidiMessageUtility(Local value); + }; + + Persistent MidiMessageUtility::s_constructorTemplate; + + v8::Local WrapMidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageUtility::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageUtility^ UnwrapMidiMessageUtility(Local value) { + return MidiMessageUtility::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageUtility(Local exports) { + MidiMessageUtility::Init(exports); + } + + class MidiService : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiService").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "pingService", PingService); + Nan::SetMethod(constructor, "getInstalledTransportPlugins", GetInstalledTransportPlugins); + Nan::SetMethod(constructor, "getInstalledMessageProcessingPlugins", GetInstalledMessageProcessingPlugins); + Nan::SetMethod(constructor, "getActiveSessions", GetActiveSessions); + Nan::SetMethod(constructor, "createTemporaryLoopbackEndpoints", CreateTemporaryLoopbackEndpoints); + Nan::SetMethod(constructor, "removeTemporaryLoopbackEndpoints", RemoveTemporaryLoopbackEndpoints); + Nan::SetMethod(constructor, "updateTransportPluginConfiguration", UpdateTransportPluginConfiguration); + Nan::SetMethod(constructor, "updateProcessingPluginConfiguration", UpdateProcessingPluginConfiguration); + + + Nan::Set(exports, Nan::New("MidiService").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiService(::Windows::Devices::Midi2::MidiService^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiService^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiService^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiService^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiService *wrapperInstance = new MidiService(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiService^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiService^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiService^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiService(winRtInstance)); + } + + + + + + static void PingService(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ result; + result = ::Windows::Devices::Midi2::MidiService::PingService(arg0); + info.GetReturnValue().Set(WrapMidiServicePingResponseSummary(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsInt32() + && info[1]->IsUint32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ result; + result = ::Windows::Devices::Midi2::MidiService::PingService(arg0, arg1); + info.GetReturnValue().Set(WrapMidiServicePingResponseSummary(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetInstalledTransportPlugins(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>^ result; + result = ::Windows::Devices::Midi2::MidiService::GetInstalledTransportPlugins(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ val) -> Local { + return WrapMidiServiceTransportPluginInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ { + return UnwrapMidiServiceTransportPluginInfo(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetInstalledMessageProcessingPlugins(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>^ result; + result = ::Windows::Devices::Midi2::MidiService::GetInstalledMessageProcessingPlugins(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ val) -> Local { + return WrapMidiServiceMessageProcessingPluginInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ { + return UnwrapMidiServiceMessageProcessingPluginInfo(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetActiveSessions(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiServiceSessionInfo^>^ result; + result = ::Windows::Devices::Midi2::MidiService::GetActiveSessions(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiServiceSessionInfo^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceSessionInfo^ val) -> Local { + return WrapMidiServiceSessionInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceSessionInfo^ { + return UnwrapMidiServiceSessionInfo(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void CreateTemporaryLoopbackEndpoints(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && NodeRT::Utils::IsGuid(info[0]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[2])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ arg1 = UnwrapMidiServiceLoopbackEndpointDefinition(info[1]); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ arg2 = UnwrapMidiServiceLoopbackEndpointDefinition(info[2]); + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ result; + result = ::Windows::Devices::Midi2::MidiService::CreateTemporaryLoopbackEndpoints(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiServiceLoopbackEndpointCreationResult(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void RemoveTemporaryLoopbackEndpoints(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && NodeRT::Utils::IsGuid(info[0])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + + bool result; + result = ::Windows::Devices::Midi2::MidiService::RemoveTemporaryLoopbackEndpoints(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void UpdateTransportPluginConfiguration(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ arg0 = UnwrapIMidiServiceTransportPluginConfiguration(info[0]); + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ result; + result = ::Windows::Devices::Midi2::MidiService::UpdateTransportPluginConfiguration(arg0); + info.GetReturnValue().Set(WrapMidiServiceConfigurationResponse(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void UpdateProcessingPluginConfiguration(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ arg0 = UnwrapIMidiServiceMessageProcessingPluginConfiguration(info[0]); + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ result; + result = ::Windows::Devices::Midi2::MidiService::UpdateProcessingPluginConfiguration(arg0); + info.GetReturnValue().Set(WrapMidiServiceConfigurationResponse(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiService^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiService(::Windows::Devices::Midi2::MidiService^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiService^ UnwrapMidiService(Local value); + }; + + Persistent MidiService::s_constructorTemplate; + + v8::Local WrapMidiService(::Windows::Devices::Midi2::MidiService^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiService::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiService^ UnwrapMidiService(Local value) { + return MidiService::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiService(Local exports) { + MidiService::Init(exports); + } + + class MidiServiceConfigurationResponse : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceConfigurationResponse").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("responseJson").ToLocalChecked(), ResponseJsonGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("status").ToLocalChecked(), StatusGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceConfigurationResponse").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceConfigurationResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceConfigurationResponse *wrapperInstance = new MidiServiceConfigurationResponse(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceConfigurationResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceConfigurationResponse(winRtInstance)); + } + + + + + + static void ResponseJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info.This())) { + return; + } + + MidiServiceConfigurationResponse *wrapper = MidiServiceConfigurationResponse::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ResponseJson; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void StatusGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info.This())) { + return; + } + + MidiServiceConfigurationResponse *wrapper = MidiServiceConfigurationResponse::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus result = wrapper->_instance->Status; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ UnwrapMidiServiceConfigurationResponse(Local value); + }; + + Persistent MidiServiceConfigurationResponse::s_constructorTemplate; + + v8::Local WrapMidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceConfigurationResponse::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ UnwrapMidiServiceConfigurationResponse(Local value) { + return MidiServiceConfigurationResponse::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceConfigurationResponse(Local exports) { + MidiServiceConfigurationResponse::Init(exports); + } + + class MidiServiceLoopbackEndpointCreationResult : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceLoopbackEndpointCreationResult").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("associationId").ToLocalChecked(), AssociationIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceIdA").ToLocalChecked(), EndpointDeviceIdAGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceIdB").ToLocalChecked(), EndpointDeviceIdBGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("success").ToLocalChecked(), SuccessGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceLoopbackEndpointCreationResult").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceLoopbackEndpointCreationResult *wrapperInstance = new MidiServiceLoopbackEndpointCreationResult(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceLoopbackEndpointCreationResult(winRtInstance)); + } + + + + + + static void AssociationIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->AssociationId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdAGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceIdA; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdBGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceIdB; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuccessGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->Success; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ UnwrapMidiServiceLoopbackEndpointCreationResult(Local value); + }; + + Persistent MidiServiceLoopbackEndpointCreationResult::s_constructorTemplate; + + v8::Local WrapMidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceLoopbackEndpointCreationResult::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ UnwrapMidiServiceLoopbackEndpointCreationResult(Local value) { + return MidiServiceLoopbackEndpointCreationResult::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceLoopbackEndpointCreationResult(Local exports) { + MidiServiceLoopbackEndpointCreationResult::Init(exports); + } + + class MidiServiceLoopbackEndpointDefinition : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceLoopbackEndpointDefinition").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("uniqueId").ToLocalChecked(), UniqueIdGetter, UniqueIdSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("description").ToLocalChecked(), DescriptionGetter, DescriptionSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceLoopbackEndpointDefinition").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceLoopbackEndpointDefinition *wrapperInstance = new MidiServiceLoopbackEndpointDefinition(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceLoopbackEndpointDefinition(winRtInstance)); + } + + + + + + static void UniqueIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UniqueId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UniqueIdSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->UniqueId = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Description; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DescriptionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Description = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ UnwrapMidiServiceLoopbackEndpointDefinition(Local value); + }; + + Persistent MidiServiceLoopbackEndpointDefinition::s_constructorTemplate; + + v8::Local WrapMidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceLoopbackEndpointDefinition::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ UnwrapMidiServiceLoopbackEndpointDefinition(Local value) { + return MidiServiceLoopbackEndpointDefinition::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceLoopbackEndpointDefinition(Local exports) { + MidiServiceLoopbackEndpointDefinition::Init(exports); + } + + class MidiServiceMessageProcessingPluginInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceMessageProcessingPluginInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("author").ToLocalChecked(), AuthorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientConfigurationAssemblyName").ToLocalChecked(), ClientConfigurationAssemblyNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("description").ToLocalChecked(), DescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isClientConfigurable").ToLocalChecked(), IsClientConfigurableGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isSystemManaged").ToLocalChecked(), IsSystemManagedGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("smallImagePath").ToLocalChecked(), SmallImagePathGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMultipleInstancesPerDevice").ToLocalChecked(), SupportsMultipleInstancesPerDeviceGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("version").ToLocalChecked(), VersionGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceMessageProcessingPluginInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceMessageProcessingPluginInfo *wrapperInstance = new MidiServiceMessageProcessingPluginInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceMessageProcessingPluginInfo(winRtInstance)); + } + + + + + + static void AuthorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Author; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientConfigurationAssemblyNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ClientConfigurationAssemblyName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Description; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsClientConfigurableGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsClientConfigurable; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsSystemManagedGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsSystemManaged; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SmallImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SmallImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMultipleInstancesPerDeviceGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMultipleInstancesPerDevice; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void VersionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Version; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ UnwrapMidiServiceMessageProcessingPluginInfo(Local value); + }; + + Persistent MidiServiceMessageProcessingPluginInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceMessageProcessingPluginInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ UnwrapMidiServiceMessageProcessingPluginInfo(Local value) { + return MidiServiceMessageProcessingPluginInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceMessageProcessingPluginInfo(Local exports) { + MidiServiceMessageProcessingPluginInfo::Init(exports); + } + + class MidiServicePingResponse : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServicePingResponse").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientDeltaTimestamp").ToLocalChecked(), ClientDeltaTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientReceiveMidiTimestamp").ToLocalChecked(), ClientReceiveMidiTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientSendMidiTimestamp").ToLocalChecked(), ClientSendMidiTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("index").ToLocalChecked(), IndexGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("serviceReportedMidiTimestamp").ToLocalChecked(), ServiceReportedMidiTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("sourceId").ToLocalChecked(), SourceIdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServicePingResponse").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServicePingResponse^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServicePingResponse *wrapperInstance = new MidiServicePingResponse(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServicePingResponse^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServicePingResponse(winRtInstance)); + } + + + + + + static void ClientDeltaTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ClientDeltaTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientReceiveMidiTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ClientReceiveMidiTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientSendMidiTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ClientSendMidiTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Index; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ServiceReportedMidiTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ServiceReportedMidiTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SourceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->SourceId; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServicePingResponse^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServicePingResponse^ UnwrapMidiServicePingResponse(Local value); + }; + + Persistent MidiServicePingResponse::s_constructorTemplate; + + v8::Local WrapMidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServicePingResponse::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServicePingResponse^ UnwrapMidiServicePingResponse(Local value) { + return MidiServicePingResponse::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServicePingResponse(Local exports) { + MidiServicePingResponse::Init(exports); + } + + class MidiServicePingResponseSummary : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServicePingResponseSummary").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("averagePingRoundTripMidiClock").ToLocalChecked(), AveragePingRoundTripMidiClockGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("failureReason").ToLocalChecked(), FailureReasonGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("responses").ToLocalChecked(), ResponsesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("success").ToLocalChecked(), SuccessGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("totalPingRoundTripMidiClock").ToLocalChecked(), TotalPingRoundTripMidiClockGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServicePingResponseSummary").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponseSummary^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServicePingResponseSummary *wrapperInstance = new MidiServicePingResponseSummary(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponseSummary^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServicePingResponseSummary(winRtInstance)); + } + + + + + + static void AveragePingRoundTripMidiClockGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->AveragePingRoundTripMidiClock; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FailureReasonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->FailureReason; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ResponsesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiServicePingResponse^>^ result = wrapper->_instance->Responses; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiServicePingResponse^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiServicePingResponse^ val) -> Local { + return WrapMidiServicePingResponse(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServicePingResponse^ { + return UnwrapMidiServicePingResponse(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuccessGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->Success; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TotalPingRoundTripMidiClockGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->TotalPingRoundTripMidiClock; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ UnwrapMidiServicePingResponseSummary(Local value); + }; + + Persistent MidiServicePingResponseSummary::s_constructorTemplate; + + v8::Local WrapMidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServicePingResponseSummary::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ UnwrapMidiServicePingResponseSummary(Local value) { + return MidiServicePingResponseSummary::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServicePingResponseSummary(Local exports) { + MidiServicePingResponseSummary::Init(exports); + } + + class MidiServiceSessionConnectionInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceSessionConnectionInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("earliestConnectionTime").ToLocalChecked(), EarliestConnectionTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceId").ToLocalChecked(), EndpointDeviceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("instanceCount").ToLocalChecked(), InstanceCountGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceSessionConnectionInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceSessionConnectionInfo *wrapperInstance = new MidiServiceSessionConnectionInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceSessionConnectionInfo(winRtInstance)); + } + + + + + + static void EarliestConnectionTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info.This())) { + return; + } + + MidiServiceSessionConnectionInfo *wrapper = MidiServiceSessionConnectionInfo::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EarliestConnectionTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info.This())) { + return; + } + + MidiServiceSessionConnectionInfo *wrapper = MidiServiceSessionConnectionInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void InstanceCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info.This())) { + return; + } + + MidiServiceSessionConnectionInfo *wrapper = MidiServiceSessionConnectionInfo::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->InstanceCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ UnwrapMidiServiceSessionConnectionInfo(Local value); + }; + + Persistent MidiServiceSessionConnectionInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceSessionConnectionInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ UnwrapMidiServiceSessionConnectionInfo(Local value) { + return MidiServiceSessionConnectionInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceSessionConnectionInfo(Local exports) { + MidiServiceSessionConnectionInfo::Init(exports); + } + + class MidiServiceSessionInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceSessionInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("connections").ToLocalChecked(), ConnectionsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("processId").ToLocalChecked(), ProcessIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("processName").ToLocalChecked(), ProcessNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("sessionId").ToLocalChecked(), SessionIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("sessionName").ToLocalChecked(), SessionNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("startTime").ToLocalChecked(), StartTimeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceSessionInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceSessionInfo *wrapperInstance = new MidiServiceSessionInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceSessionInfo(winRtInstance)); + } + + + + + + static void ConnectionsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>^ result = wrapper->_instance->Connections; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ val) -> Local { + return WrapMidiServiceSessionConnectionInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ { + return UnwrapMidiServiceSessionConnectionInfo(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProcessIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ProcessId; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProcessNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ProcessName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SessionIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->SessionId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SessionNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SessionName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void StartTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->StartTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceSessionInfo^ UnwrapMidiServiceSessionInfo(Local value); + }; + + Persistent MidiServiceSessionInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceSessionInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ UnwrapMidiServiceSessionInfo(Local value) { + return MidiServiceSessionInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceSessionInfo(Local exports) { + MidiServiceSessionInfo::Init(exports); + } + + class MidiServiceTransportPluginInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceTransportPluginInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("author").ToLocalChecked(), AuthorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientConfigurationAssemblyName").ToLocalChecked(), ClientConfigurationAssemblyNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("description").ToLocalChecked(), DescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isClientConfigurable").ToLocalChecked(), IsClientConfigurableGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isRuntimeCreatableByApps").ToLocalChecked(), IsRuntimeCreatableByAppsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isRuntimeCreatableBySettings").ToLocalChecked(), IsRuntimeCreatableBySettingsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isSystemManaged").ToLocalChecked(), IsSystemManagedGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("mnemonic").ToLocalChecked(), MnemonicGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("smallImagePath").ToLocalChecked(), SmallImagePathGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("version").ToLocalChecked(), VersionGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceTransportPluginInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceTransportPluginInfo *wrapperInstance = new MidiServiceTransportPluginInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceTransportPluginInfo(winRtInstance)); + } + + + + + + static void AuthorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Author; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientConfigurationAssemblyNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ClientConfigurationAssemblyName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Description; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsClientConfigurableGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsClientConfigurable; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsRuntimeCreatableByAppsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsRuntimeCreatableByApps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsRuntimeCreatableBySettingsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsRuntimeCreatableBySettings; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsSystemManagedGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsSystemManaged; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MnemonicGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Mnemonic; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SmallImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SmallImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void VersionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Version; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ UnwrapMidiServiceTransportPluginInfo(Local value); + }; + + Persistent MidiServiceTransportPluginInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceTransportPluginInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ UnwrapMidiServiceTransportPluginInfo(Local value) { + return MidiServiceTransportPluginInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceTransportPluginInfo(Local exports) { + MidiServiceTransportPluginInfo::Init(exports); + } + + class MidiSession : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiSession").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "createEndpointConnection", CreateEndpointConnection); + Nan::SetPrototypeMethod(localRef, "createVirtualDeviceAndConnection", CreateVirtualDeviceAndConnection); + Nan::SetPrototypeMethod(localRef, "disconnectEndpointConnection", DisconnectEndpointConnection); + Nan::SetPrototypeMethod(localRef, "updateName", UpdateName); + Nan::SetPrototypeMethod(localRef, "close", Close); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("connections").ToLocalChecked(), ConnectionsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isOpen").ToLocalChecked(), IsOpenGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settings").ToLocalChecked(), SettingsGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createSession", CreateSession); + + + Nan::Set(exports, Nan::New("MidiSession").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiSession(::Windows::Devices::Midi2::MidiSession^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiSession^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSession^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiSession *wrapperInstance = new MidiSession(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiSession^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSession^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiSession(winRtInstance)); + } + + + static void CreateEndpointConnection(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + ::Windows::Devices::Midi2::MidiEndpointConnection^ result; + result = wrapper->_instance->CreateEndpointConnection(arg0); + info.GetReturnValue().Set(WrapMidiEndpointConnection(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsString() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info[1])) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ arg1 = UnwrapIMidiEndpointConnectionSettings(info[1]); + + ::Windows::Devices::Midi2::MidiEndpointConnection^ result; + result = wrapper->_instance->CreateEndpointConnection(arg0, arg1); + info.GetReturnValue().Set(WrapMidiEndpointConnection(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void CreateVirtualDeviceAndConnection(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ arg0 = UnwrapMidiVirtualEndpointDeviceDefinition(info[0]); + + ::Windows::Devices::Midi2::MidiEndpointConnection^ result; + result = wrapper->_instance->CreateVirtualDeviceAndConnection(arg0); + info.GetReturnValue().Set(WrapMidiEndpointConnection(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void DisconnectEndpointConnection(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsGuid(info[0])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + + wrapper->_instance->DisconnectEndpointConnection(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void UpdateName(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + bool result; + result = wrapper->_instance->UpdateName(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Close(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 0) { + try { + delete wrapper->_instance; + wrapper->_instance = nullptr; + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CreateSession(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + ::Windows::Devices::Midi2::MidiSession^ result; + result = ::Windows::Devices::Midi2::MidiSession::CreateSession(arg0); + info.GetReturnValue().Set(WrapMidiSession(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsString() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info[1])) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + ::Windows::Devices::Midi2::MidiSessionSettings^ arg1 = UnwrapMidiSessionSettings(info[1]); + + ::Windows::Devices::Midi2::MidiSession^ result; + result = ::Windows::Devices::Midi2::MidiSession::CreateSession(arg0, arg1); + info.GetReturnValue().Set(WrapMidiSession(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConnectionsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView<::Platform::Guid, ::Windows::Devices::Midi2::MidiEndpointConnection^>^ result = wrapper->_instance->Connections; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper<::Platform::Guid,::Windows::Devices::Midi2::MidiEndpointConnection^>::CreateMapViewWrapper(result, + [](::Platform::Guid val) -> Local { + return NodeRT::Utils::GuidToJs(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsGuid(value); + }, + [](Local value) -> ::Platform::Guid { + return NodeRT::Utils::GuidFromJs(value); + }, + [](::Windows::Devices::Midi2::MidiEndpointConnection^ val) -> Local { + return WrapMidiEndpointConnection(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsOpenGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsOpen; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiSessionSettings^ result = wrapper->_instance->Settings; + info.GetReturnValue().Set(WrapMidiSessionSettings(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiSession^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiSession(::Windows::Devices::Midi2::MidiSession^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiSession^ UnwrapMidiSession(Local value); + }; + + Persistent MidiSession::s_constructorTemplate; + + v8::Local WrapMidiSession(::Windows::Devices::Midi2::MidiSession^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiSession::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiSession^ UnwrapMidiSession(Local value) { + return MidiSession::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiSession(Local exports) { + MidiSession::Init(exports); + } + + class MidiSessionSettings : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiSessionSettings").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("useMmcssThreads").ToLocalChecked(), UseMmcssThreadsGetter, UseMmcssThreadsSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiSessionSettings").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiSessionSettings^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSessionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiSessionSettings(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiSessionSettings *wrapperInstance = new MidiSessionSettings(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiSessionSettings^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSessionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiSessionSettings(winRtInstance)); + } + + + + + + static void UseMmcssThreadsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info.This())) { + return; + } + + MidiSessionSettings *wrapper = MidiSessionSettings::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UseMmcssThreads; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UseMmcssThreadsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info.This())) { + return; + } + + MidiSessionSettings *wrapper = MidiSessionSettings::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->UseMmcssThreads = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::MidiSessionSettings^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiSessionSettings^ UnwrapMidiSessionSettings(Local value); + }; + + Persistent MidiSessionSettings::s_constructorTemplate; + + v8::Local WrapMidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiSessionSettings::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiSessionSettings^ UnwrapMidiSessionSettings(Local value) { + return MidiSessionSettings::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiSessionSettings(Local exports) { + MidiSessionSettings::Init(exports); + } + + class MidiStreamConfigurationRequestReceivedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiStreamConfigurationRequestReceivedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preferredMidiProtocol").ToLocalChecked(), PreferredMidiProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointReceiveJitterReductionTimestamps").ToLocalChecked(), RequestEndpointReceiveJitterReductionTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointTransmitJitterReductionTimestamps").ToLocalChecked(), RequestEndpointTransmitJitterReductionTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiStreamConfigurationRequestReceivedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiStreamConfigurationRequestReceivedEventArgs *wrapperInstance = new MidiStreamConfigurationRequestReceivedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiStreamConfigurationRequestReceivedEventArgs(winRtInstance)); + } + + + + + + static void PreferredMidiProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiProtocol result = wrapper->_instance->PreferredMidiProtocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointReceiveJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointReceiveJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointTransmitJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointTransmitJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ UnwrapMidiStreamConfigurationRequestReceivedEventArgs(Local value); + }; + + Persistent MidiStreamConfigurationRequestReceivedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiStreamConfigurationRequestReceivedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ UnwrapMidiStreamConfigurationRequestReceivedEventArgs(Local value) { + return MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiStreamConfigurationRequestReceivedEventArgs(Local exports) { + MidiStreamConfigurationRequestReceivedEventArgs::Init(exports); + } + + class MidiStreamConfigurationRequestedSettings : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiStreamConfigurationRequestedSettings").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMinor").ToLocalChecked(), SpecificationVersionMinorGetter, SpecificationVersionMinorSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMajor").ToLocalChecked(), SpecificationVersionMajorGetter, SpecificationVersionMajorSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointTransmitJitterReductionTimestamps").ToLocalChecked(), RequestEndpointTransmitJitterReductionTimestampsGetter, RequestEndpointTransmitJitterReductionTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointReceiveJitterReductionTimestamps").ToLocalChecked(), RequestEndpointReceiveJitterReductionTimestampsGetter, RequestEndpointReceiveJitterReductionTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preferredMidiProtocol").ToLocalChecked(), PreferredMidiProtocolGetter, PreferredMidiProtocolSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiStreamConfigurationRequestedSettings").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiStreamConfigurationRequestedSettings *wrapperInstance = new MidiStreamConfigurationRequestedSettings(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiStreamConfigurationRequestedSettings(winRtInstance)); + } + + + + + + static void SpecificationVersionMinorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMinor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMinorSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->SpecificationVersionMinor = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SpecificationVersionMajorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMajor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMajorSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->SpecificationVersionMajor = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void RequestEndpointTransmitJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointTransmitJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointTransmitJitterReductionTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->RequestEndpointTransmitJitterReductionTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void RequestEndpointReceiveJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointReceiveJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointReceiveJitterReductionTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->RequestEndpointReceiveJitterReductionTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreferredMidiProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiProtocol result = wrapper->_instance->PreferredMidiProtocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreferredMidiProtocolSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiProtocol winRtValue = static_cast<::Windows::Devices::Midi2::MidiProtocol>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->PreferredMidiProtocol = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ UnwrapMidiStreamConfigurationRequestedSettings(Local value); + }; + + Persistent MidiStreamConfigurationRequestedSettings::s_constructorTemplate; + + v8::Local WrapMidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiStreamConfigurationRequestedSettings::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ UnwrapMidiStreamConfigurationRequestedSettings(Local value) { + return MidiStreamConfigurationRequestedSettings::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiStreamConfigurationRequestedSettings(Local exports) { + MidiStreamConfigurationRequestedSettings::Init(exports); + } + + class MidiStreamMessageBuilder : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiStreamMessageBuilder").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "buildEndpointDiscoveryMessage", BuildEndpointDiscoveryMessage); + Nan::SetMethod(constructor, "buildEndpointInfoNotificationMessage", BuildEndpointInfoNotificationMessage); + Nan::SetMethod(constructor, "buildDeviceIdentityNotificationMessage", BuildDeviceIdentityNotificationMessage); + Nan::SetMethod(constructor, "buildEndpointNameNotificationMessages", BuildEndpointNameNotificationMessages); + Nan::SetMethod(constructor, "buildProductInstanceIdNotificationMessages", BuildProductInstanceIdNotificationMessages); + Nan::SetMethod(constructor, "parseEndpointNameNotificationMessages", ParseEndpointNameNotificationMessages); + Nan::SetMethod(constructor, "parseProductInstanceIdNotificationMessages", ParseProductInstanceIdNotificationMessages); + Nan::SetMethod(constructor, "buildStreamConfigurationRequestMessage", BuildStreamConfigurationRequestMessage); + Nan::SetMethod(constructor, "buildStreamConfigurationNotificationMessage", BuildStreamConfigurationNotificationMessage); + Nan::SetMethod(constructor, "buildFunctionBlockDiscoveryMessage", BuildFunctionBlockDiscoveryMessage); + Nan::SetMethod(constructor, "buildFunctionBlockInfoNotificationMessage", BuildFunctionBlockInfoNotificationMessage); + Nan::SetMethod(constructor, "buildFunctionBlockNameNotificationMessages", BuildFunctionBlockNameNotificationMessages); + Nan::SetMethod(constructor, "parseFunctionBlockNameNotificationMessages", ParseFunctionBlockNameNotificationMessages); + + + Nan::Set(exports, Nan::New("MidiStreamMessageBuilder").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamMessageBuilder^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiStreamMessageBuilder *wrapperInstance = new MidiStreamMessageBuilder(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamMessageBuilder^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiStreamMessageBuilder(winRtInstance)); + } + + + + + + static void BuildEndpointDiscoveryMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests arg3 = static_cast<::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests>(Nan::To(info[3]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildEndpointDiscoveryMessage(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildEndpointInfoNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 9 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsBoolean() + && info[4]->IsInt32() + && info[5]->IsBoolean() + && info[6]->IsBoolean() + && info[7]->IsBoolean() + && info[8]->IsBoolean()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + bool arg3 = Nan::To(info[3]).FromMaybe(false); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + bool arg5 = Nan::To(info[5]).FromMaybe(false); + bool arg6 = Nan::To(info[6]).FromMaybe(false); + bool arg7 = Nan::To(info[7]).FromMaybe(false); + bool arg8 = Nan::To(info[8]).FromMaybe(false); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildEndpointInfoNotificationMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildDeviceIdentityNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 12 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32() + && info[10]->IsInt32() + && info[11]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + unsigned char arg10 = static_cast(Nan::To(info[10]).FromMaybe(0)); + unsigned char arg11 = static_cast(Nan::To(info[11]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildDeviceIdentityNotificationMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildEndpointNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsString()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1]))); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildEndpointNameNotificationMessages(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildProductInstanceIdNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsString()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1]))); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildProductInstanceIdNotificationMessages(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ParseEndpointNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::ParseEndpointNameNotificationMessages(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ParseProductInstanceIdNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::ParseProductInstanceIdNotificationMessages(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildStreamConfigurationRequestMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsBoolean() + && info[3]->IsBoolean()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + bool arg2 = Nan::To(info[2]).FromMaybe(false); + bool arg3 = Nan::To(info[3]).FromMaybe(false); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildStreamConfigurationRequestMessage(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildStreamConfigurationNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsBoolean() + && info[3]->IsBoolean()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + bool arg2 = Nan::To(info[2]).FromMaybe(false); + bool arg3 = Nan::To(info[3]).FromMaybe(false); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildStreamConfigurationNotificationMessage(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFunctionBlockDiscoveryMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests arg2 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests>(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildFunctionBlockDiscoveryMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFunctionBlockInfoNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && info[1]->IsBoolean() + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + bool arg1 = Nan::To(info[1]).FromMaybe(false); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockUIHint arg3 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockUIHint>(Nan::To(info[3]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockMidi10 arg4 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockMidi10>(Nan::To(info[4]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockDirection arg5 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockDirection>(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildFunctionBlockInfoNotificationMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFunctionBlockNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsString()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[2]))); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildFunctionBlockNameNotificationMessages(arg0, arg1, arg2); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ParseFunctionBlockNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::ParseFunctionBlockNameNotificationMessages(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ UnwrapMidiStreamMessageBuilder(Local value); + }; + + Persistent MidiStreamMessageBuilder::s_constructorTemplate; + + v8::Local WrapMidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiStreamMessageBuilder::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ UnwrapMidiStreamMessageBuilder(Local value) { + return MidiStreamMessageBuilder::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiStreamMessageBuilder(Local exports) { + MidiStreamMessageBuilder::Init(exports); + } + + class MidiUniqueId : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiUniqueId").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte4").ToLocalChecked(), Byte4Getter, Byte4Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte3").ToLocalChecked(), Byte3Getter, Byte3Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte2").ToLocalChecked(), Byte2Getter, Byte2Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte1").ToLocalChecked(), Byte1Getter, Byte1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("asCombined28BitValue").ToLocalChecked(), AsCombined28BitValueGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isBroadcast").ToLocalChecked(), IsBroadcastGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isReserved").ToLocalChecked(), IsReservedGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createBroadcast", CreateBroadcast); + Nan::SetMethod(constructor, "createRandom", CreateRandom); + Nan::SetAccessor(constructor, Nan::New("labelFull").ToLocalChecked(), LabelFullGetter); + Nan::SetAccessor(constructor, Nan::New("labelShort").ToLocalChecked(), LabelShortGetter); + + + Nan::Set(exports, Nan::New("MidiUniqueId").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiUniqueId^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiUniqueId^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsUint32()) + { + try { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiUniqueId(arg0); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsInt32() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32()) + { + try { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiUniqueId(arg0,arg1,arg2,arg3); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiUniqueId(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiUniqueId *wrapperInstance = new MidiUniqueId(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiUniqueId^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiUniqueId^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiUniqueId(winRtInstance)); + } + + + + + + static void CreateBroadcast(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiUniqueId^ result; + result = ::Windows::Devices::Midi2::MidiUniqueId::CreateBroadcast(); + info.GetReturnValue().Set(WrapMidiUniqueId(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void CreateRandom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiUniqueId^ result; + result = ::Windows::Devices::Midi2::MidiUniqueId::CreateRandom(); + info.GetReturnValue().Set(WrapMidiUniqueId(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Byte4Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte4; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte4Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte4 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Byte3Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte3; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte3Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte3 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Byte2Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte2; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte2Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte2 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Byte1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void AsCombined28BitValueGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->AsCombined28BitValue; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsBroadcastGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsBroadcast; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsReservedGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsReserved; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void LabelFullGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiUniqueId::LabelFull; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void LabelShortGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiUniqueId::LabelShort; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiUniqueId^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiUniqueId^ UnwrapMidiUniqueId(Local value); + }; + + Persistent MidiUniqueId::s_constructorTemplate; + + v8::Local WrapMidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiUniqueId::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiUniqueId^ UnwrapMidiUniqueId(Local value) { + return MidiUniqueId::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiUniqueId(Local exports) { + MidiUniqueId::Init(exports); + } + + class MidiVirtualEndpointDevice : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiVirtualEndpointDevice").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "updateFunctionBlock", UpdateFunctionBlock); + Nan::SetPrototypeMethod(localRef, "updateEndpointName", UpdateEndpointName); + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("suppressHandledMessages").ToLocalChecked(), SuppressHandledMessagesGetter, SuppressHandledMessagesSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceDefinition").ToLocalChecked(), DeviceDefinitionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocks").ToLocalChecked(), FunctionBlocksGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiVirtualEndpointDevice").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDevice^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiVirtualEndpointDevice *wrapperInstance = new MidiVirtualEndpointDevice(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDevice^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiVirtualEndpointDevice(winRtInstance)); + } + + + static void UpdateFunctionBlock(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiFunctionBlock^ arg0 = UnwrapMidiFunctionBlock(info[0]); + + wrapper->_instance->UpdateFunctionBlock(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void UpdateEndpointName(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + wrapper->_instance->UpdateEndpointName(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuppressHandledMessagesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SuppressHandledMessages; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuppressHandledMessagesSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SuppressHandledMessages = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceDefinitionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ result = wrapper->_instance->DeviceDefinition; + info.GetReturnValue().Set(WrapMidiVirtualEndpointDeviceDefinition(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView^ result = wrapper->_instance->FunctionBlocks; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper::CreateMapViewWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + }, + [](::Windows::Devices::Midi2::MidiFunctionBlock^ val) -> Local { + return WrapMidiFunctionBlock(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"streamConfigurationRequestReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->StreamConfigurationRequestReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^, ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ arg0, ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiVirtualEndpointDevice(arg0); + wrappedArg1 = WrapMidiStreamConfigurationRequestReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"streamConfigurationRequestReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"streamConfigurationRequestReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + wrapper->_instance->StreamConfigurationRequestReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ UnwrapMidiVirtualEndpointDevice(Local value); + }; + + Persistent MidiVirtualEndpointDevice::s_constructorTemplate; + + v8::Local WrapMidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiVirtualEndpointDevice::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ UnwrapMidiVirtualEndpointDevice(Local value) { + return MidiVirtualEndpointDevice::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiVirtualEndpointDevice(Local exports) { + MidiVirtualEndpointDevice::Init(exports); + } + + class MidiVirtualEndpointDeviceDefinition : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiVirtualEndpointDeviceDefinition").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedDescription").ToLocalChecked(), TransportSuppliedDescriptionGetter, TransportSuppliedDescriptionSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsSendingJRTimestamps").ToLocalChecked(), SupportsSendingJRTimestampsGetter, SupportsSendingJRTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsReceivingJRTimestamps").ToLocalChecked(), SupportsReceivingJRTimestampsGetter, SupportsReceivingJRTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi2ProtocolMessages").ToLocalChecked(), SupportsMidi2ProtocolMessagesGetter, SupportsMidi2ProtocolMessagesSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi1ProtocolMessages").ToLocalChecked(), SupportsMidi1ProtocolMessagesGetter, SupportsMidi1ProtocolMessagesSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointProductInstanceId").ToLocalChecked(), EndpointProductInstanceIdGetter, EndpointProductInstanceIdSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointName").ToLocalChecked(), EndpointNameGetter, EndpointNameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyMsb").ToLocalChecked(), DeviceFamilyMsbGetter, DeviceFamilyMsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyModelMsb").ToLocalChecked(), DeviceFamilyModelMsbGetter, DeviceFamilyModelMsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyModelLsb").ToLocalChecked(), DeviceFamilyModelLsbGetter, DeviceFamilyModelLsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyLsb").ToLocalChecked(), DeviceFamilyLsbGetter, DeviceFamilyLsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("areFunctionBlocksStatic").ToLocalChecked(), AreFunctionBlocksStaticGetter, AreFunctionBlocksStaticSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceManufacturerSystemExclusiveId").ToLocalChecked(), DeviceManufacturerSystemExclusiveIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocks").ToLocalChecked(), FunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("softwareRevisionLevel").ToLocalChecked(), SoftwareRevisionLevelGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiVirtualEndpointDeviceDefinition").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiVirtualEndpointDeviceDefinition *wrapperInstance = new MidiVirtualEndpointDeviceDefinition(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiVirtualEndpointDeviceDefinition(winRtInstance)); + } + + + + + + static void TransportSuppliedDescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedDescription; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedDescriptionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->TransportSuppliedDescription = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsSendingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsSendingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsSendingJRTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsSendingJRTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsReceivingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsReceivingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsReceivingJRTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsReceivingJRTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsMidi2ProtocolMessagesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi2ProtocolMessages; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi2ProtocolMessagesSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsMidi2ProtocolMessages = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsMidi1ProtocolMessagesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi1ProtocolMessages; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi1ProtocolMessagesSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsMidi1ProtocolMessages = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void EndpointProductInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointProductInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointProductInstanceIdSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->EndpointProductInstanceId = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void EndpointNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointNameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->EndpointName = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyMsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyMsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyModelMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyModelMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyModelMsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyModelMsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyModelLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyModelLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyModelLsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyModelLsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyLsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyLsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void AreFunctionBlocksStaticGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->AreFunctionBlocksStatic; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void AreFunctionBlocksStaticSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->AreFunctionBlocksStatic = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceManufacturerSystemExclusiveIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector^ result = wrapper->_instance->DeviceManufacturerSystemExclusiveId; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiFunctionBlock^>^ result = wrapper->_instance->FunctionBlocks; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiFunctionBlock^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiFunctionBlock^ val) -> Local { + return WrapMidiFunctionBlock(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiFunctionBlock^ { + return UnwrapMidiFunctionBlock(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SoftwareRevisionLevelGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector^ result = wrapper->_instance->SoftwareRevisionLevel; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ UnwrapMidiVirtualEndpointDeviceDefinition(Local value); + }; + + Persistent MidiVirtualEndpointDeviceDefinition::s_constructorTemplate; + + v8::Local WrapMidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiVirtualEndpointDeviceDefinition::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ UnwrapMidiVirtualEndpointDeviceDefinition(Local value) { + return MidiVirtualEndpointDeviceDefinition::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiVirtualEndpointDeviceDefinition(Local exports) { + MidiVirtualEndpointDeviceDefinition::Init(exports); + } + + +} } } } + +NAN_MODULE_INIT(init) { + // We ignore failures for now since it probably means that + // the initialization already happened for STA, and that's cool + + CoInitializeEx(nullptr, COINIT_MULTITHREADED); + + /* + if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"error in CoInitializeEx()"))); + return; + } + */ + + NodeRT::Windows::Devices::Midi2::InitMidi1ChannelVoiceMessageStatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidi2ChannelVoiceMessageStatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationFiltersEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationSortOrderEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDevicePurposeEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDiscoveryRequestsEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointNativeDataFormatEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockDirectionEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockDiscoveryRequestsEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockMidi10Enum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockUIHintEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupTerminalBlockDirectionEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupTerminalBlockProtocolEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageTypeEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiPacketTypeEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiProtocolEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiSendMessageResultsEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceConfigurationResponseStatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiSystemExclusive8StatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitIMidiEndpointConnectionSettings(target); + NodeRT::Windows::Devices::Midi2::InitIMidiEndpointConnectionSource(target); + NodeRT::Windows::Devices::Midi2::InitIMidiEndpointMessageProcessingPlugin(target); + NodeRT::Windows::Devices::Midi2::InitIMidiMessageReceivedEventSource(target); + NodeRT::Windows::Devices::Midi2::InitIMidiServiceMessageProcessingPluginConfiguration(target); + NodeRT::Windows::Devices::Midi2::InitIMidiServiceTransportPluginConfiguration(target); + NodeRT::Windows::Devices::Midi2::InitIMidiUniversalPacket(target); + NodeRT::Windows::Devices::Midi2::InitMidiChannel(target); + NodeRT::Windows::Devices::Midi2::InitMidiChannelEndpointListener(target); + NodeRT::Windows::Devices::Midi2::InitMidiClock(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointConnection(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformation(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationAddedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationRemovedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationUpdatedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceWatcher(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlock(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroup(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupEndpointListener(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupTerminalBlock(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage128(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage32(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage64(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage96(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageBuilder(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageConverter(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageReceivedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageTypeEndpointListener(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageUtility(target); + NodeRT::Windows::Devices::Midi2::InitMidiService(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceConfigurationResponse(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceLoopbackEndpointCreationResult(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceLoopbackEndpointDefinition(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceMessageProcessingPluginInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiServicePingResponse(target); + NodeRT::Windows::Devices::Midi2::InitMidiServicePingResponseSummary(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceSessionConnectionInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceSessionInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceTransportPluginInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiSession(target); + NodeRT::Windows::Devices::Midi2::InitMidiSessionSettings(target); + NodeRT::Windows::Devices::Midi2::InitMidiStreamConfigurationRequestReceivedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiStreamConfigurationRequestedSettings(target); + NodeRT::Windows::Devices::Midi2::InitMidiStreamMessageBuilder(target); + NodeRT::Windows::Devices::Midi2::InitMidiUniqueId(target); + NodeRT::Windows::Devices::Midi2::InitMidiVirtualEndpointDevice(target); + NodeRT::Windows::Devices::Midi2::InitMidiVirtualEndpointDeviceDefinition(target); + + + NodeRT::Utils::RegisterNameSpace("Windows.Devices.Midi2", target); +} + + + +NODE_MODULE(binding, init) diff --git a/build/electron-projection/projection3/windows.devices.midi2/binding.gyp b/build/electron-projection/projection3/windows.devices.midi2/binding.gyp new file mode 100644 index 000000000..6a1df7646 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/binding.gyp @@ -0,0 +1,82 @@ +{ + "variables": { + "WIN_VER": "v10", + "USE_ADDITIONAL_WINMD": "true" + }, + "includes": ["common.gypi"], + "targets": [{ + "target_name": "binding", + "sources": [], + "include_dirs": [ + " + + + + Debug + x64 + + + Release + x64 + + + + {34BB8FF6-AEB9-6A36-29FA-2760D66F05C8} + Win32Proj + binding + true + x64 + 10.0.22621.0 + + + + DynamicLibrary + + + v143 + + + + + + + + + + $(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\ + true + $(Configuration)\obj\$(ProjectName)\ + false + true + $(SolutionDir)$(Configuration)\ + .node + .node + .node + .node + $(ProjectName) + $(OutDir)\$(ProjectName).node + + + + C:\Users\peteb\.electron-gyp\29.1.0\include\node;C:\Users\peteb\.electron-gyp\29.1.0\src;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\config;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\openssl\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\uv\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\zlib;C:\Users\peteb\.electron-gyp\29.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + /Zc:__cplusplus -std:c++17 /ZW %(AdditionalOptions) + %ProgramFiles(x86)%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/10.0.20348.0;$(VCToolsInstallDir)/lib/x86/store/references;%MIDI_REPO_ROOT%/build/release/api/;%ProgramFiles%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles%/Windows Kits/10/Include/x64/um;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles(x86)%/Windows Kits/10/Include/x64/um + EnableFastChecks + true + OldStyle + 4609;4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings) + Sync + false + true + false + Disabled + NotUsing + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;ELECTRON_ENSURE_CONFIG_GYPI;USING_ELECTRON_CONFIG_GYPI;V8_COMPRESS_POINTERS;V8_COMPRESS_POINTERS_IN_SHARED_CAGE;V8_ENABLE_SANDBOX;V8_31BIT_SMIS_ON_64BIT_ARCH;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;OPENSSL_NO_ASM;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + true + true + false + Level3 + true + + + /LTCG:INCREMENTAL %(AdditionalOptions) + + + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\peteb\\.electron-gyp\\29.1.0\\x64\\node.lib";runtimeobject.lib + /LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions) + node.exe;%(DelayLoadDLLs) + true + true + true + $(OutDir)$(ProjectName).node + true + .node + MachineX64 + + + C:\Users\peteb\.electron-gyp\29.1.0\include\node;C:\Users\peteb\.electron-gyp\29.1.0\src;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\config;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\openssl\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\uv\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\zlib;C:\Users\peteb\.electron-gyp\29.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;ELECTRON_ENSURE_CONFIG_GYPI;USING_ELECTRON_CONFIG_GYPI;V8_COMPRESS_POINTERS;V8_COMPRESS_POINTERS_IN_SHARED_CAGE;V8_ENABLE_SANDBOX;V8_31BIT_SMIS_ON_64BIT_ARCH;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;OPENSSL_NO_ASM;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + C:\Users\peteb\.electron-gyp\29.1.0\include\node;C:\Users\peteb\.electron-gyp\29.1.0\src;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\config;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\openssl\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\uv\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\zlib;C:\Users\peteb\.electron-gyp\29.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + /Zc:__cplusplus -std:c++17 /ZW %(AdditionalOptions) + %ProgramFiles(x86)%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/10.0.20348.0;$(VCToolsInstallDir)/lib/x86/store/references;%MIDI_REPO_ROOT%/build/release/api/;%ProgramFiles%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles%/Windows Kits/10/Include/x64/um;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles(x86)%/Windows Kits/10/Include/x64/um + true + OldStyle + 4609;4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings) + Sync + Speed + true + AnySuitable + true + true + true + Full + NotUsing + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;ELECTRON_ENSURE_CONFIG_GYPI;USING_ELECTRON_CONFIG_GYPI;V8_COMPRESS_POINTERS;V8_COMPRESS_POINTERS_IN_SHARED_CAGE;V8_ENABLE_SANDBOX;V8_31BIT_SMIS_ON_64BIT_ARCH;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;OPENSSL_NO_ASM;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions) + MultiThreadedDLL + false + true + true + false + Level3 + true + + + /LTCG:INCREMENTAL %(AdditionalOptions) + + + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\peteb\\.electron-gyp\\29.1.0\\x64\\node.lib";runtimeobject.lib + /LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions) + node.exe;%(DelayLoadDLLs) + true + true + true + $(OutDir)$(ProjectName).node + true + .node + MachineX64 + + + C:\Users\peteb\.electron-gyp\29.1.0\include\node;C:\Users\peteb\.electron-gyp\29.1.0\src;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\config;C:\Users\peteb\.electron-gyp\29.1.0\deps\openssl\openssl\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\uv\include;C:\Users\peteb\.electron-gyp\29.1.0\deps\zlib;C:\Users\peteb\.electron-gyp\29.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;ELECTRON_ENSURE_CONFIG_GYPI;USING_ELECTRON_CONFIG_GYPI;V8_COMPRESS_POINTERS;V8_COMPRESS_POINTERS_IN_SHARED_CAGE;V8_ENABLE_SANDBOX;V8_31BIT_SMIS_ON_64BIT_ARCH;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;OPENSSL_NO_ASM;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + + + + $(IntDir)\_nodert_generated.obj + + + $(IntDir)\NodeRtUtils.obj + + + $(IntDir)\OpaqueWrapper.obj + + + $(IntDir)\CollectionsConverterUtils.obj + + + + + + + diff --git a/build/electron-projection/projection3/windows.devices.midi2/build/binding.vcxproj.filters b/build/electron-projection/projection3/windows.devices.midi2/build/binding.vcxproj.filters new file mode 100644 index 000000000..74083f1c4 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/build/binding.vcxproj.filters @@ -0,0 +1,79 @@ + + + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {E5D29F2B-0177-9942-CA95-0FF700094F89} + + + {93C774D4-5E46-33D7-FB89-AC2082D09F63} + + + {87566BA0-CA33-1144-65F5-087C5F9D6C20} + + + {84E6FEBA-825D-6EBF-DAAC-F202DA6E3F7D} + + + {3C4FBFE8-47F2-77F9-3EE7-49F8E7608B90} + + + {E3686288-AF21-E99D-46CF-28A44CD62AB0} + + + {D5519164-BF26-36DA-740B-76CEFC1827F4} + + + {B08A7188-80A0-87EA-04BB-C44139582C6B} + + + {8B2D918A-C1E7-C36E-BB8A-E40C5D44B587} + + + {FE1B0527-2C27-7128-F090-3F947DD4ACA2} + + + {56DF7A98-063D-FB9D-485C-089023B4C16A} + + + {77348C0E-2034-7791-74D5-63C077DF5A3B} + + + {8CDEE807-BC53-E450-C8B8-4DEBB66742D4} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + + + .. + + + .. + + + .. + + + .. + + + D:\peteb\Documents\GitHub\microsoft\midi\build\electron-projection\projection3\windows.devices.midi2\node_modules\node-gyp\src + + + .. + + + diff --git a/build/electron-projection/projection3/windows.devices.midi2/build/config.gypi b/build/electron-projection/projection3/windows.devices.midi2/build/config.gypi new file mode 100644 index 000000000..ba5b063c3 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/build/config.gypi @@ -0,0 +1,423 @@ +# Do not edit. File was generated by node-gyp's "configure" step +{ + "target_defaults": { + "cflags": [], + "default_configuration": "Release", + "defines": [], + "include_dirs": [], + "libraries": [], + "msbuild_toolset": "v143", + "msvs_windows_target_platform_version": "10.0.22621.0" + }, + "variables": { + "arm_fpu": "neon", + "asan": 0, + "build_v8_with_gn": "false", + "built_with_electron": 1, + "coverage": "false", + "dcheck_always_on": 0, + "debug_nghttp2": "false", + "debug_node": "false", + "enable_lto": "false", + "enable_pgo_generate": "false", + "enable_pgo_use": "false", + "error_on_warn": "false", + "force_dynamic_crt": 0, + "host_arch": "x64", + "icu_data_in": "..\\..\\deps\\icu-tmp\\icudt73l.dat", + "icu_endianness": "l", + "icu_gyp_path": "tools/icu/icu-generic.gyp", + "icu_path": "deps/icu-small", + "icu_small": "false", + "icu_ver_major": "73", + "is_debug": 0, + "libdir": "lib", + "llvm_version": "0.0", + "napi_build_version": "9", + "node_builtin_shareable_builtins": [ + "deps/cjs-module-lexer/lexer.js", + "deps/cjs-module-lexer/dist/lexer.js", + "deps/undici/undici.js" + ], + "node_byteorder": "little", + "node_debug_lib": "false", + "node_enable_d8": "false", + "node_enable_v8_vtunejit": "false", + "node_fipsinstall": "false", + "node_install_corepack": "true", + "node_install_npm": "true", + "node_library_files": [ + "lib/_http_agent.js", + "lib/_http_client.js", + "lib/_http_common.js", + "lib/_http_incoming.js", + "lib/_http_outgoing.js", + "lib/_http_server.js", + "lib/_stream_duplex.js", + "lib/_stream_passthrough.js", + "lib/_stream_readable.js", + "lib/_stream_transform.js", + "lib/_stream_wrap.js", + "lib/_stream_writable.js", + "lib/_tls_common.js", + "lib/_tls_wrap.js", + "lib/assert.js", + "lib/assert/strict.js", + "lib/async_hooks.js", + "lib/buffer.js", + "lib/child_process.js", + "lib/cluster.js", + "lib/console.js", + "lib/constants.js", + "lib/crypto.js", + "lib/dgram.js", + "lib/diagnostics_channel.js", + "lib/dns.js", + "lib/dns/promises.js", + "lib/domain.js", + "lib/events.js", + "lib/fs.js", + "lib/fs/promises.js", + "lib/http.js", + "lib/http2.js", + "lib/https.js", + "lib/inspector.js", + "lib/inspector/promises.js", + "lib/internal/abort_controller.js", + "lib/internal/assert.js", + "lib/internal/assert/assertion_error.js", + "lib/internal/assert/calltracker.js", + "lib/internal/async_hooks.js", + "lib/internal/blob.js", + "lib/internal/blocklist.js", + "lib/internal/bootstrap/node.js", + "lib/internal/bootstrap/realm.js", + "lib/internal/bootstrap/switches/does_not_own_process_state.js", + "lib/internal/bootstrap/switches/does_own_process_state.js", + "lib/internal/bootstrap/switches/is_main_thread.js", + "lib/internal/bootstrap/switches/is_not_main_thread.js", + "lib/internal/bootstrap/web/exposed-wildcard.js", + "lib/internal/bootstrap/web/exposed-window-or-worker.js", + "lib/internal/buffer.js", + "lib/internal/child_process.js", + "lib/internal/child_process/serialization.js", + "lib/internal/cli_table.js", + "lib/internal/cluster/child.js", + "lib/internal/cluster/primary.js", + "lib/internal/cluster/round_robin_handle.js", + "lib/internal/cluster/shared_handle.js", + "lib/internal/cluster/utils.js", + "lib/internal/cluster/worker.js", + "lib/internal/console/constructor.js", + "lib/internal/console/global.js", + "lib/internal/constants.js", + "lib/internal/crypto/aes.js", + "lib/internal/crypto/certificate.js", + "lib/internal/crypto/cfrg.js", + "lib/internal/crypto/cipher.js", + "lib/internal/crypto/diffiehellman.js", + "lib/internal/crypto/ec.js", + "lib/internal/crypto/hash.js", + "lib/internal/crypto/hashnames.js", + "lib/internal/crypto/hkdf.js", + "lib/internal/crypto/keygen.js", + "lib/internal/crypto/keys.js", + "lib/internal/crypto/mac.js", + "lib/internal/crypto/pbkdf2.js", + "lib/internal/crypto/random.js", + "lib/internal/crypto/rsa.js", + "lib/internal/crypto/scrypt.js", + "lib/internal/crypto/sig.js", + "lib/internal/crypto/util.js", + "lib/internal/crypto/webcrypto.js", + "lib/internal/crypto/webidl.js", + "lib/internal/crypto/x509.js", + "lib/internal/debugger/inspect.js", + "lib/internal/debugger/inspect_client.js", + "lib/internal/debugger/inspect_repl.js", + "lib/internal/dgram.js", + "lib/internal/dns/callback_resolver.js", + "lib/internal/dns/promises.js", + "lib/internal/dns/utils.js", + "lib/internal/encoding.js", + "lib/internal/error_serdes.js", + "lib/internal/errors.js", + "lib/internal/event_target.js", + "lib/internal/events/symbols.js", + "lib/internal/file.js", + "lib/internal/fixed_queue.js", + "lib/internal/freelist.js", + "lib/internal/freeze_intrinsics.js", + "lib/internal/fs/cp/cp-sync.js", + "lib/internal/fs/cp/cp.js", + "lib/internal/fs/dir.js", + "lib/internal/fs/promises.js", + "lib/internal/fs/read/context.js", + "lib/internal/fs/recursive_watch.js", + "lib/internal/fs/rimraf.js", + "lib/internal/fs/streams.js", + "lib/internal/fs/sync.js", + "lib/internal/fs/sync_write_stream.js", + "lib/internal/fs/utils.js", + "lib/internal/fs/watchers.js", + "lib/internal/heap_utils.js", + "lib/internal/histogram.js", + "lib/internal/http.js", + "lib/internal/http2/compat.js", + "lib/internal/http2/core.js", + "lib/internal/http2/util.js", + "lib/internal/idna.js", + "lib/internal/inspector_async_hook.js", + "lib/internal/js_stream_socket.js", + "lib/internal/legacy/processbinding.js", + "lib/internal/linkedlist.js", + "lib/internal/main/check_syntax.js", + "lib/internal/main/embedding.js", + "lib/internal/main/eval_stdin.js", + "lib/internal/main/eval_string.js", + "lib/internal/main/inspect.js", + "lib/internal/main/mksnapshot.js", + "lib/internal/main/print_help.js", + "lib/internal/main/prof_process.js", + "lib/internal/main/repl.js", + "lib/internal/main/run_main_module.js", + "lib/internal/main/test_runner.js", + "lib/internal/main/watch_mode.js", + "lib/internal/main/worker_thread.js", + "lib/internal/mime.js", + "lib/internal/modules/cjs/loader.js", + "lib/internal/modules/esm/assert.js", + "lib/internal/modules/esm/create_dynamic_module.js", + "lib/internal/modules/esm/fetch_module.js", + "lib/internal/modules/esm/formats.js", + "lib/internal/modules/esm/get_format.js", + "lib/internal/modules/esm/handle_process_exit.js", + "lib/internal/modules/esm/hooks.js", + "lib/internal/modules/esm/initialize_import_meta.js", + "lib/internal/modules/esm/load.js", + "lib/internal/modules/esm/loader.js", + "lib/internal/modules/esm/module_job.js", + "lib/internal/modules/esm/module_map.js", + "lib/internal/modules/esm/package_config.js", + "lib/internal/modules/esm/resolve.js", + "lib/internal/modules/esm/shared_constants.js", + "lib/internal/modules/esm/translators.js", + "lib/internal/modules/esm/utils.js", + "lib/internal/modules/esm/worker.js", + "lib/internal/modules/helpers.js", + "lib/internal/modules/package_json_reader.js", + "lib/internal/modules/run_main.js", + "lib/internal/net.js", + "lib/internal/options.js", + "lib/internal/per_context/domexception.js", + "lib/internal/per_context/messageport.js", + "lib/internal/per_context/primordials.js", + "lib/internal/perf/event_loop_delay.js", + "lib/internal/perf/event_loop_utilization.js", + "lib/internal/perf/nodetiming.js", + "lib/internal/perf/observe.js", + "lib/internal/perf/performance.js", + "lib/internal/perf/performance_entry.js", + "lib/internal/perf/resource_timing.js", + "lib/internal/perf/timerify.js", + "lib/internal/perf/usertiming.js", + "lib/internal/perf/utils.js", + "lib/internal/policy/manifest.js", + "lib/internal/policy/sri.js", + "lib/internal/priority_queue.js", + "lib/internal/process/esm_loader.js", + "lib/internal/process/execution.js", + "lib/internal/process/per_thread.js", + "lib/internal/process/permission.js", + "lib/internal/process/policy.js", + "lib/internal/process/pre_execution.js", + "lib/internal/process/promises.js", + "lib/internal/process/report.js", + "lib/internal/process/signal.js", + "lib/internal/process/task_queues.js", + "lib/internal/process/warning.js", + "lib/internal/process/worker_thread_only.js", + "lib/internal/promise_hooks.js", + "lib/internal/querystring.js", + "lib/internal/readline/callbacks.js", + "lib/internal/readline/emitKeypressEvents.js", + "lib/internal/readline/interface.js", + "lib/internal/readline/promises.js", + "lib/internal/readline/utils.js", + "lib/internal/repl.js", + "lib/internal/repl/await.js", + "lib/internal/repl/history.js", + "lib/internal/repl/utils.js", + "lib/internal/socket_list.js", + "lib/internal/socketaddress.js", + "lib/internal/source_map/prepare_stack_trace.js", + "lib/internal/source_map/source_map.js", + "lib/internal/source_map/source_map_cache.js", + "lib/internal/stream_base_commons.js", + "lib/internal/streams/add-abort-signal.js", + "lib/internal/streams/buffer_list.js", + "lib/internal/streams/compose.js", + "lib/internal/streams/destroy.js", + "lib/internal/streams/duplex.js", + "lib/internal/streams/duplexify.js", + "lib/internal/streams/end-of-stream.js", + "lib/internal/streams/from.js", + "lib/internal/streams/lazy_transform.js", + "lib/internal/streams/legacy.js", + "lib/internal/streams/operators.js", + "lib/internal/streams/passthrough.js", + "lib/internal/streams/pipeline.js", + "lib/internal/streams/readable.js", + "lib/internal/streams/state.js", + "lib/internal/streams/transform.js", + "lib/internal/streams/utils.js", + "lib/internal/streams/writable.js", + "lib/internal/structured_clone.js", + "lib/internal/test/binding.js", + "lib/internal/test/transfer.js", + "lib/internal/test_runner/coverage.js", + "lib/internal/test_runner/harness.js", + "lib/internal/test_runner/mock/mock.js", + "lib/internal/test_runner/mock/mock_timers.js", + "lib/internal/test_runner/reporter/dot.js", + "lib/internal/test_runner/reporter/junit.js", + "lib/internal/test_runner/reporter/spec.js", + "lib/internal/test_runner/reporter/tap.js", + "lib/internal/test_runner/reporter/v8-serializer.js", + "lib/internal/test_runner/runner.js", + "lib/internal/test_runner/test.js", + "lib/internal/test_runner/tests_stream.js", + "lib/internal/test_runner/utils.js", + "lib/internal/timers.js", + "lib/internal/tls/secure-context.js", + "lib/internal/tls/secure-pair.js", + "lib/internal/trace_events_async_hooks.js", + "lib/internal/tty.js", + "lib/internal/url.js", + "lib/internal/util.js", + "lib/internal/util/colors.js", + "lib/internal/util/comparisons.js", + "lib/internal/util/debuglog.js", + "lib/internal/util/embedding.js", + "lib/internal/util/inspect.js", + "lib/internal/util/inspector.js", + "lib/internal/util/iterable_weak_map.js", + "lib/internal/util/parse_args/parse_args.js", + "lib/internal/util/parse_args/utils.js", + "lib/internal/util/types.js", + "lib/internal/v8/startup_snapshot.js", + "lib/internal/v8_prof_polyfill.js", + "lib/internal/v8_prof_processor.js", + "lib/internal/validators.js", + "lib/internal/vm.js", + "lib/internal/vm/module.js", + "lib/internal/wasm_web_api.js", + "lib/internal/watch_mode/files_watcher.js", + "lib/internal/watchdog.js", + "lib/internal/webidl.js", + "lib/internal/webstreams/adapters.js", + "lib/internal/webstreams/compression.js", + "lib/internal/webstreams/encoding.js", + "lib/internal/webstreams/queuingstrategies.js", + "lib/internal/webstreams/readablestream.js", + "lib/internal/webstreams/transfer.js", + "lib/internal/webstreams/transformstream.js", + "lib/internal/webstreams/util.js", + "lib/internal/webstreams/writablestream.js", + "lib/internal/worker.js", + "lib/internal/worker/io.js", + "lib/internal/worker/js_transferable.js", + "lib/module.js", + "lib/net.js", + "lib/os.js", + "lib/path.js", + "lib/path/posix.js", + "lib/path/win32.js", + "lib/perf_hooks.js", + "lib/process.js", + "lib/punycode.js", + "lib/querystring.js", + "lib/readline.js", + "lib/readline/promises.js", + "lib/repl.js", + "lib/stream.js", + "lib/stream/consumers.js", + "lib/stream/promises.js", + "lib/stream/web.js", + "lib/string_decoder.js", + "lib/sys.js", + "lib/test.js", + "lib/test/reporters.js", + "lib/timers.js", + "lib/timers/promises.js", + "lib/tls.js", + "lib/trace_events.js", + "lib/tty.js", + "lib/url.js", + "lib/util.js", + "lib/util/types.js", + "lib/v8.js", + "lib/vm.js", + "lib/wasi.js", + "lib/worker_threads.js", + "lib/zlib.js" + ], + "node_module_version": 121, + "node_no_browser_globals": "false", + "node_prefix": "\\usr\\local", + "node_release_urlbase": "", + "node_shared": "false", + "node_shared_brotli": "false", + "node_shared_cares": "false", + "node_shared_http_parser": "false", + "node_shared_libuv": "false", + "node_shared_nghttp2": "false", + "node_shared_nghttp3": "false", + "node_shared_ngtcp2": "false", + "node_shared_openssl": "false", + "node_shared_zlib": "false", + "node_tag": "", + "node_target_type": "executable", + "node_use_bundled_v8": "true", + "node_use_node_code_cache": "false", + "node_use_node_snapshot": "false", + "node_use_openssl": "true", + "node_use_v8_platform": "true", + "node_with_ltcg": "true", + "node_without_node_options": "false", + "node_write_snapshot_as_array_literals": "true", + "openssl_is_fips": "false", + "openssl_no_asm": 1, + "openssl_quic": "true", + "ossfuzz": "false", + "shlib_suffix": "so.115", + "single_executable_application": "true", + "target_arch": "x64", + "using_electron_config_gypi": 1, + "v8_enable_31bit_smis_on_64bit_arch": 1, + "v8_enable_gdbjit": 0, + "v8_enable_hugepage": 0, + "v8_enable_i18n_support": 1, + "v8_enable_inspector": 1, + "v8_enable_javascript_promise_hooks": 1, + "v8_enable_lite_mode": 0, + "v8_enable_object_print": 1, + "v8_enable_pointer_compression": 1, + "v8_enable_sandbox": 1, + "v8_enable_shared_ro_heap": 0, + "v8_enable_webassembly": 1, + "v8_no_strict_aliasing": 1, + "v8_optimized_debug": 1, + "v8_promise_internal_field_count": 1, + "v8_random_seed": 0, + "v8_trace_maps": 0, + "v8_use_siphash": 1, + "want_separate_host_toolset": 1, + "nodedir": "C:\\Users\\peteb\\.electron-gyp\\29.1.0", + "standalone_static_library": 1, + "msbuild_path": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\MSBuild\\Current\\Bin\\MSBuild.exe", + "runtime": "electron", + "target": "29.1.0", + "build_from_source": "true" + } +} diff --git a/build/electron-projection/projection3/windows.devices.midi2/common.gypi b/build/electron-projection/projection3/windows.devices.midi2/common.gypi new file mode 100644 index 000000000..ef272e94f --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/common.gypi @@ -0,0 +1,26 @@ +{ + 'variables' : { + 'node_shared': 'true' + }, + 'target_defaults': { + 'default_configuration': 'Release', + 'configurations': { + 'Debug': { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'ExceptionHandling': 1, # /EHsc, + 'RuntimeLibrary': '3', # /MDd + } + } + }, + 'Release': { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'ExceptionHandling': 1, # /EHsc, + 'RuntimeLibrary': '2', # /MD + } + } + } + } + } +} \ No newline at end of file diff --git a/build/electron-projection/projection3/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.js b/build/electron-projection/projection3/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.js new file mode 100644 index 000000000..d888195b8 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.js @@ -0,0 +1,3030 @@ + +MidiMessageStruct = (function () { + var cls = function MidiMessageStruct() { + this.word0 = new Number(); + this.word1 = new Number(); + this.word2 = new Number(); + this.word3 = new Number(); + }; + return cls; +}) (); +exports.MidiMessageStruct = MidiMessageStruct; + + +_Midi1ChannelVoiceMessageStatus = function () { + this.noteOff = 0; + this.noteOn = 1; + this.polyPressure = 2; + this.controlChange = 3; + this.programChange = 4; + this.channelPressure = 5; + this.pitchBend = 6; +} +exports.Midi1ChannelVoiceMessageStatus = new _Midi1ChannelVoiceMessageStatus(); + +_Midi2ChannelVoiceMessageStatus = function () { + this.registeredPerNoteController = 0; + this.assignablePerNoteController = 1; + this.registeredController = 2; + this.assignableController = 3; + this.relativeRegisteredController = 4; + this.relativeAssignableController = 5; + this.perNotePitchBend = 6; + this.noteOff = 7; + this.noteOn = 8; + this.polyPressure = 9; + this.controlChange = 10; + this.programChange = 11; + this.channelPressure = 12; + this.pitchBend = 13; + this.perNoteManagement = 14; +} +exports.Midi2ChannelVoiceMessageStatus = new _Midi2ChannelVoiceMessageStatus(); + +_MidiEndpointDeviceInformationFilters = function () { + this.includeClientUmpNative = 0; + this.includeClientByteStreamNative = 1; + this.includeVirtualDeviceResponder = 2; + this.includeDiagnosticLoopback = 3; + this.includeDiagnosticPing = 4; + this.allTypicalEndpoints = 5; +} +exports.MidiEndpointDeviceInformationFilters = new _MidiEndpointDeviceInformationFilters(); + +_MidiEndpointDeviceInformationSortOrder = function () { + this.none = 0; + this.name = 1; + this.endpointDeviceId = 2; + this.deviceInstanceId = 3; + this.containerThenName = 4; + this.containerThenEndpointDeviceId = 5; + this.containerThenDeviceInstanceId = 6; + this.transportMnemonicThenName = 7; + this.transportMnemonicThenEndpointDeviceId = 8; + this.transportMnemonicThenDeviceInstanceId = 9; +} +exports.MidiEndpointDeviceInformationSortOrder = new _MidiEndpointDeviceInformationSortOrder(); + +_MidiEndpointDevicePurpose = function () { + this.normalMessageEndpoint = 0; + this.virtualDeviceResponder = 1; + this.inBoxGeneralMidiSynth = 2; + this.diagnosticLoopback = 3; + this.diagnosticPing = 4; +} +exports.MidiEndpointDevicePurpose = new _MidiEndpointDevicePurpose(); + +_MidiEndpointDiscoveryRequests = function () { + this.none = 0; + this.requestEndpointInfo = 1; + this.requestDeviceIdentity = 2; + this.requestEndpointName = 3; + this.requestProductInstanceId = 4; + this.requestStreamConfiguration = 5; +} +exports.MidiEndpointDiscoveryRequests = new _MidiEndpointDiscoveryRequests(); + +_MidiEndpointNativeDataFormat = function () { + this.unknown = 0; + this.byteStream = 1; + this.universalMidiPacket = 2; +} +exports.MidiEndpointNativeDataFormat = new _MidiEndpointNativeDataFormat(); + +_MidiFunctionBlockDirection = function () { + this.undefined = 0; + this.blockInput = 1; + this.blockOutput = 2; + this.bidirectional = 3; +} +exports.MidiFunctionBlockDirection = new _MidiFunctionBlockDirection(); + +_MidiFunctionBlockDiscoveryRequests = function () { + this.none = 0; + this.requestFunctionBlockInfo = 1; + this.requestFunctionBlockName = 2; +} +exports.MidiFunctionBlockDiscoveryRequests = new _MidiFunctionBlockDiscoveryRequests(); + +_MidiFunctionBlockMidi10 = function () { + this.not10 = 0; + this.yesBandwidthUnrestricted = 1; + this.yesBandwidthRestricted = 2; + this.reserved = 3; +} +exports.MidiFunctionBlockMidi10 = new _MidiFunctionBlockMidi10(); + +_MidiFunctionBlockUIHint = function () { + this.unknown = 0; + this.receiver = 1; + this.sender = 2; + this.bidirectional = 3; +} +exports.MidiFunctionBlockUIHint = new _MidiFunctionBlockUIHint(); + +_MidiGroupTerminalBlockDirection = function () { + this.bidirectional = 0; + this.blockInput = 1; + this.blockOutput = 2; +} +exports.MidiGroupTerminalBlockDirection = new _MidiGroupTerminalBlockDirection(); + +_MidiGroupTerminalBlockProtocol = function () { + this.unknown = 0; + this.midi1Message64 = 1; + this.midi1Message64WithJitterReduction = 2; + this.midi1Message128 = 3; + this.midi1Message128WithJitterReduction = 4; + this.midi2 = 5; + this.midi2WithJitterReduction = 6; +} +exports.MidiGroupTerminalBlockProtocol = new _MidiGroupTerminalBlockProtocol(); + +_MidiMessageType = function () { + this.utilityMessage32 = 0; + this.systemCommon32 = 1; + this.midi1ChannelVoice32 = 2; + this.dataMessage64 = 3; + this.midi2ChannelVoice64 = 4; + this.dataMessage128 = 5; + this.futureReserved632 = 6; + this.futureReserved732 = 7; + this.futureReserved864 = 8; + this.futureReserved964 = 9; + this.futureReservedA64 = 10; + this.futureReservedB96 = 11; + this.futureReservedC96 = 12; + this.flexData128 = 13; + this.futureReservedE128 = 14; + this.stream128 = 15; +} +exports.MidiMessageType = new _MidiMessageType(); + +_MidiPacketType = function () { + this.unknownOrInvalid = 0; + this.universalMidiPacket32 = 1; + this.universalMidiPacket64 = 2; + this.universalMidiPacket96 = 3; + this.universalMidiPacket128 = 4; +} +exports.MidiPacketType = new _MidiPacketType(); + +_MidiProtocol = function () { + this.default = 0; + this.midi1 = 1; + this.midi2 = 2; +} +exports.MidiProtocol = new _MidiProtocol(); + +_MidiSendMessageResults = function () { + this.succeeded = 0; + this.failed = 1; + this.bufferFull = 2; + this.endpointConnectionClosedOrInvalid = 3; + this.invalidMessageTypeForWordCount = 4; + this.invalidMessageOther = 5; + this.dataIndexOutOfRange = 6; + this.timestampOutOfRange = 7; + this.messageListPartiallyProcessed = 8; + this.other = 9; +} +exports.MidiSendMessageResults = new _MidiSendMessageResults(); + +_MidiServiceConfigurationResponseStatus = function () { + this.success = 0; + this.errorTargetNotFound = 1; + this.errorJsonNullOrEmpty = 2; + this.errorProcessingJson = 3; + this.errorNotImplemented = 4; + this.errorOther = 5; +} +exports.MidiServiceConfigurationResponseStatus = new _MidiServiceConfigurationResponseStatus(); + +_MidiSystemExclusive8Status = function () { + this.completeMessageInSingleMessagePacket = 0; + this.startMessagePacket = 1; + this.continueMessagePacket = 2; + this.endMessagePacket = 3; +} +exports.MidiSystemExclusive8Status = new _MidiSystemExclusive8Status(); + +IMidiEndpointConnectionSettings = (function () { + var cls = function IMidiEndpointConnectionSettings() { + this.settingsJson = new String(); + }; + + + return cls; +}) (); +exports.IMidiEndpointConnectionSettings = IMidiEndpointConnectionSettings; + +IMidiEndpointConnectionSource = (function () { + var cls = function IMidiEndpointConnectionSource() { + }; + + + return cls; +}) (); +exports.IMidiEndpointConnectionSource = IMidiEndpointConnectionSource; + +IMidiEndpointMessageProcessingPlugin = (function () { + var cls = function IMidiEndpointMessageProcessingPlugin() { + this.id = new String(); + this.isEnabled = new Boolean(); + this.name = new String(); + this.tag = new Object(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + return cls; +}) (); +exports.IMidiEndpointMessageProcessingPlugin = IMidiEndpointMessageProcessingPlugin; + +IMidiMessageReceivedEventSource = (function () { + var cls = function IMidiMessageReceivedEventSource() { + }; + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.IMidiMessageReceivedEventSource = IMidiMessageReceivedEventSource; + +IMidiServiceMessageProcessingPluginConfiguration = (function () { + var cls = function IMidiServiceMessageProcessingPluginConfiguration() { + this.endpointDeviceId = new String(); + this.isFromConfigurationFile = new Boolean(); + this.messageProcessingPluginId = new String(); + this.pluginInstanceId = new String(); + this.settingsJson = new Object(); + }; + + + return cls; +}) (); +exports.IMidiServiceMessageProcessingPluginConfiguration = IMidiServiceMessageProcessingPluginConfiguration; + +IMidiServiceTransportPluginConfiguration = (function () { + var cls = function IMidiServiceTransportPluginConfiguration() { + this.isFromConfigurationFile = new Boolean(); + this.settingsJson = new Object(); + this.transportId = new String(); + }; + + + return cls; +}) (); +exports.IMidiServiceTransportPluginConfiguration = IMidiServiceTransportPluginConfiguration; + +IMidiUniversalPacket = (function () { + var cls = function IMidiUniversalPacket() { + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + this.timestamp = new Number(); + }; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + return cls; +}) (); +exports.IMidiUniversalPacket = IMidiUniversalPacket; + +MidiChannel = (function () { + var cls = function MidiChannel() { + this.index = new Number(); + this.numberForDisplay = new Number(); + }; + +var cls = function MidiChannel(index) { + this.index = new Number(); + this.numberForDisplay = new Number(); +}; + + + cls.isValidChannelIndex = function isValidChannelIndex(index) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.labelFull = new String(); + cls.labelShort = new String(); + return cls; +}) (); +exports.MidiChannel = MidiChannel; + +MidiChannelEndpointListener = (function () { + var cls = function MidiChannelEndpointListener() { + this.preventFiringMainMessageReceivedEvent = new Boolean(); + this.preventCallingFurtherListeners = new Boolean(); + this.includeGroup = new MidiGroup(); + this.includeChannels = new Object(); + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiChannelEndpointListener = MidiChannelEndpointListener; + +MidiClock = (function () { + var cls = function MidiClock() { + }; + + + cls.convertTimestampToMicroseconds = function convertTimestampToMicroseconds(timestampValue) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.convertTimestampToMilliseconds = function convertTimestampToMilliseconds(timestampValue) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.convertTimestampToSeconds = function convertTimestampToSeconds(timestampValue) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampByTicks = function offsetTimestampByTicks(timestampValue, offsetTicks) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampByMicroseconds = function offsetTimestampByMicroseconds(timestampValue, offsetMicroseconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampByMilliseconds = function offsetTimestampByMilliseconds(timestampValue, offsetMilliseconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampBySeconds = function offsetTimestampBySeconds(timestampValue, offsetSeconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.now = new Number(); + cls.timestampConstantSendImmediately = new Number(); + cls.timestampFrequency = new Number(); + return cls; +}) (); +exports.MidiClock = MidiClock; + +MidiEndpointConnection = (function () { + var cls = function MidiEndpointConnection() { + this.tag = new Object(); + this.connectionId = new String(); + this.endpointDeviceId = new String(); + this.isOpen = new Boolean(); + this.messageProcessingPlugins = new Object(); + this.settings = new IMidiEndpointConnectionSettings(); + }; + + + cls.prototype.open = function open() { + /// + /// Function summary. + /// + /// + return new Boolean(); + } + + + cls.prototype.addMessageProcessingPlugin = function addMessageProcessingPlugin(plugin) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.removeMessageProcessingPlugin = function removeMessageProcessingPlugin(id) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.sendSingleMessagePacket = function sendSingleMessagePacket(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageStruct = function sendSingleMessageStruct(timestamp, wordCount, message) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageWordArray = function sendSingleMessageWordArray(timestamp, startIndex, wordCount, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + +cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0, word1) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + +cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0, word1, word2) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + +cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0, word1, word2, word3) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageBuffer = function sendSingleMessageBuffer(timestamp, byteOffset, byteCount, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesWordList = function sendMultipleMessagesWordList(timestamp, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesWordArray = function sendMultipleMessagesWordArray(timestamp, startIndex, wordCount, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesPacketList = function sendMultipleMessagesPacketList(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesStructList = function sendMultipleMessagesStructList(timestamp, messages) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesStructArray = function sendMultipleMessagesStructArray(timestamp, startIndex, messageCount, messages) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesBuffer = function sendMultipleMessagesBuffer(timestamp, byteOffset, byteCount, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.getDeviceSelector = function getDeviceSelector() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + cls.sendMessageSucceeded = function sendMessageSucceeded(sendResult) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.sendMessageFailed = function sendMessageFailed(sendResult) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiEndpointConnection = MidiEndpointConnection; + +MidiEndpointDeviceInformation = (function () { + var cls = function MidiEndpointDeviceInformation() { + this.configuredProtocol = new MidiProtocol(); + this.configuredToReceiveJRTimestamps = new Boolean(); + this.configuredToSendJRTimestamps = new Boolean(); + this.containerId = new String(); + this.deviceIdentityDeviceFamilyLsb = new Number(); + this.deviceIdentityDeviceFamilyModelNumberLsb = new Number(); + this.deviceIdentityDeviceFamilyModelNumberMsb = new Number(); + this.deviceIdentityDeviceFamilyMsb = new Number(); + this.deviceIdentityLastUpdateTime = new Date(); + this.deviceIdentitySoftwareRevisionLevel = new Array(); + this.deviceIdentitySystemExclusiveId = new Array(); + this.deviceInstanceId = new String(); + this.endpointConfigurationLastUpdateTime = new Date(); + this.endpointInformationLastUpdateTime = new Date(); + this.endpointPurpose = new MidiEndpointDevicePurpose(); + this.endpointSuppliedName = new String(); + this.endpointSuppliedNameLastUpdateTime = new Date(); + this.functionBlockCount = new Number(); + this.functionBlocks = new Object(); + this.functionBlocksLastUpdateTime = new Date(); + this.groupTerminalBlocks = new Object(); + this.hasStaticFunctionBlocks = new Boolean(); + this.id = new String(); + this.manufacturerName = new String(); + this.name = new String(); + this.nativeDataFormat = new MidiEndpointNativeDataFormat(); + this.productInstanceId = new String(); + this.productInstanceIdLastUpdateTime = new Date(); + this.properties = new Object(); + this.recommendedCCAutomationIntervalMS = new Number(); + this.requiresNoteOffTranslation = new Boolean(); + this.specificationVersionMajor = new Number(); + this.specificationVersionMinor = new Number(); + this.supportsMidi10Protocol = new Boolean(); + this.supportsMidi20Protocol = new Boolean(); + this.supportsMultiClient = new Boolean(); + this.supportsReceivingJRTimestamps = new Boolean(); + this.supportsSendingJRTimestamps = new Boolean(); + this.transportId = new String(); + this.transportMnemonic = new String(); + this.transportSuppliedDescription = new String(); + this.transportSuppliedName = new String(); + this.transportSuppliedProductId = new Number(); + this.transportSuppliedSerialNumber = new String(); + this.transportSuppliedVendorId = new Number(); + this.userSuppliedDescription = new String(); + this.userSuppliedLargeImagePath = new String(); + this.userSuppliedName = new String(); + this.userSuppliedSmallImagePath = new String(); + }; + + + cls.prototype.updateFromDeviceInformation = function updateFromDeviceInformation(deviceInformation) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.updateFromDeviceInformationUpdate = function updateFromDeviceInformationUpdate(deviceInformationUpdate) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.getParentDeviceInformation = function getParentDeviceInformation() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.getContainerInformation = function getContainerInformation() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.createFromId = function createFromId(id) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointDeviceInformation(); + } + + + cls.findAll = function findAll() { + /// + /// Function summary. + /// + /// + return new Object(); + } + +cls.findAll = function findAll(sortOrder) { + /// + /// Function summary. + /// A param. + /// + /// + return new Object(); + } + +cls.findAll = function findAll(sortOrder, endpointFilters) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.getAdditionalPropertiesList = function getAdditionalPropertiesList() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.deviceMatchesFilter = function deviceMatchesFilter(deviceInformation, endpointFilters) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.diagnosticsLoopbackAEndpointId = new String(); + cls.diagnosticsLoopbackBEndpointId = new String(); + cls.endpointInterfaceClass = new String(); + return cls; +}) (); +exports.MidiEndpointDeviceInformation = MidiEndpointDeviceInformation; + +MidiEndpointDeviceInformationAddedEventArgs = (function () { + var cls = function MidiEndpointDeviceInformationAddedEventArgs() { + this.addedDevice = new MidiEndpointDeviceInformation(); + }; + + + return cls; +}) (); +exports.MidiEndpointDeviceInformationAddedEventArgs = MidiEndpointDeviceInformationAddedEventArgs; + +MidiEndpointDeviceInformationRemovedEventArgs = (function () { + var cls = function MidiEndpointDeviceInformationRemovedEventArgs() { + this.deviceInformationUpdate = new Object(); + this.id = new String(); + }; + + + return cls; +}) (); +exports.MidiEndpointDeviceInformationRemovedEventArgs = MidiEndpointDeviceInformationRemovedEventArgs; + +MidiEndpointDeviceInformationUpdatedEventArgs = (function () { + var cls = function MidiEndpointDeviceInformationUpdatedEventArgs() { + this.deviceInformationUpdate = new Object(); + this.id = new String(); + this.updatedAdditionalCapabilities = new Boolean(); + this.updatedDeviceIdentity = new Boolean(); + this.updatedEndpointInformation = new Boolean(); + this.updatedFunctionBlocks = new Boolean(); + this.updatedName = new Boolean(); + this.updatedStreamConfiguration = new Boolean(); + this.updatedUserMetadata = new Boolean(); + }; + + + return cls; +}) (); +exports.MidiEndpointDeviceInformationUpdatedEventArgs = MidiEndpointDeviceInformationUpdatedEventArgs; + +MidiEndpointDeviceWatcher = (function () { + var cls = function MidiEndpointDeviceWatcher() { + this.enumeratedEndpointDevices = new Object(); + this.status = new Number(); + }; + + + cls.prototype.start = function start() { + /// + /// Function summary. + /// + } + + + cls.prototype.stop = function stop() { + /// + /// Function summary. + /// + } + + + cls.createWatcher = function createWatcher(endpointFilters) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointDeviceWatcher(); + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiEndpointDeviceWatcher = MidiEndpointDeviceWatcher; + +MidiFunctionBlock = (function () { + var cls = function MidiFunctionBlock() { + this.uIHint = new MidiFunctionBlockUIHint(); + this.number = new Number(); + this.name = new String(); + this.midiCIMessageVersionFormat = new Number(); + this.midi10Connection = new MidiFunctionBlockMidi10(); + this.maxSystemExclusive8Streams = new Number(); + this.isActive = new Boolean(); + this.groupCount = new Number(); + this.firstGroupIndex = new Number(); + this.direction = new MidiFunctionBlockDirection(); + this.isReadOnly = new Boolean(); + }; + + + cls.prototype.includesGroup = function includesGroup(group) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + return cls; +}) (); +exports.MidiFunctionBlock = MidiFunctionBlock; + +MidiGroup = (function () { + var cls = function MidiGroup() { + this.index = new Number(); + this.numberForDisplay = new Number(); + }; + +var cls = function MidiGroup(index) { + this.index = new Number(); + this.numberForDisplay = new Number(); +}; + + + cls.isValidGroupIndex = function isValidGroupIndex(index) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.labelFull = new String(); + cls.labelShort = new String(); + return cls; +}) (); +exports.MidiGroup = MidiGroup; + +MidiGroupEndpointListener = (function () { + var cls = function MidiGroupEndpointListener() { + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + this.preventFiringMainMessageReceivedEvent = new Boolean(); + this.preventCallingFurtherListeners = new Boolean(); + this.includeGroups = new Object(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiGroupEndpointListener = MidiGroupEndpointListener; + +MidiGroupTerminalBlock = (function () { + var cls = function MidiGroupTerminalBlock() { + this.calculatedMaxDeviceInputBandwidthBitsPerSecond = new Number(); + this.calculatedMaxDeviceOutputBandwidthBitsPerSecond = new Number(); + this.direction = new MidiGroupTerminalBlockDirection(); + this.firstGroupIndex = new Number(); + this.groupCount = new Number(); + this.maxDeviceInputBandwidthIn4KBitsPerSecondUnits = new Number(); + this.maxDeviceOutputBandwidthIn4KBitsPerSecondUnits = new Number(); + this.name = new String(); + this.number = new Number(); + this.protocol = new MidiGroupTerminalBlockProtocol(); + }; + + + cls.prototype.includesGroup = function includesGroup(group) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.asEquivalentFunctionBlock = function asEquivalentFunctionBlock() { + /// + /// Function summary. + /// + /// + return new MidiFunctionBlock(); + } + + + return cls; +}) (); +exports.MidiGroupTerminalBlock = MidiGroupTerminalBlock; + +MidiMessage128 = (function () { + var cls = function MidiMessage128() { + this.word3 = new Number(); + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage128(timestamp, word0, word1, word2, word3) { + this.word3 = new Number(); + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + +var cls = function MidiMessage128(timestamp, words) { + this.word3 = new Number(); + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage128 = MidiMessage128; + +MidiMessage32 = (function () { + var cls = function MidiMessage32() { + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage32(timestamp, word0) { + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage32 = MidiMessage32; + +MidiMessage64 = (function () { + var cls = function MidiMessage64() { + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage64(timestamp, word0, word1) { + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + +var cls = function MidiMessage64(timestamp, words) { + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage64 = MidiMessage64; + +MidiMessage96 = (function () { + var cls = function MidiMessage96() { + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage96(timestamp, word0, word1, word2) { + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + +var cls = function MidiMessage96(timestamp, words) { + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage96 = MidiMessage96; + +MidiMessageBuilder = (function () { + var cls = function MidiMessageBuilder() { + }; + + + cls.buildUtilityMessage = function buildUtilityMessage(timestamp, status, dataOrReserved) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.buildSystemMessage = function buildSystemMessage(timestamp, group, status, midi1Byte2, midi1Byte3) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.buildMidi1ChannelVoiceMessage = function buildMidi1ChannelVoiceMessage(timestamp, group, status, channel, byte3, byte4) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.buildSystemExclusive7Message = function buildSystemExclusive7Message(timestamp, group, status, numberOfBytes, dataByte0, dataByte1, dataByte2, dataByte3, dataByte4, dataByte5) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage64(); + } + + + cls.buildMidi2ChannelVoiceMessage = function buildMidi2ChannelVoiceMessage(timestamp, group, status, channel, index, data) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage64(); + } + + + cls.buildSystemExclusive8Message = function buildSystemExclusive8Message(timestamp, group, status, numberOfValidDataBytesThisMessage, streamId, dataByte00, dataByte01, dataByte02, dataByte03, dataByte04, dataByte05, dataByte06, dataByte07, dataByte08, dataByte09, dataByte10, dataByte11, dataByte12) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildMixedDataSetChunkHeaderMessage = function buildMixedDataSetChunkHeaderMessage(timestamp, group, mdsId, numberValidDataBytesInThisChunk, numberChunksInMixedDataSet, numberOfThisChunk, manufacturerId, deviceId, subId1, subId2) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildMixedDataSetChunkDataMessage = function buildMixedDataSetChunkDataMessage(timestamp, group, mdsId, dataByte00, dataByte01, dataByte02, dataByte03, dataByte04, dataByte05, dataByte06, dataByte07, dataByte08, dataByte09, dataByte10, dataByte11, dataByte12, dataByte13) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildFlexDataMessage = function buildFlexDataMessage(timestamp, group, form, address, channel, statusBank, status, word1Data, word2Data, word3Data) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildStreamMessage = function buildStreamMessage(timestamp, form, status, word0RemainingData, word1Data, word2Data, word3Data) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + return cls; +}) (); +exports.MidiMessageBuilder = MidiMessageBuilder; + +MidiMessageConverter = (function () { + var cls = function MidiMessageConverter() { + }; + + + cls.convertMidi1Message = function convertMidi1Message(timestamp, group, statusByte) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + +cls.convertMidi1Message = function convertMidi1Message(timestamp, group, statusByte, dataByte1) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + +cls.convertMidi1Message = function convertMidi1Message(timestamp, group, statusByte, dataByte1, dataByte2) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ChannelPressureMessage = function convertMidi1ChannelPressureMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1NoteOffMessage = function convertMidi1NoteOffMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1NoteOnMessage = function convertMidi1NoteOnMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1PitchBendChangeMessage = function convertMidi1PitchBendChangeMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1PolyphonicKeyPressureMessage = function convertMidi1PolyphonicKeyPressureMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ProgramChangeMessage = function convertMidi1ProgramChangeMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1TimeCodeMessage = function convertMidi1TimeCodeMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1SongPositionPointerMessage = function convertMidi1SongPositionPointerMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1SongSelectMessage = function convertMidi1SongSelectMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1TuneRequestMessage = function convertMidi1TuneRequestMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1TimingClockMessage = function convertMidi1TimingClockMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1StartMessage = function convertMidi1StartMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ContinueMessage = function convertMidi1ContinueMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1StopMessage = function convertMidi1StopMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ActiveSensingMessage = function convertMidi1ActiveSensingMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1SystemResetMessage = function convertMidi1SystemResetMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + return cls; +}) (); +exports.MidiMessageConverter = MidiMessageConverter; + +MidiMessageReceivedEventArgs = (function () { + var cls = function MidiMessageReceivedEventArgs() { + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + this.timestamp = new Number(); + }; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getMessagePacket = function getMessagePacket() { + /// + /// Function summary. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.prototype.fillWords = function fillWords(word0, word1, word2, word3) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillMessageStruct = function fillMessageStruct(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillMessage32 = function fillMessage32(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillMessage64 = function fillMessage64(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillMessage96 = function fillMessage96(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillMessage128 = function fillMessage128(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillWordArray = function () { +} + + cls.prototype.fillByteArray = function () { +} + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.appendWordsToList = function appendWordsToList(wordList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + return cls; +}) (); +exports.MidiMessageReceivedEventArgs = MidiMessageReceivedEventArgs; + +MidiMessageTypeEndpointListener = (function () { + var cls = function MidiMessageTypeEndpointListener() { + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + this.preventFiringMainMessageReceivedEvent = new Boolean(); + this.preventCallingFurtherListeners = new Boolean(); + this.includeMessageTypes = new Object(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiMessageTypeEndpointListener = MidiMessageTypeEndpointListener; + +MidiMessageUtility = (function () { + var cls = function MidiMessageUtility() { + }; + + + cls.validateMessage32MessageType = function validateMessage32MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.validateMessage64MessageType = function validateMessage64MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.validateMessage96MessageType = function validateMessage96MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.validateMessage128MessageType = function validateMessage128MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.getMessageTypeFromMessageFirstWord = function getMessageTypeFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiMessageType(); + } + + + cls.getPacketTypeFromMessageFirstWord = function getPacketTypeFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiPacketType(); + } + + + cls.messageTypeHasGroupField = function messageTypeHasGroupField(messageType) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.replaceGroupInMessageFirstWord = function replaceGroupInMessageFirstWord(word0, newGroup) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.getGroupFromMessageFirstWord = function getGroupFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiGroup(); + } + + + cls.getStatusFromUtilityMessage = function getStatusFromUtilityMessage(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromMidi1ChannelVoiceMessage = function getStatusFromMidi1ChannelVoiceMessage(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Midi1ChannelVoiceMessageStatus(); + } + + + cls.getStatusFromMidi2ChannelVoiceMessageFirstWord = function getStatusFromMidi2ChannelVoiceMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Midi2ChannelVoiceMessageStatus(); + } + + + cls.getStatusBankFromFlexDataMessageFirstWord = function getStatusBankFromFlexDataMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromFlexDataMessageFirstWord = function getStatusFromFlexDataMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromSystemCommonMessage = function getStatusFromSystemCommonMessage(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromDataMessage64FirstWord = function getStatusFromDataMessage64FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getNumberOfBytesFromDataMessage64FirstWord = function getNumberOfBytesFromDataMessage64FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromDataMessage128FirstWord = function getStatusFromDataMessage128FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getNumberOfBytesFromDataMessage128FirstWord = function getNumberOfBytesFromDataMessage128FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.messageTypeHasChannelField = function messageTypeHasChannelField(messageType) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.replaceChannelInMessageFirstWord = function replaceChannelInMessageFirstWord(word0, newChannel) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.getChannelFromMessageFirstWord = function getChannelFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiChannel(); + } + + + cls.getFormFromStreamMessageFirstWord = function getFormFromStreamMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromStreamMessageFirstWord = function getStatusFromStreamMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getMessageFriendlyNameFromFirstWord = function getMessageFriendlyNameFromFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + cls.getPacketListFromWordList = function getPacketListFromWordList(timestamp, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.getWordListFromPacketList = function getWordListFromPacketList(words) { + /// + /// Function summary. + /// A param. + /// + /// + return new Object(); + } + + + return cls; +}) (); +exports.MidiMessageUtility = MidiMessageUtility; + +MidiService = (function () { + var cls = function MidiService() { + }; + + + cls.pingService = function pingService(pingCount) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiServicePingResponseSummary(); + } + +cls.pingService = function pingService(pingCount, timeoutMilliseconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiServicePingResponseSummary(); + } + + + cls.getInstalledTransportPlugins = function getInstalledTransportPlugins() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.getInstalledMessageProcessingPlugins = function getInstalledMessageProcessingPlugins() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.getActiveSessions = function getActiveSessions() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.createTemporaryLoopbackEndpoints = function createTemporaryLoopbackEndpoints(associationId, endpointDefinitionA, endpointDefinitionB) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiServiceLoopbackEndpointCreationResult(); + } + + + cls.removeTemporaryLoopbackEndpoints = function removeTemporaryLoopbackEndpoints(associationId) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.updateTransportPluginConfiguration = function updateTransportPluginConfiguration(configurationUpdate) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiServiceConfigurationResponse(); + } + + + cls.updateProcessingPluginConfiguration = function updateProcessingPluginConfiguration(configurationUpdate) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiServiceConfigurationResponse(); + } + + + return cls; +}) (); +exports.MidiService = MidiService; + +MidiServiceConfigurationResponse = (function () { + var cls = function MidiServiceConfigurationResponse() { + this.responseJson = new String(); + this.status = new MidiServiceConfigurationResponseStatus(); + }; + + + return cls; +}) (); +exports.MidiServiceConfigurationResponse = MidiServiceConfigurationResponse; + +MidiServiceLoopbackEndpointCreationResult = (function () { + var cls = function MidiServiceLoopbackEndpointCreationResult() { + this.associationId = new String(); + this.endpointDeviceIdA = new String(); + this.endpointDeviceIdB = new String(); + this.success = new Boolean(); + }; + + + return cls; +}) (); +exports.MidiServiceLoopbackEndpointCreationResult = MidiServiceLoopbackEndpointCreationResult; + +MidiServiceLoopbackEndpointDefinition = (function () { + var cls = function MidiServiceLoopbackEndpointDefinition() { + this.uniqueId = new String(); + this.name = new String(); + this.description = new String(); + }; + + + return cls; +}) (); +exports.MidiServiceLoopbackEndpointDefinition = MidiServiceLoopbackEndpointDefinition; + +MidiServiceMessageProcessingPluginInfo = (function () { + var cls = function MidiServiceMessageProcessingPluginInfo() { + this.author = new String(); + this.clientConfigurationAssemblyName = new String(); + this.description = new String(); + this.id = new String(); + this.isClientConfigurable = new Boolean(); + this.isSystemManaged = new Boolean(); + this.name = new String(); + this.smallImagePath = new String(); + this.supportsMultipleInstancesPerDevice = new Boolean(); + this.version = new String(); + }; + + + return cls; +}) (); +exports.MidiServiceMessageProcessingPluginInfo = MidiServiceMessageProcessingPluginInfo; + +MidiServicePingResponse = (function () { + var cls = function MidiServicePingResponse() { + this.clientDeltaTimestamp = new Number(); + this.clientReceiveMidiTimestamp = new Number(); + this.clientSendMidiTimestamp = new Number(); + this.index = new Number(); + this.serviceReportedMidiTimestamp = new Number(); + this.sourceId = new Number(); + }; + + + return cls; +}) (); +exports.MidiServicePingResponse = MidiServicePingResponse; + +MidiServicePingResponseSummary = (function () { + var cls = function MidiServicePingResponseSummary() { + this.averagePingRoundTripMidiClock = new Number(); + this.failureReason = new String(); + this.responses = new Object(); + this.success = new Boolean(); + this.totalPingRoundTripMidiClock = new Number(); + }; + + + return cls; +}) (); +exports.MidiServicePingResponseSummary = MidiServicePingResponseSummary; + +MidiServiceSessionConnectionInfo = (function () { + var cls = function MidiServiceSessionConnectionInfo() { + this.earliestConnectionTime = new Date(); + this.endpointDeviceId = new String(); + this.instanceCount = new Number(); + }; + + + return cls; +}) (); +exports.MidiServiceSessionConnectionInfo = MidiServiceSessionConnectionInfo; + +MidiServiceSessionInfo = (function () { + var cls = function MidiServiceSessionInfo() { + this.connections = new Object(); + this.processId = new Number(); + this.processName = new String(); + this.sessionId = new String(); + this.sessionName = new String(); + this.startTime = new Date(); + }; + + + return cls; +}) (); +exports.MidiServiceSessionInfo = MidiServiceSessionInfo; + +MidiServiceTransportPluginInfo = (function () { + var cls = function MidiServiceTransportPluginInfo() { + this.author = new String(); + this.clientConfigurationAssemblyName = new String(); + this.description = new String(); + this.id = new String(); + this.isClientConfigurable = new Boolean(); + this.isRuntimeCreatableByApps = new Boolean(); + this.isRuntimeCreatableBySettings = new Boolean(); + this.isSystemManaged = new Boolean(); + this.mnemonic = new String(); + this.name = new String(); + this.smallImagePath = new String(); + this.version = new String(); + }; + + + return cls; +}) (); +exports.MidiServiceTransportPluginInfo = MidiServiceTransportPluginInfo; + +MidiSession = (function () { + var cls = function MidiSession() { + this.connections = new Object(); + this.id = new String(); + this.isOpen = new Boolean(); + this.name = new String(); + this.settings = new MidiSessionSettings(); + }; + + + cls.prototype.createEndpointConnection = function createEndpointConnection(endpointDeviceId) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointConnection(); + } + +cls.prototype.createEndpointConnection = function createEndpointConnection(endpointDeviceId, settings) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiEndpointConnection(); + } + + + cls.prototype.createVirtualDeviceAndConnection = function createVirtualDeviceAndConnection(deviceDefinition) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointConnection(); + } + + + cls.prototype.disconnectEndpointConnection = function disconnectEndpointConnection(endpointConnectionId) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.updateName = function updateName(newName) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.close = function close() { +} + + + cls.createSession = function createSession(sessionName) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiSession(); + } + +cls.createSession = function createSession(sessionName, settings) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSession(); + } + + + return cls; +}) (); +exports.MidiSession = MidiSession; + +MidiSessionSettings = (function () { + var cls = function MidiSessionSettings() { + this.useMmcssThreads = new Boolean(); + }; + + + return cls; +}) (); +exports.MidiSessionSettings = MidiSessionSettings; + +MidiStreamConfigurationRequestReceivedEventArgs = (function () { + var cls = function MidiStreamConfigurationRequestReceivedEventArgs() { + this.preferredMidiProtocol = new MidiProtocol(); + this.requestEndpointReceiveJitterReductionTimestamps = new Boolean(); + this.requestEndpointTransmitJitterReductionTimestamps = new Boolean(); + this.timestamp = new Number(); + }; + + + return cls; +}) (); +exports.MidiStreamConfigurationRequestReceivedEventArgs = MidiStreamConfigurationRequestReceivedEventArgs; + +MidiStreamConfigurationRequestedSettings = (function () { + var cls = function MidiStreamConfigurationRequestedSettings() { + this.specificationVersionMinor = new Number(); + this.specificationVersionMajor = new Number(); + this.requestEndpointTransmitJitterReductionTimestamps = new Boolean(); + this.requestEndpointReceiveJitterReductionTimestamps = new Boolean(); + this.preferredMidiProtocol = new MidiProtocol(); + }; + + + return cls; +}) (); +exports.MidiStreamConfigurationRequestedSettings = MidiStreamConfigurationRequestedSettings; + +MidiStreamMessageBuilder = (function () { + var cls = function MidiStreamMessageBuilder() { + }; + + + cls.buildEndpointDiscoveryMessage = function buildEndpointDiscoveryMessage(timestamp, umpVersionMajor, umpVersionMinor, requestFlags) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildEndpointInfoNotificationMessage = function buildEndpointInfoNotificationMessage(timestamp, umpVersionMajor, umpVersionMinor, hasStaticFunctionBlocks, numberOfFunctionBlocks, supportsMidi20Protocol, supportsMidi10Protocol, supportsReceivingJitterReductionTimestamps, supportsSendingJitterReductionTimestamps) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildDeviceIdentityNotificationMessage = function buildDeviceIdentityNotificationMessage(timestamp, deviceManufacturerSysExIdByte1, deviceManufacturerSysExIdByte2, deviceManufacturerSysExIdByte3, deviceFamilyLsb, deviceFamilyMsb, deviceFamilyModelNumberLsb, deviceFamilyModelNumberMsb, softwareRevisionLevelByte1, softwareRevisionLevelByte2, softwareRevisionLevelByte3, softwareRevisionLevelByte4) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildEndpointNameNotificationMessages = function buildEndpointNameNotificationMessages(timestamp, name) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.buildProductInstanceIdNotificationMessages = function buildProductInstanceIdNotificationMessages(timestamp, productInstanceId) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.parseEndpointNameNotificationMessages = function parseEndpointNameNotificationMessages(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + cls.parseProductInstanceIdNotificationMessages = function parseProductInstanceIdNotificationMessages(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + cls.buildStreamConfigurationRequestMessage = function buildStreamConfigurationRequestMessage(timestamp, protocol, expectToReceiveJRTimestamps, requestToSendJRTimestamps) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildStreamConfigurationNotificationMessage = function buildStreamConfigurationNotificationMessage(timestamp, protocol, confirmationWillReceiveJRTimestamps, confirmationSendJRTimestamps) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildFunctionBlockDiscoveryMessage = function buildFunctionBlockDiscoveryMessage(timestamp, functionBlockNumber, requestFlags) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildFunctionBlockInfoNotificationMessage = function buildFunctionBlockInfoNotificationMessage(timestamp, active, functionBlockNumber, uiHint, midi10, direction, firstGroup, numberOfGroups, midiCIVersionFormat, maxNumberSysEx8Streams) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildFunctionBlockNameNotificationMessages = function buildFunctionBlockNameNotificationMessages(timestamp, functionBlockNumber, name) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.parseFunctionBlockNameNotificationMessages = function parseFunctionBlockNameNotificationMessages(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiStreamMessageBuilder = MidiStreamMessageBuilder; + +MidiUniqueId = (function () { + var cls = function MidiUniqueId() { + this.byte4 = new Number(); + this.byte3 = new Number(); + this.byte2 = new Number(); + this.byte1 = new Number(); + this.asCombined28BitValue = new Number(); + this.isBroadcast = new Boolean(); + this.isReserved = new Boolean(); + }; + +var cls = function MidiUniqueId(combined28BitValue) { + this.byte4 = new Number(); + this.byte3 = new Number(); + this.byte2 = new Number(); + this.byte1 = new Number(); + this.asCombined28BitValue = new Number(); + this.isBroadcast = new Boolean(); + this.isReserved = new Boolean(); +}; + +var cls = function MidiUniqueId(sevenBitByte1, sevenBitByte2, sevenBitByte3, sevenBitByte4) { + this.byte4 = new Number(); + this.byte3 = new Number(); + this.byte2 = new Number(); + this.byte1 = new Number(); + this.asCombined28BitValue = new Number(); + this.isBroadcast = new Boolean(); + this.isReserved = new Boolean(); +}; + + + cls.createBroadcast = function createBroadcast() { + /// + /// Function summary. + /// + /// + return new MidiUniqueId(); + } + + + cls.createRandom = function createRandom() { + /// + /// Function summary. + /// + /// + return new MidiUniqueId(); + } + + + cls.labelFull = new String(); + cls.labelShort = new String(); + return cls; +}) (); +exports.MidiUniqueId = MidiUniqueId; + +MidiVirtualEndpointDevice = (function () { + var cls = function MidiVirtualEndpointDevice() { + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + this.suppressHandledMessages = new Boolean(); + this.deviceDefinition = new MidiVirtualEndpointDeviceDefinition(); + this.functionBlocks = new Object(); + }; + + + cls.prototype.updateFunctionBlock = function updateFunctionBlock(block) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.updateEndpointName = function updateEndpointName(name) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiVirtualEndpointDevice = MidiVirtualEndpointDevice; + +MidiVirtualEndpointDeviceDefinition = (function () { + var cls = function MidiVirtualEndpointDeviceDefinition() { + this.transportSuppliedDescription = new String(); + this.supportsSendingJRTimestamps = new Boolean(); + this.supportsReceivingJRTimestamps = new Boolean(); + this.supportsMidi2ProtocolMessages = new Boolean(); + this.supportsMidi1ProtocolMessages = new Boolean(); + this.endpointProductInstanceId = new String(); + this.endpointName = new String(); + this.deviceFamilyMsb = new Number(); + this.deviceFamilyModelMsb = new Number(); + this.deviceFamilyModelLsb = new Number(); + this.deviceFamilyLsb = new Number(); + this.areFunctionBlocksStatic = new Boolean(); + this.deviceManufacturerSystemExclusiveId = new Object(); + this.functionBlocks = new Object(); + this.softwareRevisionLevel = new Object(); + }; + + + return cls; +}) (); +exports.MidiVirtualEndpointDeviceDefinition = MidiVirtualEndpointDeviceDefinition; + diff --git a/build/electron-projection/projection3/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.ts b/build/electron-projection/projection3/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.ts new file mode 100644 index 000000000..a2404bfee --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.ts @@ -0,0 +1,1262 @@ +declare module "windows.devices.midi2" { + export class MidiMessageStruct { + word0: Number; + word1: Number; + word2: Number; + word3: Number; + constructor(); + } + + export enum Midi1ChannelVoiceMessageStatus { + noteOff, + noteOn, + polyPressure, + controlChange, + programChange, + channelPressure, + pitchBend, + } + + export enum Midi2ChannelVoiceMessageStatus { + registeredPerNoteController, + assignablePerNoteController, + registeredController, + assignableController, + relativeRegisteredController, + relativeAssignableController, + perNotePitchBend, + noteOff, + noteOn, + polyPressure, + controlChange, + programChange, + channelPressure, + pitchBend, + perNoteManagement, + } + + export enum MidiEndpointDeviceInformationFilters { + includeClientUmpNative, + includeClientByteStreamNative, + includeVirtualDeviceResponder, + includeDiagnosticLoopback, + includeDiagnosticPing, + allTypicalEndpoints, + } + + export enum MidiEndpointDeviceInformationSortOrder { + none, + name, + endpointDeviceId, + deviceInstanceId, + containerThenName, + containerThenEndpointDeviceId, + containerThenDeviceInstanceId, + transportMnemonicThenName, + transportMnemonicThenEndpointDeviceId, + transportMnemonicThenDeviceInstanceId, + } + + export enum MidiEndpointDevicePurpose { + normalMessageEndpoint, + virtualDeviceResponder, + inBoxGeneralMidiSynth, + diagnosticLoopback, + diagnosticPing, + } + + export enum MidiEndpointDiscoveryRequests { + none, + requestEndpointInfo, + requestDeviceIdentity, + requestEndpointName, + requestProductInstanceId, + requestStreamConfiguration, + } + + export enum MidiEndpointNativeDataFormat { + unknown, + byteStream, + universalMidiPacket, + } + + export enum MidiFunctionBlockDirection { + undefined, + blockInput, + blockOutput, + bidirectional, + } + + export enum MidiFunctionBlockDiscoveryRequests { + none, + requestFunctionBlockInfo, + requestFunctionBlockName, + } + + export enum MidiFunctionBlockMidi10 { + not10, + yesBandwidthUnrestricted, + yesBandwidthRestricted, + reserved, + } + + export enum MidiFunctionBlockUIHint { + unknown, + receiver, + sender, + bidirectional, + } + + export enum MidiGroupTerminalBlockDirection { + bidirectional, + blockInput, + blockOutput, + } + + export enum MidiGroupTerminalBlockProtocol { + unknown, + midi1Message64, + midi1Message64WithJitterReduction, + midi1Message128, + midi1Message128WithJitterReduction, + midi2, + midi2WithJitterReduction, + } + + export enum MidiMessageType { + utilityMessage32, + systemCommon32, + midi1ChannelVoice32, + dataMessage64, + midi2ChannelVoice64, + dataMessage128, + futureReserved632, + futureReserved732, + futureReserved864, + futureReserved964, + futureReservedA64, + futureReservedB96, + futureReservedC96, + flexData128, + futureReservedE128, + stream128, + } + + export enum MidiPacketType { + unknownOrInvalid, + universalMidiPacket32, + universalMidiPacket64, + universalMidiPacket96, + universalMidiPacket128, + } + + export enum MidiProtocol { + default, + midi1, + midi2, + } + + export enum MidiSendMessageResults { + succeeded, + failed, + bufferFull, + endpointConnectionClosedOrInvalid, + invalidMessageTypeForWordCount, + invalidMessageOther, + dataIndexOutOfRange, + timestampOutOfRange, + messageListPartiallyProcessed, + other, + } + + export enum MidiServiceConfigurationResponseStatus { + success, + errorTargetNotFound, + errorJsonNullOrEmpty, + errorProcessingJson, + errorNotImplemented, + errorOther, + } + + export enum MidiSystemExclusive8Status { + completeMessageInSingleMessagePacket, + startMessagePacket, + continueMessagePacket, + endMessagePacket, + } + + export class IMidiEndpointConnectionSettings { + settingsJson: String; + constructor(); + + } + + export class IMidiEndpointConnectionSource { + constructor(); + + } + + export class IMidiEndpointMessageProcessingPlugin { + id: String; + isEnabled: Boolean; + name: String; + tag: Object; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + } + + export class IMidiMessageReceivedEventSource { + constructor(); + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class IMidiServiceMessageProcessingPluginConfiguration { + endpointDeviceId: String; + isFromConfigurationFile: Boolean; + messageProcessingPluginId: String; + pluginInstanceId: String; + settingsJson: Object; + constructor(); + + } + + export class IMidiServiceTransportPluginConfiguration { + isFromConfigurationFile: Boolean; + settingsJson: Object; + transportId: String; + constructor(); + + } + + export class IMidiUniversalPacket { + messageType: MidiMessageType; + packetType: MidiPacketType; + timestamp: Number; + constructor(); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + } + + export class MidiChannel { + static labelFull: String; + static labelShort: String; + index: Number; + numberForDisplay: Number; + constructor(); + constructor(index: Number); + + static isValidChannelIndex(index: Number): Boolean; + + + } + + export class MidiChannelEndpointListener { + preventFiringMainMessageReceivedEvent: Boolean; + preventCallingFurtherListeners: Boolean; + includeGroup: MidiGroup; + includeChannels: Object; + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiClock { + static now: Number; + static timestampConstantSendImmediately: Number; + static timestampFrequency: Number; + constructor(); + + static convertTimestampToMicroseconds(timestampValue: Number): Number; + + + static convertTimestampToMilliseconds(timestampValue: Number): Number; + + + static convertTimestampToSeconds(timestampValue: Number): Number; + + + static offsetTimestampByTicks(timestampValue: Number, offsetTicks: Number): Number; + + + static offsetTimestampByMicroseconds(timestampValue: Number, offsetMicroseconds: Number): Number; + + + static offsetTimestampByMilliseconds(timestampValue: Number, offsetMilliseconds: Number): Number; + + + static offsetTimestampBySeconds(timestampValue: Number, offsetSeconds: Number): Number; + + + } + + export class MidiEndpointConnection { + tag: Object; + connectionId: String; + endpointDeviceId: String; + isOpen: Boolean; + messageProcessingPlugins: Object; + settings: IMidiEndpointConnectionSettings; + constructor(); + + static getDeviceSelector(): String; + + + static sendMessageSucceeded(sendResult: MidiSendMessageResults): Boolean; + + + static sendMessageFailed(sendResult: MidiSendMessageResults): Boolean; + + + open(): Boolean; + + addMessageProcessingPlugin(plugin: IMidiEndpointMessageProcessingPlugin): void; + + removeMessageProcessingPlugin(id: String): void; + + sendSingleMessagePacket(message: IMidiUniversalPacket): MidiSendMessageResults; + + sendSingleMessageStruct(timestamp: Number, wordCount: Number, message: MidiMessageStruct): MidiSendMessageResults; + + sendSingleMessageWordArray(timestamp: Number, startIndex: Number, wordCount: Number, words: Array): MidiSendMessageResults; + + sendSingleMessageWords(timestamp: Number, word0: Number): MidiSendMessageResults; + sendSingleMessageWords(timestamp: Number, word0: Number, word1: Number): MidiSendMessageResults; + sendSingleMessageWords(timestamp: Number, word0: Number, word1: Number, word2: Number): MidiSendMessageResults; + sendSingleMessageWords(timestamp: Number, word0: Number, word1: Number, word2: Number, word3: Number): MidiSendMessageResults; + + sendSingleMessageBuffer(timestamp: Number, byteOffset: Number, byteCount: Number, buffer: Object): MidiSendMessageResults; + + sendMultipleMessagesWordList(timestamp: Number, words: Object): MidiSendMessageResults; + + sendMultipleMessagesWordArray(timestamp: Number, startIndex: Number, wordCount: Number, words: Array): MidiSendMessageResults; + + sendMultipleMessagesPacketList(messages: Object): MidiSendMessageResults; + + sendMultipleMessagesStructList(timestamp: Number, messages: Object): MidiSendMessageResults; + + sendMultipleMessagesStructArray(timestamp: Number, startIndex: Number, messageCount: Number, messages: Array): MidiSendMessageResults; + + sendMultipleMessagesBuffer(timestamp: Number, byteOffset: Number, byteCount: Number, buffer: Object): MidiSendMessageResults; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiEndpointDeviceInformation { + static diagnosticsLoopbackAEndpointId: String; + static diagnosticsLoopbackBEndpointId: String; + static endpointInterfaceClass: String; + configuredProtocol: MidiProtocol; + configuredToReceiveJRTimestamps: Boolean; + configuredToSendJRTimestamps: Boolean; + containerId: String; + deviceIdentityDeviceFamilyLsb: Number; + deviceIdentityDeviceFamilyModelNumberLsb: Number; + deviceIdentityDeviceFamilyModelNumberMsb: Number; + deviceIdentityDeviceFamilyMsb: Number; + deviceIdentityLastUpdateTime: Date; + deviceIdentitySoftwareRevisionLevel: Array; + deviceIdentitySystemExclusiveId: Array; + deviceInstanceId: String; + endpointConfigurationLastUpdateTime: Date; + endpointInformationLastUpdateTime: Date; + endpointPurpose: MidiEndpointDevicePurpose; + endpointSuppliedName: String; + endpointSuppliedNameLastUpdateTime: Date; + functionBlockCount: Number; + functionBlocks: Object; + functionBlocksLastUpdateTime: Date; + groupTerminalBlocks: Object; + hasStaticFunctionBlocks: Boolean; + id: String; + manufacturerName: String; + name: String; + nativeDataFormat: MidiEndpointNativeDataFormat; + productInstanceId: String; + productInstanceIdLastUpdateTime: Date; + properties: Object; + recommendedCCAutomationIntervalMS: Number; + requiresNoteOffTranslation: Boolean; + specificationVersionMajor: Number; + specificationVersionMinor: Number; + supportsMidi10Protocol: Boolean; + supportsMidi20Protocol: Boolean; + supportsMultiClient: Boolean; + supportsReceivingJRTimestamps: Boolean; + supportsSendingJRTimestamps: Boolean; + transportId: String; + transportMnemonic: String; + transportSuppliedDescription: String; + transportSuppliedName: String; + transportSuppliedProductId: Number; + transportSuppliedSerialNumber: String; + transportSuppliedVendorId: Number; + userSuppliedDescription: String; + userSuppliedLargeImagePath: String; + userSuppliedName: String; + userSuppliedSmallImagePath: String; + constructor(); + + static createFromId(id: String): MidiEndpointDeviceInformation; + + + static findAll(): Object; + static findAll(sortOrder: MidiEndpointDeviceInformationSortOrder): Object; + static findAll(sortOrder: MidiEndpointDeviceInformationSortOrder, endpointFilters: MidiEndpointDeviceInformationFilters): Object; + + + static getAdditionalPropertiesList(): Object; + + + static deviceMatchesFilter(deviceInformation: MidiEndpointDeviceInformation, endpointFilters: MidiEndpointDeviceInformationFilters): Boolean; + + + updateFromDeviceInformation(deviceInformation: Object): Boolean; + + updateFromDeviceInformationUpdate(deviceInformationUpdate: Object): Boolean; + + getParentDeviceInformation(): Object; + + getContainerInformation(): Object; + + } + + export class MidiEndpointDeviceInformationAddedEventArgs { + addedDevice: MidiEndpointDeviceInformation; + constructor(); + + } + + export class MidiEndpointDeviceInformationRemovedEventArgs { + deviceInformationUpdate: Object; + id: String; + constructor(); + + } + + export class MidiEndpointDeviceInformationUpdatedEventArgs { + deviceInformationUpdate: Object; + id: String; + updatedAdditionalCapabilities: Boolean; + updatedDeviceIdentity: Boolean; + updatedEndpointInformation: Boolean; + updatedFunctionBlocks: Boolean; + updatedName: Boolean; + updatedStreamConfiguration: Boolean; + updatedUserMetadata: Boolean; + constructor(); + + } + + export class MidiEndpointDeviceWatcher { + enumeratedEndpointDevices: Object; + status: Number; + constructor(); + + static createWatcher(endpointFilters: MidiEndpointDeviceInformationFilters): MidiEndpointDeviceWatcher; + + + start(): void; + + stop(): void; + + addListener(type: "Added", listener: (ev: Event) => void): void ; + removeListener(type: "Added", listener: (ev: Event) => void): void ; + on(type: "Added", listener: (ev: Event) => void): void ; + off(type: "Added", listener: (ev: Event) => void): void ; + + addListener(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + removeListener(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + on(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + off(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + + addListener(type: "Removed", listener: (ev: Event) => void): void ; + removeListener(type: "Removed", listener: (ev: Event) => void): void ; + on(type: "Removed", listener: (ev: Event) => void): void ; + off(type: "Removed", listener: (ev: Event) => void): void ; + + addListener(type: "Stopped", listener: (ev: Event) => void): void ; + removeListener(type: "Stopped", listener: (ev: Event) => void): void ; + on(type: "Stopped", listener: (ev: Event) => void): void ; + off(type: "Stopped", listener: (ev: Event) => void): void ; + + addListener(type: "Updated", listener: (ev: Event) => void): void ; + removeListener(type: "Updated", listener: (ev: Event) => void): void ; + on(type: "Updated", listener: (ev: Event) => void): void ; + off(type: "Updated", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiFunctionBlock { + uIHint: MidiFunctionBlockUIHint; + number: Number; + name: String; + midiCIMessageVersionFormat: Number; + midi10Connection: MidiFunctionBlockMidi10; + maxSystemExclusive8Streams: Number; + isActive: Boolean; + groupCount: Number; + firstGroupIndex: Number; + direction: MidiFunctionBlockDirection; + isReadOnly: Boolean; + constructor(); + + includesGroup(group: MidiGroup): Boolean; + + } + + export class MidiGroup { + static labelFull: String; + static labelShort: String; + index: Number; + numberForDisplay: Number; + constructor(); + constructor(index: Number); + + static isValidGroupIndex(index: Number): Boolean; + + + } + + export class MidiGroupEndpointListener { + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + preventFiringMainMessageReceivedEvent: Boolean; + preventCallingFurtherListeners: Boolean; + includeGroups: Object; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiGroupTerminalBlock { + calculatedMaxDeviceInputBandwidthBitsPerSecond: Number; + calculatedMaxDeviceOutputBandwidthBitsPerSecond: Number; + direction: MidiGroupTerminalBlockDirection; + firstGroupIndex: Number; + groupCount: Number; + maxDeviceInputBandwidthIn4KBitsPerSecondUnits: Number; + maxDeviceOutputBandwidthIn4KBitsPerSecondUnits: Number; + name: String; + number: Number; + protocol: MidiGroupTerminalBlockProtocol; + constructor(); + + includesGroup(group: MidiGroup): Boolean; + + asEquivalentFunctionBlock(): MidiFunctionBlock; + + } + + export class MidiMessage128 { + word3: Number; + word2: Number; + word1: Number; + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number, word1: Number, word2: Number, word3: Number); + constructor(timestamp: Number, words: Array); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessage32 { + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessage64 { + word1: Number; + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number, word1: Number); + constructor(timestamp: Number, words: Array); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessage96 { + word2: Number; + word1: Number; + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number, word1: Number, word2: Number); + constructor(timestamp: Number, words: Array); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessageBuilder { + constructor(); + + static buildUtilityMessage(timestamp: Number, status: Number, dataOrReserved: Number): MidiMessage32; + + + static buildSystemMessage(timestamp: Number, group: MidiGroup, status: Number, midi1Byte2: Number, midi1Byte3: Number): MidiMessage32; + + + static buildMidi1ChannelVoiceMessage(timestamp: Number, group: MidiGroup, status: Midi1ChannelVoiceMessageStatus, channel: MidiChannel, byte3: Number, byte4: Number): MidiMessage32; + + + static buildSystemExclusive7Message(timestamp: Number, group: MidiGroup, status: Number, numberOfBytes: Number, dataByte0: Number, dataByte1: Number, dataByte2: Number, dataByte3: Number, dataByte4: Number, dataByte5: Number): MidiMessage64; + + + static buildMidi2ChannelVoiceMessage(timestamp: Number, group: MidiGroup, status: Midi2ChannelVoiceMessageStatus, channel: MidiChannel, index: Number, data: Number): MidiMessage64; + + + static buildSystemExclusive8Message(timestamp: Number, group: MidiGroup, status: MidiSystemExclusive8Status, numberOfValidDataBytesThisMessage: Number, streamId: Number, dataByte00: Number, dataByte01: Number, dataByte02: Number, dataByte03: Number, dataByte04: Number, dataByte05: Number, dataByte06: Number, dataByte07: Number, dataByte08: Number, dataByte09: Number, dataByte10: Number, dataByte11: Number, dataByte12: Number): MidiMessage128; + + + static buildMixedDataSetChunkHeaderMessage(timestamp: Number, group: MidiGroup, mdsId: Number, numberValidDataBytesInThisChunk: Number, numberChunksInMixedDataSet: Number, numberOfThisChunk: Number, manufacturerId: Number, deviceId: Number, subId1: Number, subId2: Number): MidiMessage128; + + + static buildMixedDataSetChunkDataMessage(timestamp: Number, group: MidiGroup, mdsId: Number, dataByte00: Number, dataByte01: Number, dataByte02: Number, dataByte03: Number, dataByte04: Number, dataByte05: Number, dataByte06: Number, dataByte07: Number, dataByte08: Number, dataByte09: Number, dataByte10: Number, dataByte11: Number, dataByte12: Number, dataByte13: Number): MidiMessage128; + + + static buildFlexDataMessage(timestamp: Number, group: MidiGroup, form: Number, address: Number, channel: MidiChannel, statusBank: Number, status: Number, word1Data: Number, word2Data: Number, word3Data: Number): MidiMessage128; + + + static buildStreamMessage(timestamp: Number, form: Number, status: Number, word0RemainingData: Number, word1Data: Number, word2Data: Number, word3Data: Number): MidiMessage128; + + + } + + export class MidiMessageConverter { + constructor(); + + static convertMidi1Message(timestamp: Number, group: MidiGroup, statusByte: Number): MidiMessage32; + static convertMidi1Message(timestamp: Number, group: MidiGroup, statusByte: Number, dataByte1: Number): MidiMessage32; + static convertMidi1Message(timestamp: Number, group: MidiGroup, statusByte: Number, dataByte1: Number, dataByte2: Number): MidiMessage32; + + + static convertMidi1ChannelPressureMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1NoteOffMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1NoteOnMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1PitchBendChangeMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1PolyphonicKeyPressureMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1ProgramChangeMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1TimeCodeMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1SongPositionPointerMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1SongSelectMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1TuneRequestMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1TimingClockMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1StartMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1ContinueMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1StopMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1ActiveSensingMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1SystemResetMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + } + + export class MidiMessageReceivedEventArgs { + messageType: MidiMessageType; + packetType: MidiPacketType; + timestamp: Number; + constructor(); + + peekFirstWord(): Number; + + getMessagePacket(): IMidiUniversalPacket; + + fillWords(word0: Number, word1: Number, word2: Number, word3: Number): Number; + + fillMessageStruct(message: MidiMessageStruct): Number; + + fillMessage32(message: MidiMessage32): Boolean; + + fillMessage64(message: MidiMessage64): Boolean; + + fillMessage96(message: MidiMessage96): Boolean; + + fillMessage128(message: MidiMessage128): Boolean; + + fillWordArray(); + fillByteArray(); + fillBuffer(byteOffset: Number, buffer: Object): Number; + + appendWordsToList(wordList: Object): Number; + + } + + export class MidiMessageTypeEndpointListener { + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + preventFiringMainMessageReceivedEvent: Boolean; + preventCallingFurtherListeners: Boolean; + includeMessageTypes: Object; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiMessageUtility { + constructor(); + + static validateMessage32MessageType(word0: Number): Boolean; + + + static validateMessage64MessageType(word0: Number): Boolean; + + + static validateMessage96MessageType(word0: Number): Boolean; + + + static validateMessage128MessageType(word0: Number): Boolean; + + + static getMessageTypeFromMessageFirstWord(word0: Number): MidiMessageType; + + + static getPacketTypeFromMessageFirstWord(word0: Number): MidiPacketType; + + + static messageTypeHasGroupField(messageType: MidiMessageType): Boolean; + + + static replaceGroupInMessageFirstWord(word0: Number, newGroup: MidiGroup): Number; + + + static getGroupFromMessageFirstWord(word0: Number): MidiGroup; + + + static getStatusFromUtilityMessage(word0: Number): Number; + + + static getStatusFromMidi1ChannelVoiceMessage(word0: Number): Midi1ChannelVoiceMessageStatus; + + + static getStatusFromMidi2ChannelVoiceMessageFirstWord(word0: Number): Midi2ChannelVoiceMessageStatus; + + + static getStatusBankFromFlexDataMessageFirstWord(word0: Number): Number; + + + static getStatusFromFlexDataMessageFirstWord(word0: Number): Number; + + + static getStatusFromSystemCommonMessage(word0: Number): Number; + + + static getStatusFromDataMessage64FirstWord(word0: Number): Number; + + + static getNumberOfBytesFromDataMessage64FirstWord(word0: Number): Number; + + + static getStatusFromDataMessage128FirstWord(word0: Number): Number; + + + static getNumberOfBytesFromDataMessage128FirstWord(word0: Number): Number; + + + static messageTypeHasChannelField(messageType: MidiMessageType): Boolean; + + + static replaceChannelInMessageFirstWord(word0: Number, newChannel: MidiChannel): Number; + + + static getChannelFromMessageFirstWord(word0: Number): MidiChannel; + + + static getFormFromStreamMessageFirstWord(word0: Number): Number; + + + static getStatusFromStreamMessageFirstWord(word0: Number): Number; + + + static getMessageFriendlyNameFromFirstWord(word0: Number): String; + + + static getPacketListFromWordList(timestamp: Number, words: Object): Object; + + + static getWordListFromPacketList(words: Object): Object; + + + } + + export class MidiService { + constructor(); + + static pingService(pingCount: Number): MidiServicePingResponseSummary; + static pingService(pingCount: Number, timeoutMilliseconds: Number): MidiServicePingResponseSummary; + + + static getInstalledTransportPlugins(): Object; + + + static getInstalledMessageProcessingPlugins(): Object; + + + static getActiveSessions(): Object; + + + static createTemporaryLoopbackEndpoints(associationId: String, endpointDefinitionA: MidiServiceLoopbackEndpointDefinition, endpointDefinitionB: MidiServiceLoopbackEndpointDefinition): MidiServiceLoopbackEndpointCreationResult; + + + static removeTemporaryLoopbackEndpoints(associationId: String): Boolean; + + + static updateTransportPluginConfiguration(configurationUpdate: IMidiServiceTransportPluginConfiguration): MidiServiceConfigurationResponse; + + + static updateProcessingPluginConfiguration(configurationUpdate: IMidiServiceMessageProcessingPluginConfiguration): MidiServiceConfigurationResponse; + + + } + + export class MidiServiceConfigurationResponse { + responseJson: String; + status: MidiServiceConfigurationResponseStatus; + constructor(); + + } + + export class MidiServiceLoopbackEndpointCreationResult { + associationId: String; + endpointDeviceIdA: String; + endpointDeviceIdB: String; + success: Boolean; + constructor(); + + } + + export class MidiServiceLoopbackEndpointDefinition { + uniqueId: String; + name: String; + description: String; + constructor(); + + } + + export class MidiServiceMessageProcessingPluginInfo { + author: String; + clientConfigurationAssemblyName: String; + description: String; + id: String; + isClientConfigurable: Boolean; + isSystemManaged: Boolean; + name: String; + smallImagePath: String; + supportsMultipleInstancesPerDevice: Boolean; + version: String; + constructor(); + + } + + export class MidiServicePingResponse { + clientDeltaTimestamp: Number; + clientReceiveMidiTimestamp: Number; + clientSendMidiTimestamp: Number; + index: Number; + serviceReportedMidiTimestamp: Number; + sourceId: Number; + constructor(); + + } + + export class MidiServicePingResponseSummary { + averagePingRoundTripMidiClock: Number; + failureReason: String; + responses: Object; + success: Boolean; + totalPingRoundTripMidiClock: Number; + constructor(); + + } + + export class MidiServiceSessionConnectionInfo { + earliestConnectionTime: Date; + endpointDeviceId: String; + instanceCount: Number; + constructor(); + + } + + export class MidiServiceSessionInfo { + connections: Object; + processId: Number; + processName: String; + sessionId: String; + sessionName: String; + startTime: Date; + constructor(); + + } + + export class MidiServiceTransportPluginInfo { + author: String; + clientConfigurationAssemblyName: String; + description: String; + id: String; + isClientConfigurable: Boolean; + isRuntimeCreatableByApps: Boolean; + isRuntimeCreatableBySettings: Boolean; + isSystemManaged: Boolean; + mnemonic: String; + name: String; + smallImagePath: String; + version: String; + constructor(); + + } + + export class MidiSession { + connections: Object; + id: String; + isOpen: Boolean; + name: String; + settings: MidiSessionSettings; + constructor(); + + static createSession(sessionName: String): MidiSession; + static createSession(sessionName: String, settings: MidiSessionSettings): MidiSession; + + + createEndpointConnection(endpointDeviceId: String): MidiEndpointConnection; + createEndpointConnection(endpointDeviceId: String, settings: IMidiEndpointConnectionSettings): MidiEndpointConnection; + + createVirtualDeviceAndConnection(deviceDefinition: MidiVirtualEndpointDeviceDefinition): MidiEndpointConnection; + + disconnectEndpointConnection(endpointConnectionId: String): void; + + updateName(newName: String): Boolean; + + close(): void; + } + + export class MidiSessionSettings { + useMmcssThreads: Boolean; + constructor(); + + } + + export class MidiStreamConfigurationRequestReceivedEventArgs { + preferredMidiProtocol: MidiProtocol; + requestEndpointReceiveJitterReductionTimestamps: Boolean; + requestEndpointTransmitJitterReductionTimestamps: Boolean; + timestamp: Number; + constructor(); + + } + + export class MidiStreamConfigurationRequestedSettings { + specificationVersionMinor: Number; + specificationVersionMajor: Number; + requestEndpointTransmitJitterReductionTimestamps: Boolean; + requestEndpointReceiveJitterReductionTimestamps: Boolean; + preferredMidiProtocol: MidiProtocol; + constructor(); + + } + + export class MidiStreamMessageBuilder { + constructor(); + + static buildEndpointDiscoveryMessage(timestamp: Number, umpVersionMajor: Number, umpVersionMinor: Number, requestFlags: MidiEndpointDiscoveryRequests): IMidiUniversalPacket; + + + static buildEndpointInfoNotificationMessage(timestamp: Number, umpVersionMajor: Number, umpVersionMinor: Number, hasStaticFunctionBlocks: Boolean, numberOfFunctionBlocks: Number, supportsMidi20Protocol: Boolean, supportsMidi10Protocol: Boolean, supportsReceivingJitterReductionTimestamps: Boolean, supportsSendingJitterReductionTimestamps: Boolean): IMidiUniversalPacket; + + + static buildDeviceIdentityNotificationMessage(timestamp: Number, deviceManufacturerSysExIdByte1: Number, deviceManufacturerSysExIdByte2: Number, deviceManufacturerSysExIdByte3: Number, deviceFamilyLsb: Number, deviceFamilyMsb: Number, deviceFamilyModelNumberLsb: Number, deviceFamilyModelNumberMsb: Number, softwareRevisionLevelByte1: Number, softwareRevisionLevelByte2: Number, softwareRevisionLevelByte3: Number, softwareRevisionLevelByte4: Number): IMidiUniversalPacket; + + + static buildEndpointNameNotificationMessages(timestamp: Number, name: String): Object; + + + static buildProductInstanceIdNotificationMessages(timestamp: Number, productInstanceId: String): Object; + + + static parseEndpointNameNotificationMessages(messages: Object): String; + + + static parseProductInstanceIdNotificationMessages(messages: Object): String; + + + static buildStreamConfigurationRequestMessage(timestamp: Number, protocol: Number, expectToReceiveJRTimestamps: Boolean, requestToSendJRTimestamps: Boolean): IMidiUniversalPacket; + + + static buildStreamConfigurationNotificationMessage(timestamp: Number, protocol: Number, confirmationWillReceiveJRTimestamps: Boolean, confirmationSendJRTimestamps: Boolean): IMidiUniversalPacket; + + + static buildFunctionBlockDiscoveryMessage(timestamp: Number, functionBlockNumber: Number, requestFlags: MidiFunctionBlockDiscoveryRequests): IMidiUniversalPacket; + + + static buildFunctionBlockInfoNotificationMessage(timestamp: Number, active: Boolean, functionBlockNumber: Number, uiHint: MidiFunctionBlockUIHint, midi10: MidiFunctionBlockMidi10, direction: MidiFunctionBlockDirection, firstGroup: Number, numberOfGroups: Number, midiCIVersionFormat: Number, maxNumberSysEx8Streams: Number): IMidiUniversalPacket; + + + static buildFunctionBlockNameNotificationMessages(timestamp: Number, functionBlockNumber: Number, name: String): Object; + + + static parseFunctionBlockNameNotificationMessages(messages: Object): String; + + + } + + export class MidiUniqueId { + static labelFull: String; + static labelShort: String; + byte4: Number; + byte3: Number; + byte2: Number; + byte1: Number; + asCombined28BitValue: Number; + isBroadcast: Boolean; + isReserved: Boolean; + constructor(); + constructor(combined28BitValue: Number); + constructor(sevenBitByte1: Number, sevenBitByte2: Number, sevenBitByte3: Number, sevenBitByte4: Number); + + static createBroadcast(): MidiUniqueId; + + + static createRandom(): MidiUniqueId; + + + } + + export class MidiVirtualEndpointDevice { + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + suppressHandledMessages: Boolean; + deviceDefinition: MidiVirtualEndpointDeviceDefinition; + functionBlocks: Object; + constructor(); + + updateFunctionBlock(block: MidiFunctionBlock): void; + + updateEndpointName(name: String): void; + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + removeListener(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + on(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + off(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiVirtualEndpointDeviceDefinition { + transportSuppliedDescription: String; + supportsSendingJRTimestamps: Boolean; + supportsReceivingJRTimestamps: Boolean; + supportsMidi2ProtocolMessages: Boolean; + supportsMidi1ProtocolMessages: Boolean; + endpointProductInstanceId: String; + endpointName: String; + deviceFamilyMsb: Number; + deviceFamilyModelMsb: Number; + deviceFamilyModelLsb: Number; + deviceFamilyLsb: Number; + areFunctionBlocksStatic: Boolean; + deviceManufacturerSystemExclusiveId: Object; + functionBlocks: Object; + softwareRevisionLevel: Object; + constructor(); + + } + +} + + + diff --git a/build/electron-projection/projection3/windows.devices.midi2/lib/main.js b/build/electron-projection/projection3/windows.devices.midi2/lib/main.js new file mode 100644 index 000000000..ed1f5c4e9 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/lib/main.js @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation, Nadav Bar, and Felix Rieseberg +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing permissions +// and limitations under the License. + +const path = require('path'); +const fs = require('fs'); + +const npmScope = ''; + +// This little trick makes Node.js Tools for VS load IntelliSense for the module +if (fs.existsSync(path.join(__dirname, 'NodeRT_Windows_Devices_Midi2.d.js)'))) { + module.exports = require('./NodeRT_Windows_Devices_Midi2.d.js'); +} else { + module.exports = require('../build/Release/binding.node'); +} + +var externalReferencedNamespaces = ['Windows.Data.Json', 'Windows.Foundation', 'Windows.Devices.Enumeration', 'Windows.Devices.Midi']; + +if (externalReferencedNamespaces.length > 0) { + var namespaceRegistry = global.__winRtNamespaces__; + + if (!namespaceRegistry) { + namespaceRegistry = {}; + + Object.defineProperty(global, '__winRtNamespaces__', { + configurable: true, + writable: false, + enumerable: false, + value: namespaceRegistry + }); + } + + function requireNamespace(namespace) { + var moduleName = namespace.toLowerCase(); + + if (npmScope) { + moduleName = '@' + npmScope + '/' + moduleName; + } + + var m = require(moduleName); + delete namespaceRegistry[namespace]; + namespaceRegistry[namespace] = m; + return m; + } + + for (var i in externalReferencedNamespaces) { + var ns = externalReferencedNamespaces[i]; + + if (!namespaceRegistry.hasOwnProperty(ns)) { + Object.defineProperty(namespaceRegistry, ns, { + configurable: true, + enumerable: true, + get: requireNamespace.bind(null, ns) + }); + } + } +} diff --git a/build/electron-projection/projection3/windows.devices.midi2/node-async.h b/build/electron-projection/projection3/windows.devices.midi2/node-async.h new file mode 100644 index 000000000..1b57fd458 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/node-async.h @@ -0,0 +1,379 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +#include +#include "nan.h" + +#include +#include +#include + +#if NAUV_UVVERSION < 0x000b17 +#define NODEASYNC_ASYNC_WORK_CB(func) \ + static void __cdecl func(uv_async_t* handle, int) +#define NODEASYNC_IDLE_WORK_CB(func) \ + static void __cdecl func(uv_idle_t* handle, int) +#else +#define NODEASYNC_ASYNC_WORK_CB(func) \ + static void __cdecl func(uv_async_t* handle) +#define NODEASYNC_IDLE_WORK_CB(func) static void __cdecl func(uv_idle_t* handle) +#endif + +namespace NodeUtils { +using Nan::EscapableHandleScope; +using Nan::GetCurrentContext; +using Nan::HandleScope; +using Nan::New; +using Nan::Null; +using Nan::Persistent; +using Nan::Undefined; +using v8::Exception; +using v8::Function; +using v8::Integer; +using v8::Local; +using v8::Object; +using v8::String; +using v8::Value; + +typedef std::function*)> InvokeCallbackDelegate; + +class Async { + public: + template + struct Baton { + int error_code; + std::wstring error_message; + + // Custom data + std::shared_ptr data; + std::shared_ptr result; + std::shared_ptr> callback_args; + unsigned callback_args_size; + + Baton() { callback_args_size = 0; } + + void setCallbackArgs(Local* argv, int argc) { + HandleScope scope; + + callback_info.reset(new Persistent[argc], + [](Persistent* ptr) { delete[] ptr; }); + + callback_args_size = 0; + + for (int i = 0; i < argc; i++) { + // callback_info.get()[i] = argv[i]; + callback_info.get()[i].Reset(argv[i]); + } + } + + virtual ~Baton() { + for (int i = 0; i < callback_args_size; i++) { + callback_info.get()[i].Reset(); + } + } + + private: + uv_work_t request; + std::function doWork; + std::function afterWork; + Nan::Persistent callbackData; + + friend Async; + }; + + private: + class TokenData { + public: + static uv_async_t* NewAsyncToken() { + uv_async_t* asyncHandle = new uv_async_t; + uv_async_init(uv_default_loop(), asyncHandle, AsyncCb); + SetHandleData(asyncHandle->data); + + return asyncHandle; + } + + static uv_async_t* NewAsyncToken(Local callback, + Local receiver) { + uv_async_t* asyncHandle = NewAsyncToken(); + SetHandleCallbackData(asyncHandle->data, callback, receiver); + + return asyncHandle; + } + + static uv_idle_t* NewIdleToken() { + uv_idle_t* idleHandle = new uv_idle_t; + uv_idle_init(uv_default_loop(), idleHandle); + + SetHandleData(idleHandle->data); + return idleHandle; + } + + static uv_idle_t* NewIdleToken(Local callback, + Local receiver) { + uv_idle_t* idleHandle = NewIdleToken(); + SetHandleCallbackData(idleHandle->data, callback, receiver); + + return idleHandle; + } + + virtual ~TokenData() { callbackData.Reset(); } + + private: + static void SetHandleData(void*& handleData) { + handleData = new TokenData(); + } + + static void SetHandleCallbackData(void* handleData, + Local callback, + Local receiver) { + TokenData* Token = static_cast(handleData); + Token->callbackData.Reset(CreateCallbackData(callback, receiver)); + } + + TokenData() {} + + Persistent callbackData; + std::function func; + + friend Async; + }; + + public: + template + static void __cdecl Run( + std::shared_ptr input, + std::function*)> doWork, + std::function*)> afterWork, + Local callback, + Local receiver = Local()) { + HandleScope scope; + Local callbackData = CreateCallbackData(callback, receiver); + + Baton* baton = new Baton(); + baton->request.data = baton; + baton->callbackData.Reset(callbackData); + baton->error_code = 0; + baton->data = input; + baton->doWork = doWork; + baton->afterWork = afterWork; + + uv_queue_work(uv_default_loop(), &baton->request, + AsyncWork, AsyncAfter); + } + + static uv_async_t* __cdecl GetAsyncToken() { + return TokenData::NewAsyncToken(); + } + + static uv_async_t* __cdecl GetAsyncToken( + Local callback, + Local receiver = Local()) { + return TokenData::NewAsyncToken(callback, receiver); + } + + static uv_idle_t* __cdecl GetIdleToken() { return TokenData::NewIdleToken(); } + + static uv_idle_t* __cdecl GetIdleToken( + Local callback, + Local receiver = Local()) { + return TokenData::NewIdleToken(callback, receiver); + } + + static void __cdecl RunOnMain(uv_async_t* async, std::function func) { + TokenData* Token = static_cast(async->data); + Token->func = func; + uv_async_send(async); + } + + static void __cdecl RunOnMain(std::function func) { + uv_async_t* async = GetAsyncToken(); + RunOnMain(async, func); + } + + static void __cdecl RunCallbackOnMain( + uv_async_t* async, + std::function func) { + TokenData* Token = static_cast(async->data); + + InvokeCallbackDelegate invokeCallback = [Token](int argc, + Local* argv) { + if (!Token->callbackData.IsEmpty()) { + Nan::AsyncResource asyncResource(Nan::New("RunCallbackOnMain").ToLocalChecked()); + asyncResource.runInAsyncScope(New(Token->callbackData), + New("callback").ToLocalChecked(), argc, argv); + } + }; + + std::function wrapper = [func, invokeCallback]() { + HandleScope scope; + func(invokeCallback); + }; + + RunOnMain(async, wrapper); + } + + // defers execution of the provided function by creating an idler + // that means, the function will be invoked once the event loop has delivered + // all pending events. + static void __cdecl NextTick(std::function func) { + uv_idle_t* idler = GetIdleToken(); + NextTick(idler, func); + } + + static void __cdecl NextTick(uv_idle_t* idler, std::function func) { + TokenData* Token = static_cast(idler->data); + Token->func = func; + + uv_idle_start(idler, onNextTick); + } + + static void __cdecl RunCallbackOnNextTick( + uv_idle_t* idler, + std::function func) { + TokenData* Token = static_cast(idler->data); + + InvokeCallbackDelegate invokeCallback = [Token](int argc, + Local* argv) { + if (!Token->callbackData.IsEmpty()) { + Nan::AsyncResource asyncResource(Nan::New("RunCallbackOnNextTick").ToLocalChecked()); + asyncResource.runInAsyncScope(New(Token->callbackData), + New("callback").ToLocalChecked(), argc, argv); + } + }; + + std::function wrapper = [func, invokeCallback]() { + HandleScope scope; + func(invokeCallback); + }; + + NextTick(idler, wrapper); + } + + private: + static Local CreateCallbackData(Local callback, + Local receiver) { + EscapableHandleScope scope; + + Local callbackData; + if (!callback.IsEmpty() && !callback->Equals(Nan::GetCurrentContext(), Undefined()).FromMaybe(true)) { + callbackData = New(); + + if (!receiver.IsEmpty()) { + Nan::SetPrototype(callbackData, receiver); + } + + Nan::Set(callbackData, New("callback").ToLocalChecked(), + callback); + + // get the current domain: + Local currentDomain = Undefined(); + + Local process = + Nan::To(Nan::Get(GetCurrentContext()->Global(), + New("process").ToLocalChecked()) + .ToLocalChecked()) + .ToLocalChecked(); + if (!process->Equals(Nan::GetCurrentContext(), Undefined()).FromMaybe(true)) { + currentDomain = process->Get(Nan::GetCurrentContext(), New("domain").ToLocalChecked()).ToLocalChecked(); + } + + Nan::Set(callbackData, New("domain").ToLocalChecked(), + currentDomain); + } + + return scope.Escape(callbackData); + }; + + template + static void __cdecl AsyncWork(uv_work_t* req) { + // No HandleScope! + + Baton* baton = + static_cast*>(req->data); + + // Do work in threadpool here. + // Set baton->error_code/message on failures. + // Set baton->result with a final result object + baton->doWork(baton); + } + + template + static void __cdecl AsyncAfter(uv_work_t* req, int status) { + HandleScope scope; + ; + Baton* baton = + static_cast*>(req->data); + + // typical AfterWorkFunc implementation + // if (baton->error) + //{ + // Local err = Exception::Error(...); + // Local argv[] = { err }; + // baton->setCallbackArgs(argv, _countof(argv)); + //} + // else + //{ + // Local argv[] = { Undefined(), ... }; + // baton->setCallbackArgs(argv, _countof(argv)); + //} + + baton->afterWork(baton); + + if (!baton->callbackData.IsEmpty()) { + // call the callback, using domains and all + int argc = static_cast(baton->callback_args_size); + std::unique_ptr> handlesArr(new Local[argc]); + for (int i = 0; i < argc; i++) { + handlesArr.get()[i] = New(baton->callback_info.get()[i]); + } + + Nan::AsyncResource asyncResource(Nan::New("AsyncAfter").ToLocalChecked()); + asyncResource.callInAsyncScope(New(baton->callbackData), + New("callback").ToLocalChecked(), argc, + handlesArr.get()); + } + + baton->callbackData.Reset(); + delete baton; + } + + // called after the async handle is closed in order to free it's memory + static void __cdecl AyncCloseCb(uv_handle_t* handle) { + if (handle != nullptr) { + uv_async_t* async = reinterpret_cast(handle); + delete async; + } + } + + // Called by run on main in case we are not running on the main thread + NODEASYNC_ASYNC_WORK_CB(AsyncCb) { + auto Token = static_cast(handle->data); + Token->func(); + uv_close((uv_handle_t*)handle, AyncCloseCb); + delete Token; + } + + NODEASYNC_IDLE_WORK_CB(onNextTick) { + std::function* func = + static_cast*>(handle->data); + (*func)(); + delete func; + uv_idle_stop(handle); + delete handle; + } +}; +} // namespace NodeUtils diff --git a/build/electron-projection/projection3/windows.devices.midi2/package-lock.json b/build/electron-projection/projection3/windows.devices.midi2/package-lock.json new file mode 100644 index 000000000..6da549173 --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/package-lock.json @@ -0,0 +1,2508 @@ +{ + "name": "windows.devices.midi2", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "windows.devices.midi2", + "version": "0.1.0", + "license": "Apache-2.0", + "dependencies": { + "nan": "latest" + }, + "devDependencies": { + "@electron/rebuild": "^3.6.0", + "electron": "^29.1.0" + } + }, + "node_modules/@electron/get": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.3.tgz", + "integrity": "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "env-paths": "^2.2.0", + "fs-extra": "^8.1.0", + "got": "^11.8.5", + "progress": "^2.0.3", + "semver": "^6.2.0", + "sumchecker": "^3.0.1" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "global-agent": "^3.0.0" + } + }, + "node_modules/@electron/rebuild": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@electron/rebuild/-/rebuild-3.6.0.tgz", + "integrity": "sha512-zF4x3QupRU3uNGaP5X1wjpmcjfw1H87kyqZ00Tc3HvriV+4gmOGuvQjGNkrJuXdsApssdNyVwLsy+TaeTGGcVw==", + "dev": true, + "dependencies": { + "@malept/cross-spawn-promise": "^2.0.0", + "chalk": "^4.0.0", + "debug": "^4.1.1", + "detect-libc": "^2.0.1", + "fs-extra": "^10.0.0", + "got": "^11.7.0", + "node-abi": "^3.45.0", + "node-api-version": "^0.2.0", + "node-gyp": "^9.0.0", + "ora": "^5.1.0", + "read-binary-file-arch": "^1.0.6", + "semver": "^7.3.5", + "tar": "^6.0.5", + "yargs": "^17.0.1" + }, + "bin": { + "electron-rebuild": "lib/cli.js" + }, + "engines": { + "node": ">=12.13.0" + } + }, + "node_modules/@electron/rebuild/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@electron/rebuild/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/@electron/rebuild/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@electron/rebuild/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/@gar/promisify": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", + "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", + "dev": true + }, + "node_modules/@malept/cross-spawn-promise": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", + "integrity": "sha512-1DpKU0Z5ThltBwjNySMC14g0CkbyhCaz9FkhxqNsZI6uAPJXFS8cMXlBKo26FJ8ZuW6S9GCMcR9IO5k2X5/9Fg==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/malept" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/npm-.malept-cross-spawn-promise?utm_medium=referral&utm_source=npm_fund" + } + ], + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/@npmcli/fs": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-2.1.2.tgz", + "integrity": "sha512-yOJKRvohFOaLqipNtwYB9WugyZKhC/DZC4VYPmpaCzDBrA8YpK3qHZ8/HGscMnE4GqbkLNuVcCnxkeQEdGt6LQ==", + "dev": true, + "dependencies": { + "@gar/promisify": "^1.1.3", + "semver": "^7.3.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@npmcli/fs/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@npmcli/move-file": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/move-file/-/move-file-2.0.1.tgz", + "integrity": "sha512-mJd2Z5TjYWq/ttPLLGqArdtnC74J6bOzg4rMDnN+p1xTacZ2yPRCk2y0oSWQtygLR9YVQXgOcONrwtnk3JupxQ==", + "deprecated": "This functionality has been moved to @npmcli/fs", + "dev": true, + "dependencies": { + "mkdirp": "^1.0.4", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@sindresorhus/is": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", + "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@szmarczak/http-timer": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "dev": true, + "dependencies": { + "defer-to-connect": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@tootallnate/once": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", + "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@types/cacheable-request": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", + "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", + "dev": true, + "dependencies": { + "@types/http-cache-semantics": "*", + "@types/keyv": "^3.1.4", + "@types/node": "*", + "@types/responselike": "^1.0.0" + } + }, + "node_modules/@types/http-cache-semantics": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", + "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==", + "dev": true + }, + "node_modules/@types/keyv": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", + "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "20.11.25", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.25.tgz", + "integrity": "sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/responselike": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", + "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/yauzl": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", + "integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==", + "dev": true, + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dev": true, + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "dependencies": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "dev": true + }, + "node_modules/are-we-there-yet": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", + "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", + "dev": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/boolean": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz", + "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==", + "dev": true, + "optional": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/cacache": { + "version": "16.1.3", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-16.1.3.tgz", + "integrity": "sha512-/+Emcj9DAXxX4cwlLmRI9c166RuL3w30zp4R7Joiv2cQTtTtA+jeuCAjH3ZlGnYS3tKENSrKhAzVVP9GVyzeYQ==", + "dev": true, + "dependencies": { + "@npmcli/fs": "^2.1.0", + "@npmcli/move-file": "^2.0.0", + "chownr": "^2.0.0", + "fs-minipass": "^2.1.0", + "glob": "^8.0.1", + "infer-owner": "^1.0.4", + "lru-cache": "^7.7.1", + "minipass": "^3.1.6", + "minipass-collect": "^1.0.2", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.4", + "mkdirp": "^1.0.4", + "p-map": "^4.0.0", + "promise-inflight": "^1.0.1", + "rimraf": "^3.0.2", + "ssri": "^9.0.0", + "tar": "^6.1.11", + "unique-filename": "^2.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/cacache/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/cacache/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/cacache/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/cacache/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/cacheable-lookup": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", + "dev": true, + "engines": { + "node": ">=10.6.0" + } + }, + "node_modules/cacheable-request": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", + "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", + "dev": true, + "dependencies": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^4.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^6.0.1", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/clone-response": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", + "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", + "dev": true, + "dependencies": { + "mimic-response": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true, + "bin": { + "color-support": "bin.js" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dev": true, + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/decompress-response/node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dev": true, + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "optional": true, + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "optional": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", + "dev": true + }, + "node_modules/detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/detect-node": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", + "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==", + "dev": true, + "optional": true + }, + "node_modules/electron": { + "version": "29.1.0", + "resolved": "https://registry.npmjs.org/electron/-/electron-29.1.0.tgz", + "integrity": "sha512-giJVIm0sWVp+8V1GXrKqKTb+h7no0P3ooYqEd34AD9wMJzGnAeL+usj+R0155/0pdvvP1mgydnA7lcaFA2M9lw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@electron/get": "^2.0.0", + "@types/node": "^20.9.0", + "extract-zip": "^2.0.1" + }, + "bin": { + "electron": "cli.js" + }, + "engines": { + "node": ">= 12.20.55" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, + "optional": true, + "dependencies": { + "iconv-lite": "^0.6.2" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/err-code": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", + "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", + "dev": true + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dev": true, + "optional": true, + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true, + "optional": true + }, + "node_modules/escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "optional": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/exponential-backoff": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", + "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==", + "dev": true + }, + "node_modules/extract-zip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" + }, + "bin": { + "extract-zip": "cli.js" + }, + "engines": { + "node": ">= 10.17.0" + }, + "optionalDependencies": { + "@types/yauzl": "^2.9.1" + } + }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "optional": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gauge": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", + "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", + "dev": true, + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.3", + "console-control-strings": "^1.1.0", + "has-unicode": "^2.0.1", + "signal-exit": "^3.0.7", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dev": true, + "optional": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/global-agent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz", + "integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==", + "dev": true, + "optional": true, + "dependencies": { + "boolean": "^3.0.1", + "es6-error": "^4.1.1", + "matcher": "^3.0.0", + "roarr": "^2.15.3", + "semver": "^7.3.2", + "serialize-error": "^7.0.1" + }, + "engines": { + "node": ">=10.0" + } + }, + "node_modules/global-agent/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "optional": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dev": true, + "optional": true, + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "optional": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/got": { + "version": "11.8.6", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", + "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", + "dev": true, + "dependencies": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.2", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=10.19.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/got?sponsor=1" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "optional": true, + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==", + "dev": true + }, + "node_modules/hasown": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", + "dev": true, + "optional": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-cache-semantics": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", + "dev": true + }, + "node_modules/http-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", + "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", + "dev": true, + "dependencies": { + "@tootallnate/once": "2", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/http2-wrapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "dev": true, + "dependencies": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dev": true, + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dev": true, + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "optional": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/infer-owner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", + "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dev": true, + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-lambda": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", + "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==", + "dev": true + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "dev": true, + "optional": true + }, + "node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-fetch-happen": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.2.1.tgz", + "integrity": "sha512-NgOPbRiaQM10DYXvN3/hhGVI2M5MtITFryzBGxHM5p4wnFxsVCbxkrBrDsk+EZ5OB4jEOT7AjDxtdF+KVEFT7w==", + "dev": true, + "dependencies": { + "agentkeepalive": "^4.2.1", + "cacache": "^16.1.0", + "http-cache-semantics": "^4.1.0", + "http-proxy-agent": "^5.0.0", + "https-proxy-agent": "^5.0.0", + "is-lambda": "^1.0.1", + "lru-cache": "^7.7.1", + "minipass": "^3.1.6", + "minipass-collect": "^1.0.2", + "minipass-fetch": "^2.0.3", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.4", + "negotiator": "^0.6.3", + "promise-retry": "^2.0.1", + "socks-proxy-agent": "^7.0.0", + "ssri": "^9.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/make-fetch-happen/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/matcher": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", + "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==", + "dev": true, + "optional": true, + "dependencies": { + "escape-string-regexp": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-collect": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/minipass-collect/-/minipass-collect-1.0.2.tgz", + "integrity": "sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minipass-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-2.1.2.tgz", + "integrity": "sha512-LT49Zi2/WMROHYoqGgdlQIZh8mLPZmOrN2NdJjMXxYe4nkN6FUyuPuOAOedNJDrx0IRGg9+4guZewtp8hE6TxA==", + "dev": true, + "dependencies": { + "minipass": "^3.1.6", + "minipass-sized": "^1.0.3", + "minizlib": "^2.1.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "optionalDependencies": { + "encoding": "^0.1.13" + } + }, + "node_modules/minipass-flush": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz", + "integrity": "sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minipass-pipeline": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz", + "integrity": "sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-sized": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/minipass-sized/-/minipass-sized-1.0.3.tgz", + "integrity": "sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/nan": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz", + "integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-abi": { + "version": "3.56.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.56.0.tgz", + "integrity": "sha512-fZjdhDOeRcaS+rcpve7XuwHBmktS1nS1gzgghwKUQQ8nTy2FdSDr6ZT8k6YhvlJeHmmQMYiT/IH9hfco5zeW2Q==", + "dev": true, + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-abi/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-api-version": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/node-api-version/-/node-api-version-0.2.0.tgz", + "integrity": "sha512-fthTTsi8CxaBXMaBAD7ST2uylwvsnYxh2PfaScwpMhos6KlSFajXQPcM4ogNE1q2s3Lbz9GCGqeIHC+C6OZnKg==", + "dev": true, + "dependencies": { + "semver": "^7.3.5" + } + }, + "node_modules/node-api-version/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-gyp": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-9.4.1.tgz", + "integrity": "sha512-OQkWKbjQKbGkMf/xqI1jjy3oCTgMKJac58G2+bjZb3fza6gW2YrCSdMQYaoTb70crvE//Gngr4f0AgVHmqHvBQ==", + "dev": true, + "dependencies": { + "env-paths": "^2.2.0", + "exponential-backoff": "^3.1.1", + "glob": "^7.1.4", + "graceful-fs": "^4.2.6", + "make-fetch-happen": "^10.0.3", + "nopt": "^6.0.0", + "npmlog": "^6.0.0", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.2", + "which": "^2.0.2" + }, + "bin": { + "node-gyp": "bin/node-gyp.js" + }, + "engines": { + "node": "^12.13 || ^14.13 || >=16" + } + }, + "node_modules/node-gyp/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/nopt": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz", + "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==", + "dev": true, + "dependencies": { + "abbrev": "^1.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/normalize-url": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", + "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npmlog": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", + "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", + "dev": true, + "dependencies": { + "are-we-there-yet": "^3.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^4.0.3", + "set-blocking": "^2.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dev": true, + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-cancelable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-map": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", + "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", + "dev": true, + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true + }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/promise-inflight": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", + "integrity": "sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==", + "dev": true + }, + "node_modules/promise-retry": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", + "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", + "dev": true, + "dependencies": { + "err-code": "^2.0.2", + "retry": "^0.12.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-binary-file-arch": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/read-binary-file-arch/-/read-binary-file-arch-1.0.6.tgz", + "integrity": "sha512-BNg9EN3DD3GsDXX7Aa8O4p92sryjkmzYYgmgTAc6CA4uGLEDzFfxOxugu21akOxpcXHiEgsYkC6nPsQvLLLmEg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "bin": { + "read-binary-file-arch": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-alpn": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", + "dev": true + }, + "node_modules/responselike": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", + "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", + "dev": true, + "dependencies": { + "lowercase-keys": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/roarr": { + "version": "2.15.4", + "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz", + "integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==", + "dev": true, + "optional": true, + "dependencies": { + "boolean": "^3.0.1", + "detect-node": "^2.0.4", + "globalthis": "^1.0.1", + "json-stringify-safe": "^5.0.1", + "semver-compare": "^1.0.0", + "sprintf-js": "^1.1.2" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "optional": true + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", + "dev": true, + "optional": true + }, + "node_modules/serialize-error": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", + "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==", + "dev": true, + "optional": true, + "dependencies": { + "type-fest": "^0.13.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "dev": true, + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.1.tgz", + "integrity": "sha512-B6w7tkwNid7ToxjZ08rQMT8M9BJAf8DKx8Ft4NivzH0zBUfd6jldGcisJn/RLgxcX3FPNDdNQCUEMMT79b+oCQ==", + "dev": true, + "dependencies": { + "ip-address": "^9.0.5", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks-proxy-agent": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-7.0.0.tgz", + "integrity": "sha512-Fgl0YPZ902wEsAyiQ+idGd1A7rSFx/ayC1CQVMw5P+EQx2V0SgpGtf6OKFhVjPflPUl9YMmEOnmfjCdMUsygww==", + "dev": true, + "dependencies": { + "agent-base": "^6.0.2", + "debug": "^4.3.3", + "socks": "^2.6.2" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "dev": true + }, + "node_modules/ssri": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz", + "integrity": "sha512-o57Wcn66jMQvfHG1FlYbWeZWW/dHZhJXjpIcTfXldXEk5nz5lStPo3mK0OJQfGR3RbZUlbISexbljkJzuEj/8Q==", + "dev": true, + "dependencies": { + "minipass": "^3.1.1" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sumchecker": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", + "integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==", + "dev": true, + "dependencies": { + "debug": "^4.1.0" + }, + "engines": { + "node": ">= 8.0" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", + "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "dev": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tar/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/type-fest": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", + "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/unique-filename": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-2.0.1.tgz", + "integrity": "sha512-ODWHtkkdx3IAR+veKxFV+VBkUMcN+FaqzUUd7IZzt+0zhDZFPFxhlqwPF3YQvMHx1TD0tdgYl+kuPnJ8E6ql7A==", + "dev": true, + "dependencies": { + "unique-slug": "^3.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/unique-slug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-3.0.0.tgz", + "integrity": "sha512-8EyMynh679x/0gqE9fT9oilG+qEt+ibFyqjuVTsZn1+CMxH+XLlpvr2UZx4nVcCwTpx81nICr2JQFkM+HPLq4w==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dev": true, + "dependencies": { + "defaults": "^1.0.3" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } +} diff --git a/build/electron-projection/projection3/windows.devices.midi2/package.json b/build/electron-projection/projection3/windows.devices.midi2/package.json new file mode 100644 index 000000000..9bb8a21ce --- /dev/null +++ b/build/electron-projection/projection3/windows.devices.midi2/package.json @@ -0,0 +1,102 @@ +{ + "name": "windows.devices.midi2", + "version": "0.1.0", + "description": "Use the Windows.Devices.Midi2 UWP API directly from Node.js", + "main": "lib/main.js", + "keywords": [ + "Windows.Devices.Midi2", + "Windows", + "Devices", + "Midi2", + "IMidiEndpointConnectionSettings", + "IMidiEndpointConnectionSource", + "IMidiEndpointMessageProcessingPlugin", + "IMidiMessageReceivedEventSource", + "IMidiServiceMessageProcessingPluginConfiguration", + "IMidiServiceTransportPluginConfiguration", + "IMidiUniversalPacket", + "MidiChannel", + "MidiChannelEndpointListener", + "MidiClock", + "MidiEndpointConnection", + "MidiEndpointDeviceInformation", + "MidiEndpointDeviceInformationAddedEventArgs", + "MidiEndpointDeviceInformationRemovedEventArgs", + "MidiEndpointDeviceInformationUpdatedEventArgs", + "MidiEndpointDeviceWatcher", + "MidiFunctionBlock", + "MidiGroup", + "MidiGroupEndpointListener", + "MidiGroupTerminalBlock", + "MidiMessage128", + "MidiMessage32", + "MidiMessage64", + "MidiMessage96", + "MidiMessageBuilder", + "MidiMessageConverter", + "MidiMessageReceivedEventArgs", + "MidiMessageTypeEndpointListener", + "MidiMessageUtility", + "MidiService", + "MidiServiceConfigurationResponse", + "MidiServiceLoopbackEndpointCreationResult", + "MidiServiceLoopbackEndpointDefinition", + "MidiServiceMessageProcessingPluginInfo", + "MidiServicePingResponse", + "MidiServicePingResponseSummary", + "MidiServiceSessionConnectionInfo", + "MidiServiceSessionInfo", + "MidiServiceTransportPluginInfo", + "MidiSession", + "MidiSessionSettings", + "MidiStreamConfigurationRequestReceivedEventArgs", + "MidiStreamConfigurationRequestedSettings", + "MidiStreamMessageBuilder", + "MidiUniqueId", + "MidiVirtualEndpointDevice", + "MidiVirtualEndpointDeviceDefinition", + "Midi1ChannelVoiceMessageStatus", + "Midi2ChannelVoiceMessageStatus", + "MidiEndpointDeviceInformationFilters", + "MidiEndpointDeviceInformationSortOrder", + "MidiEndpointDevicePurpose", + "MidiEndpointDiscoveryRequests", + "MidiEndpointNativeDataFormat", + "MidiFunctionBlockDirection", + "MidiFunctionBlockDiscoveryRequests", + "MidiFunctionBlockMidi10", + "MidiFunctionBlockUIHint", + "MidiGroupTerminalBlockDirection", + "MidiGroupTerminalBlockProtocol", + "MidiMessageType", + "MidiPacketType", + "MidiProtocol", + "MidiSendMessageResults", + "MidiServiceConfigurationResponseStatus", + "MidiSystemExclusive8Status", + "MidiMessageStruct", + "NodeRT", + "WinRT", + "Microsoft" + ], + "dependencies": { + "nan": "latest" + }, + "repository": { + "type": "git", + "url": "git://github.com/MaySoMusician/NodeRT.git" + }, + "homepage": "https://github.com/MaySoMusician/NodeRT/tree/feature/136-vs2019", + "author": "Generated by NodeRT (modified)", + "contributors": [ + "nadavbar (http://www.nadavos.com)", + "Felix Rieseberg (https://www.felix.fun)", + "MaySoMusician (https://msmsm.work/)" + ], + "gypfile": true, + "license": "Apache-2.0", + "devDependencies": { + "@electron/rebuild": "^3.6.0", + "electron": "^29.1.0" + } +} diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/.npmignore b/build/electron-projection/projection3_backup/windows.devices.midi2/.npmignore new file mode 100644 index 000000000..f5c9ab246 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/.npmignore @@ -0,0 +1,6 @@ +*.vcxproj +*.filters +*.user +Debug +Release +test \ No newline at end of file diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverter.h b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverter.h new file mode 100644 index 000000000..76f6ce371 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverter.h @@ -0,0 +1,280 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once +#include +#include +#include "CollectionsConverterUtils.h" +#include "NodeRtUtils.h" +#include "nan.h" + +namespace NodeRT { +namespace Collections { + +Nan::Persistent g_keyProp; +Nan::Persistent g_valueProp; + +static void initProps() { + if (g_keyProp.IsEmpty()) + g_keyProp.Reset(Nan::New("key").ToLocalChecked()); + + if (g_valueProp.IsEmpty()) + g_valueProp.Reset(Nan::New("value").ToLocalChecked()); +} + +static std::function)> checkStringFunc = + [](v8::Local value) -> bool { return value->IsString(); }; + +template + static ::Platform::Collections::Map ^ + JsArrayToWinrtMap( + v8::Local arr, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map stdMap; + if (!FillMapFromJsArray(arr, checkKeyTypeFunc, convertToKeyTypeFunc, + checkValueTypeFunc, convertToValueTypeFunc, + stdMap)) { + return nullptr; + } + + // TODO: michfa: consider using std::move (here & everywhere), e.g: return + // ref new ::Platform::Collections::Map(std::move(stdMap)); + // std::move will give a more efficient initialization from std::map, will + // invalidate stdMap however- some types will throw while moving + return ref new ::Platform::Collections::Map(stdMap); + } + + template + static ::Platform::Collections::MapView ^ + JsArrayToWinrtMapView( + v8::Local arr, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map stdMap; + if (!FillMapFromJsArray(arr, checkKeyTypeFunc, convertToKeyTypeFunc, + checkValueTypeFunc, convertToValueTypeFunc, + stdMap)) { + return nullptr; + } + + return ref new ::Platform::Collections::MapView(stdMap); + } + + // A special implementation for the case were the map's keys are strings + // In this case we expect a non-array JS object. + template + static ::Platform::Collections::Map ^ + JsObjectToWinrtMap( + v8::Local obj, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map<::Platform::String ^, V> stdMap; + + if (!FillMapFromJsObject( + obj, checkStringFunc, NodeRT::Utils::V8StringToPlatformString, + checkValueTypeFunc, convertToValueTypeFunc, stdMap)) { + return nullptr; + } + + return ref new ::Platform::Collections::Map<::Platform::String ^, V>( + stdMap); + } + + template + static ::Platform::Collections::MapView ^ + JsObjectToWinrtMapView( + v8::Local obj, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::map<::Platform::String ^, V> stdMap; + if (!FillMapFromJsObject( + obj, checkStringFunc, NodeRT::Utils::V8StringToPlatformString, + checkValueTypeFunc, convertToValueTypeFunc, stdMap)) { + return nullptr; + } + + return ref new ::Platform::Collections::MapView<::Platform::String ^, V>( + stdMap); + } + + template + static ::Platform::Collections::Vector ^ + JsArrayToWinrtVector( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::vector vec(arr->Length()); + if (!FillVector&, V>(arr, checkValueTypeFunc, + convertToValueTypeFunc, vec)) { + return nullptr; + } + + return ref new ::Platform::Collections::Vector(vec); + } + + template + static ::Platform::Collections::VectorView ^ + JsArrayToWinrtVectorView( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + std::vector vec(arr->Length()); + + if (!FillVector&, V>(arr, checkValueTypeFunc, + convertToValueTypeFunc, vec)) { + return nullptr; + } + + return ref new ::Platform::Collections::VectorView(vec); + } + + template + static ::Platform::Array ^ + JsArrayToWinrtArray( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + auto vec = ref new ::Platform::Array(arr->Length()); + if (!FillVector<::Platform::Array ^, V>(arr, checkValueTypeFunc, + convertToValueTypeFunc, vec)) { + return nullptr; + } + + return vec; + } +} // namespace Collections + +template +static void InsertToVector( + uint32_t index, + v8::Local value, + const std::function)>& convertToValueTypeFunc, + std::vector& vec) { + vec[index] = convertToValueTypeFunc(value); +} + +template +static void InsertToVector( + uint32_t index, + v8::Local value, + const std::function)>& convertToValueTypeFunc, + ::Platform::Array ^ vec) { + vec->set(index, convertToValueTypeFunc(value)); +} + +// assumption: vec length >= arr length +template +static bool FillVector( + v8::Local arr, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc, + T vec) { + for (uint32_t i = 0; i < arr->Length(); i++) { + Local value = Nan::Get(arr, i).ToLocalChecked(); + + if (!checkValueTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Received array with unexpected value type"))); + return false; + } + + InsertToVector(i, value, convertToValueTypeFunc, vec); + } + + return true; +} + +template +static bool FillMapFromJsArray( + v8::Local arr, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc, + std::map& stdMap) { + initProps(); + + // expect that each element in the array will be an object with 2 properties: + // key and value (with types that match K and V respectively) + for (uint32_t i = 0; i < arr->Length(); i++) { + Local curr = Nan::Get(arr, i).ToLocalChecked(); + + if (!curr->IsObject()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Array elements are expected to be javascript objects"))); + return false; + } + + v8::Local obj = curr.As(); + + if (!obj->Has(g_keyProp) || !obj->Has(g_valueProp)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Array elements are expected to be javascript objects with \'key\' " + L"and \'value\' properties"))); + return false; + } + + Local key = Nan::Get(obj, g_keyProp).ToLocalChecked(); + Local value = Nan::Get(obj, g_valueProp).ToLocalChecked(); + + if (!checkKeyTypeFunc(key)) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Array element has invalid key type"))); + return false; + } + + if (!checkValueTypeFunc(value)) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Array element has invalid value type"))); + return false; + } + + stdMap.insert(std::pair(convertToKeyTypeFunc(key), + convertToValueTypeFunc(value))); + } + + return true; +} + +template +static bool FillMapFromJsObject( + v8::Local obj, + const std::function)>& checkKeyTypeFunc, + const std::function<::Platform::String ^ (v8::Local)>& + convertToKeyTypeFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc, + std::map<::Platform::String ^, V>& stdMap) { + Local objProps = Nan::GetPropertyNames(obj).ToLocalChecked(); + for (uint32_t i = 0; i < objProps->Length(); i++) { + Local key = Nan::Get(objProps, i).ToLocalChecked(); + Local value = Nan::Get(obj, key).ToLocalChecked(); + if (!checkValueTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Received object with unexpected value type"))); + return false; + } + + stdMap.insert(std::pair<::Platform::String ^, V>( + convertToKeyTypeFunc(key), convertToValueTypeFunc(value))); + } + return true; +} +}; // namespace NodeRT diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverterUtils.cpp b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverterUtils.cpp new file mode 100644 index 000000000..be071ac7b --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverterUtils.cpp @@ -0,0 +1,44 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#include "CollectionsConverterUtils.h" + +namespace std { +bool operator==(const ::Windows::Foundation::TimeSpan& first, + const ::Windows::Foundation::TimeSpan& second) { + return first.Duration == second.Duration; +} + +bool operator==( + const ::Windows::Devices::Geolocation::BasicGeoposition& first, + const ::Windows::Devices::Geolocation::BasicGeoposition& second) { + return (first.Altitude == second.Altitude) && + (first.Latitude == second.Latitude) && + (first.Longitude == second.Longitude); +} + +bool operator==(const ::Windows::Storage::Search::SortEntry& first, + const ::Windows::Storage::Search::SortEntry& second) { + return (first.AscendingOrder == second.AscendingOrder) && + (first.PropertyName == second.PropertyName); +} + +bool operator==(const ::Windows::Data::Text::TextSegment& first, + const ::Windows::Data::Text::TextSegment& second) { + return (first.Length == second.Length) && + (first.StartPosition == second.StartPosition); +} + +} // namespace std diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverterUtils.h b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverterUtils.h new file mode 100644 index 000000000..180a443c8 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsConverterUtils.h @@ -0,0 +1,37 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +// Every type used in Vector or VectorView template instantiation must have +// operator== Implement operator== for types that don't have an operator== +// implementation available and there is no acceptable conversion to an existing +// operator== +namespace std { + +bool operator==(const ::Windows::Foundation::TimeSpan& first, + const ::Windows::Foundation::TimeSpan& second); + +bool operator==( + const ::Windows::Devices::Geolocation::BasicGeoposition& first, + const ::Windows::Devices::Geolocation::BasicGeoposition& second); + +bool operator==(const ::Windows::Storage::Search::SortEntry& first, + const ::Windows::Storage::Search::SortEntry& second); + +bool operator==(const ::Windows::Data::Text::TextSegment& first, + const ::Windows::Data::Text::TextSegment& second); + +} // namespace std diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsWrap.h b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsWrap.h new file mode 100644 index 000000000..330453961 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/CollectionsWrap.h @@ -0,0 +1,1989 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. +#pragma once + +#include +#include "NodeRtUtils.h" +#include "OpaqueWrapper.h" +#include "WrapperBase.h" +#include "nan.h" + +#include + +namespace NodeRT { +namespace Collections { + +using Nan::False; +using Nan::HandleScope; +using Nan::MaybeLocal; +using Nan::Null; +using Nan::Persistent; +using Nan::True; +using Nan::Undefined; +using v8::Boolean; +using v8::FunctionTemplate; +using v8::Integer; +using v8::Local; +using v8::String; +using v8::Value; + +template +class ArrayWrapper : NodeRT::WrapperBase { + public: + static void Init() { + EscapableHandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + + localRef->SetClassName( + Nan::New("Windows::Foundation::Array").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + Nan::SetIndexedPropertyHandler(localRef->InstanceTemplate(), Get, Set); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), LengthGetter); + + return; + } + + static Local CreateArrayWrapper( + ::Platform::Array ^ winRtInstance, + const std::function(T)>& getterFunc = nullptr, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + ArrayWrapper* wrapperInstance = new ArrayWrapper( + winRtInstance, getterFunc, checkTypeFunc, convertToTypeFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + ArrayWrapper( + ::Platform::Array ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) + : _instance(winRtInstance), + _getterFunc(getterFunc), + _checkTypeFunc(checkTypeFunc), + _convertToTypeFunc(convertToTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void LengthGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info.This())) { + return; + } + + ArrayWrapper* wrapper = + ArrayWrapper::Unwrap>(info.This()); + + try { + unsigned int result = wrapper->_instance->Length; + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Get(uint32_t index, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info.This())) { + return; + } + + ArrayWrapper* wrapper = + ArrayWrapper::Unwrap>(info.This()); + + if (wrapper->_instance->Length <= index) { + return; + } + + if (wrapper->_getterFunc == nullptr) { + info.GetReturnValue().Set(CreateOpaqueWrapper(wrapper->_instance[index])); + } else { + info.GetReturnValue().Set( + wrapper->_getterFunc(wrapper->_instance[index])); + } + } + + static void Set(uint32_t index, + Local value, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info.This())) { + return; + } + + ArrayWrapper* wrapper = + ArrayWrapper::Unwrap>(info.This()); + + if (wrapper->_checkTypeFunc && !wrapper->_checkTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"The argument to set isn't of the expected type or internal WinRt " + L"object was disposed"))); + return; + } + + if (wrapper->_instance->Length <= index) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Given index exceeded array length"))); + return; + } + + if (wrapper->_convertToTypeFunc) { + try { + wrapper->_instance[index] = wrapper->_convertToTypeFunc(value); + } catch (::Platform::Exception ^ e) { + NodeRT::Utils::ThrowWinRtExceptionInJs(e); + } + } + + return; + } + + private: + ::Platform::Array ^ _instance; + std::function(T)> _getterFunc; + std::function)> _checkTypeFunc; + std::function)> _convertToTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent ArrayWrapper::s_constructorTemplate; + +template +class IteratorWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IIterator") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "getMany", GetMany); + Nan::SetPrototypeMethod(localRef, "moveNext", MoveNext); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("current").ToLocalChecked(), + CurrentGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("hasCurrent").ToLocalChecked(), + HasCurrentGetter); + + return; + } + + static Local CreateIteratorWrapper( + ::Windows::Foundation::Collections::IIterator ^ winRtInstance, + const std::function(T)>& getterFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + IteratorWrapper* wrapperInstance = + new IteratorWrapper(winRtInstance, getterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + IteratorWrapper(::Windows::Foundation::Collections::IIterator ^ + winRtInstance, + const std::function(T)>& getterFunc) + : _instance(winRtInstance), _getterFunc(getterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + info.GetReturnValue().Set(info.This()); + } + + static void MoveNext(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterator ^>(info.This())) { + return; + } + + IteratorWrapper* wrapper = + IteratorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + bool result; + result = wrapper->_instance->MoveNext(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + // Not supporting this for now since we need to initialize the array ourselves + // and don't know which size to use + static void GetMany(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + return; + } + + static void CurrentGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterator ^>(info.This())) { + return; + } + + IteratorWrapper* wrapper = + IteratorWrapper::Unwrap>(info.This()); + + try { + T current = wrapper->_instance->Current; + + if (wrapper->_getterFunc != nullptr) { + info.GetReturnValue().Set(wrapper->_getterFunc(current)); + } else { + info.GetReturnValue().Set(CreateOpaqueWrapper(current)); + } + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void HasCurrentGetter( + Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterator ^>(info.This())) { + return; + } + + IteratorWrapper* wrapper = + IteratorWrapper::Unwrap>(info.This()); + + try { + bool result = wrapper->_instance->HasCurrent; + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IIterator ^ _instance; + std::function(T)> _getterFunc; + static Persistent s_constructorTemplate; +}; + +template +class IterableWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IIterable") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "first", First); + + return; + } + + static Local CreateIterableWrapper( + ::Windows::Foundation::Collections::IIterable ^ winRtInstance, + const std::function(T)>& getterFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + IterableWrapper* wrapperInstance = + new IterableWrapper(winRtInstance, getterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + IterableWrapper(::Windows::Foundation::Collections::IIterable ^ + winRtInstance, + const std::function(T)>& getterFunc) + : _instance(winRtInstance), _getterFunc(getterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This().Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + info.GetReturnValue().Set(info.This()); + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IIterable ^>(info.This())) { + return; + } + + IterableWrapper* wrapper = + IterableWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IIterator ^ result = + wrapper->_instance->First(); + + info.GetReturnValue().Set(IteratorWrapper::CreateIteratorWrapper( + result, wrapper->_getterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + private: + ::Windows::Foundation::Collections::IIterable ^ _instance; + std::function(T)> _getterFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent IterableWrapper::s_constructorTemplate; + +template +Persistent IteratorWrapper::s_constructorTemplate; + +template +class VectorViewWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IVectorView") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + Nan::SetIndexedPropertyHandler(localRef->InstanceTemplate(), Get); + + Nan::SetPrototypeMethod(localRef, "getMany", GetMany); + Nan::SetPrototypeMethod(localRef, "getAt", GetAt); + Nan::SetPrototypeMethod(localRef, "indexOf", IndexOf); + Nan::SetPrototypeMethod(localRef, "first", First); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateVectorViewWrapper( + ::Windows::Foundation::Collections::IVectorView ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + VectorViewWrapper* wrapperInstance = + new VectorViewWrapper(winRtInstance, getterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + VectorViewWrapper( + ::Windows::Foundation::Collections::IVectorView ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) + : _instance(winRtInstance), + _getterFunc(getterFunc), + _checkTypeFunc(checkTypeFunc), + _convertToTypeFunc(convertToTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void Get(uint32_t index, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (wrapper->_instance->Size <= index) { + return; + } + + if (wrapper->_getterFunc == nullptr) { + info.GetReturnValue().Set( + CreateOpaqueWrapper(wrapper->_instance->GetAt(index))); + } else { + info.GetReturnValue().Set( + wrapper->_getterFunc(wrapper->_instance->GetAt(index))); + } + } + + static void GetAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && info[0]->IsUint32()) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + if (index >= wrapper->_instance->Size) { + return; + } + T result; + result = wrapper->_instance->GetAt(index); + + if (wrapper->_getterFunc) { + info.GetReturnValue().Set(wrapper->_getterFunc(result)); + } + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void GetMany(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + return; + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + info.GetReturnValue().Set(IteratorWrapper::CreateIteratorWrapper( + wrapper->_instance->First(), wrapper->_getterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void IndexOf(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + if (wrapper->_convertToTypeFunc == nullptr || + wrapper->_checkTypeFunc == nullptr) { + Nan::ThrowError( + Nan::Error(NodeRT::Utils::NewString(L"Method isn't supported"))); + return; + } + + if (info.Length() == 1 && wrapper->_checkTypeFunc(info[0])) { + try { + T item = wrapper->_convertToTypeFunc(info[0]); + + unsigned int index; + bool result = wrapper->_instance->IndexOf(item, &index); + + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("boolean").ToLocalChecked(), + Nan::New(result)); + Nan::Set(resObj, Nan::New("index").ToLocalChecked(), + Nan::New(index)); + info.GetReturnValue().Set(resObj); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVectorView ^>( + info.This())) { + return; + } + + VectorViewWrapper* wrapper = + VectorViewWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IVectorView ^ _instance; + std::function(T)> _getterFunc; + std::function)> _checkTypeFunc; + std::function)> _convertToTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent VectorViewWrapper::s_constructorTemplate; + +template +class VectorWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IVector") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + Nan::SetIndexedPropertyHandler(localRef->InstanceTemplate(), Get, Set); + + Nan::SetPrototypeMethod(localRef, "getMany", GetMany); + Nan::SetPrototypeMethod(localRef, "getAt", GetAt); + Nan::SetPrototypeMethod(localRef, "indexOf", IndexOf); + Nan::SetPrototypeMethod(localRef, "first", First); + Nan::SetPrototypeMethod(localRef, "append", Append); + Nan::SetPrototypeMethod(localRef, "clear", Clear); + Nan::SetPrototypeMethod(localRef, "getView", GetView); + Nan::SetPrototypeMethod(localRef, "insertAt", InsertAt); + Nan::SetPrototypeMethod(localRef, "removeAt", RemoveAt); + Nan::SetPrototypeMethod(localRef, "removeAtEnd", RemoveAtEnd); + Nan::SetPrototypeMethod(localRef, "replaceAll", ReplaceAll); + Nan::SetPrototypeMethod(localRef, "setAt", SetAt); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateVectorWrapper( + ::Windows::Foundation::Collections::IVector ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + VectorWrapper* wrapperInstance = new VectorWrapper( + winRtInstance, getterFunc, checkTypeFunc, convertToTypeFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + VectorWrapper( + ::Windows::Foundation::Collections::IVector ^ winRtInstance, + const std::function(T)>& getterFunc, + const std::function)>& checkTypeFunc = nullptr, + const std::function)>& convertToTypeFunc = nullptr) + : _instance(winRtInstance), + _getterFunc(getterFunc), + _checkTypeFunc(checkTypeFunc), + _convertToTypeFunc(convertToTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void Get(uint32_t index, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (wrapper->_instance->Size <= index) { + return; + } + + if (wrapper->_getterFunc == nullptr) { + info.GetReturnValue().Set( + CreateOpaqueWrapper(wrapper->_instance->GetAt(index))); + } else { + info.GetReturnValue().Set( + wrapper->_getterFunc(wrapper->_instance->GetAt(index))); + } + } + + static void Set(uint32 index, + Local value, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (!wrapper->_checkTypeFunc(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"The value to set isn't of the expected type"))); + return; + } + + try { + T item = wrapper->_convertToTypeFunc(value); + + wrapper->_instance->SetAt(index, item); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + return; + } + + static void Append(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkTypeFunc(info[0])) { + try { + T value = wrapper->_convertToTypeFunc(info[0]); + + wrapper->_instance->Append(value); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Clear(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + wrapper->_instance->Clear(); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void GetMany(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + return; + } + + static void GetView(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IVectorView ^ result = + wrapper->_instance->GetView(); + info.GetReturnValue().Set(VectorViewWrapper::CreateVectorViewWrapper( + result, wrapper->_getterFunc, wrapper->_checkTypeFunc, + wrapper->_convertToTypeFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void InsertAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 2 && info[0]->IsUint32() && + wrapper->_checkTypeFunc(info[1])) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + T value = wrapper->_convertToTypeFunc(info[1]); + wrapper->_instance->InsertAt(index, value); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void RemoveAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && info[0]->IsUint32()) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + wrapper->_instance->RemoveAt(index); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void RemoveAtEnd(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + wrapper->_instance->RemoveAtEnd(); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ReplaceAll(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && + NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array ^>(info[0])) { + try { + WrapperBase* itemsWrapper = + WrapperBase::Unwrap(info[0].As()); + ::Platform::Array ^ items = + (::Platform::Array ^) itemsWrapper->GetObjectInstance(); + wrapper->_instance->ReplaceAll(items); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && info[0]->IsUint32()) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + if (index >= wrapper->_instance->Size) { + return; + } + T result; + result = wrapper->_instance->GetAt(index); + + if (wrapper->_getterFunc) { + info.GetReturnValue().Set(wrapper->_getterFunc(result)); + } + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SetAt(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 2 && info[0]->IsUint32() && + wrapper->_checkTypeFunc(info[1])) { + try { + unsigned int index = info[0]->Uint32Value(Nan::GetCurrentContext()).FromMaybe(0); + + if (index >= wrapper->_instance->Size) { + return; + } + + T item = wrapper->_convertToTypeFunc(info[1]); + + wrapper->_instance->SetAt(index, item); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + info.GetReturnValue().Set(IteratorWrapper::CreateIteratorWrapper( + wrapper->_instance->First(), wrapper->_getterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void IndexOf(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + if (wrapper->_convertToTypeFunc == nullptr || + wrapper->_checkTypeFunc == nullptr) { + Nan::ThrowError( + Nan::Error(NodeRT::Utils::NewString(L"Method isn't supported"))); + return; + } + + if (info.Length() == 1 && wrapper->_checkTypeFunc(info[0])) { + try { + T item = wrapper->_convertToTypeFunc(info[0]); + + unsigned int index; + bool result = wrapper->_instance->IndexOf(item, &index); + + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("boolean").ToLocalChecked(), + Nan::New(result)); + Nan::Set(resObj, Nan::New("index").ToLocalChecked(), + Nan::New(index)); + info.GetReturnValue().Set(resObj); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IVector ^>(info.This())) { + return; + } + + VectorWrapper* wrapper = + VectorWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IVector ^ _instance; + std::function(T)> _getterFunc; + std::function)> _checkTypeFunc; + std::function)> _convertToTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent VectorWrapper::s_constructorTemplate; + +template +class KeyValuePairWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IKeyValuePair") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("key").ToLocalChecked(), KeyGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("value").ToLocalChecked(), ValueGetter); + + return; + } + + static Local CreateKeyValuePairWrapper( + ::Windows::Foundation::Collections::IKeyValuePair ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function(V)>& valueGetterFunc) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + KeyValuePairWrapper* wrapperInstance = new KeyValuePairWrapper( + winRtInstance, keyGetterFunc, valueGetterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + KeyValuePairWrapper(::Windows::Foundation::Collections::IKeyValuePair ^ + winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function(V)>& valueGetterFunc) + : _instance(winRtInstance), + _keyGetterFunc(keyGetterFunc), + _valueGetterFunc(valueGetterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + info.GetReturnValue().Set(info.This()); + } + + static void KeyGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IKeyValuePair ^>( + info.This())) { + return; + } + + KeyValuePairWrapper* wrapper = + KeyValuePairWrapper::Unwrap>( + info.This()); + + try { + info.GetReturnValue().Set( + wrapper->_keyGetterFunc(wrapper->_instance->Key)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ValueGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IKeyValuePair ^>( + info.This())) { + return; + } + + KeyValuePairWrapper* wrapper = + KeyValuePairWrapper::Unwrap>( + info.This()); + + try { + info.GetReturnValue().Set( + wrapper->_valueGetterFunc(wrapper->_instance->Value)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IKeyValuePair ^ _instance; + std::function(K)> _keyGetterFunc; + std::function(V)> _valueGetterFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent KeyValuePairWrapper::s_constructorTemplate; + +template +class MapViewWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IMapView") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "hasKey", HasKey); + Nan::SetPrototypeMethod(localRef, "lookup", Lookup); + Nan::SetPrototypeMethod(localRef, "split", Split); + Nan::SetPrototypeMethod(localRef, "first", First); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateMapViewWrapper( + ::Windows::Foundation::Collections::IMapView ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + MapViewWrapper* wrapperInstance = + new MapViewWrapper(winRtInstance, keyGetterFunc, checkKeyTypeFunc, + convertToKeyTypeFunc, valueGetterFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + MapViewWrapper(::Windows::Foundation::Collections::IMapView ^ + winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc) + : _instance(winRtInstance), + _keyGetterFunc(keyGetterFunc), + _checkKeyTypeFunc(checkKeyTypeFunc), + _convertToKeyTypeFunc(convertToKeyTypeFunc), + _valueGetterFunc(valueGetterFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void HasKey(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + bool result = wrapper->_instance->HasKey(key); + + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + const std::function(K)>& keyGetter = + wrapper->_keyGetterFunc; + const std::function(V)>& valueGetter = + wrapper->_valueGetterFunc; + info.GetReturnValue().Set( + IteratorWrapper< + ::Windows::Foundation::Collections::IKeyValuePair ^>:: + CreateIteratorWrapper( + wrapper->_instance->First(), + [keyGetter, valueGetter]( + ::Windows::Foundation::Collections::IKeyValuePair ^ + value) { + return KeyValuePairWrapper< + K, V>::CreateKeyValuePairWrapper(value, keyGetter, + valueGetter); + })); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Lookup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + V result = wrapper->_instance->Lookup(key); + + info.GetReturnValue().Set(wrapper->_valueGetterFunc(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Split(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IMapView ^ first; + ::Windows::Foundation::Collections::IMapView ^ second; + + wrapper->_instance->Split(&first, &second); + + Local resObj = Nan::New(); + Nan::Set( + resObj, Nan::New("first").ToLocalChecked(), + MapViewWrapper::CreateMapViewWrapper( + first, wrapper->_keyGetterFunc, wrapper->_checkTypeFunc, + wrapper->_convertToKeyTypeFunc, wrapper->_valueGetterFunc)); + Nan::Set( + resObj, Nan::New("second").ToLocalChecked(), + MapViewWrapper::CreateMapViewWrapper( + second, wrapper->_keyGetterFunc, wrapper->_checkTypeFunc, + wrapper->_convertToKeyTypeFunc, wrapper->_valueGetterFunc)); + info.GetReturnValue().Set(resObj); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMapView ^>( + info.This())) { + return; + } + + MapViewWrapper* wrapper = + MapViewWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IMapView ^ _instance; + std::function)> _checkTypeFunc; + std::function(K)> _keyGetterFunc; + std::function)> _convertToKeyTypeFunc; + std::function(V)> _valueGetterFunc; + std::function)> _checkKeyTypeFunc; + static Persistent s_constructorTemplate; +}; + +template +Persistent MapViewWrapper::s_constructorTemplate; + +template +class MapWrapper : NodeRT::WrapperBase { + public: + static void Init() { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName( + Nan::New("Windows::Foundation::Collections:IMap") + .ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + Nan::SetPrototypeMethod(localRef, "hasKey", HasKey); + Nan::SetPrototypeMethod(localRef, "lookup", Lookup); + Nan::SetPrototypeMethod(localRef, "getView", GetView); + Nan::SetPrototypeMethod(localRef, "clear", Clear); + Nan::SetPrototypeMethod(localRef, "insert", Insert); + Nan::SetPrototypeMethod(localRef, "remove", Remove); + Nan::SetPrototypeMethod(localRef, "first", First); + + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("size").ToLocalChecked(), SizeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), + Nan::New("length").ToLocalChecked(), SizeGetter); + + return; + } + + static Local CreateMapWrapper( + ::Windows::Foundation::Collections::IMap ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) { + EscapableHandleScope scope; + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + if (s_constructorTemplate.IsEmpty()) { + Init(); + } + + v8::Local args[] = {Undefined()}; + Local localRef = + Nan::New(s_constructorTemplate); + Local objectInstance = + Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args) + .ToLocalChecked(); + if (objectInstance.IsEmpty()) { + return scope.Escape(Undefined()); + } + + MapWrapper* wrapperInstance = new MapWrapper( + winRtInstance, keyGetterFunc, checkKeyTypeFunc, convertToKeyTypeFunc, + valueGetterFunc, checkValueTypeFunc, convertToValueTypeFunc); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } + + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + private: + MapWrapper(::Windows::Foundation::Collections::IMap ^ winRtInstance, + const std::function(K)>& keyGetterFunc, + const std::function)>& checkKeyTypeFunc, + const std::function)>& convertToKeyTypeFunc, + const std::function(V)>& valueGetterFunc, + const std::function)>& checkValueTypeFunc, + const std::function)>& convertToValueTypeFunc) + : _instance(winRtInstance), + _keyGetterFunc(keyGetterFunc), + _checkKeyTypeFunc(checkKeyTypeFunc), + _convertToKeyTypeFunc(convertToKeyTypeFunc), + _valueGetterFunc(valueGetterFunc), + _checkValueTypeFunc(checkValueTypeFunc), + _convertToValueTypeFunc(convertToValueTypeFunc) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + NodeRT::Utils::SetHiddenValue( + info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), + True()); + + info.GetReturnValue().Set(info.This()); + } + + static void HasKey(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + bool result = wrapper->_instance->HasKey(key); + + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Remove(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + wrapper->_instance->Remove(key); + + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Insert(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 2 && wrapper->_checkKeyTypeFunc(info[0]) && + wrapper->_checkValueTypeFunc(info[1])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + V value = wrapper->_convertToValueTypeFunc(info[1]); + + bool result = wrapper->_instance->Insert(key, value); + + info.GetReturnValue().Set(Nan::New(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void First(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + const std::function(K)>& keyGetter = + wrapper->_keyGetterFunc; + const std::function(V)>& valueGetter = + wrapper->_valueGetterFunc; + info.GetReturnValue().Set( + IteratorWrapper< + ::Windows::Foundation::Collections::IKeyValuePair ^>:: + CreateIteratorWrapper( + wrapper->_instance->First(), + [keyGetter, valueGetter]( + ::Windows::Foundation::Collections::IKeyValuePair ^ + value) { + return KeyValuePairWrapper< + K, V>::CreateKeyValuePairWrapper(value, keyGetter, + valueGetter); + })); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void Lookup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 1 && wrapper->_checkKeyTypeFunc(info[0])) { + try { + K key = wrapper->_convertToKeyTypeFunc(info[0]); + + V result = wrapper->_instance->Lookup(key); + + info.GetReturnValue().Set(wrapper->_valueGetterFunc(result)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + + return; + } + + static void GetView(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + ::Windows::Foundation::Collections::IMapView ^ result = + wrapper->_instance->GetView(); + + info.GetReturnValue().Set(MapViewWrapper::CreateMapViewWrapper( + result, wrapper->_keyGetterFunc, wrapper->_checkKeyTypeFunc, + wrapper->_convertToKeyTypeFunc, wrapper->_valueGetterFunc)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Clear(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + if (info.Length() == 0) { + try { + wrapper->_instance->Clear(); + return; + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void SizeGetter(Local property, + const Nan::PropertyCallbackInfo& info) { + HandleScope scope; + if (!NodeRT::Utils::IsWinRtWrapperOf< + ::Windows::Foundation::Collections::IMap ^>(info.This())) { + return; + } + + MapWrapper* wrapper = + MapWrapper::Unwrap>(info.This()); + + try { + info.GetReturnValue().Set(Nan::New(wrapper->_instance->Size)); + } catch (Platform::Exception ^ exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + private: + ::Windows::Foundation::Collections::IMap ^ _instance; + + std::function(K)> _keyGetterFunc; + std::function)> _convertToKeyTypeFunc; + std::function)> _checkKeyTypeFunc; + + std::function(V)> _valueGetterFunc; + std::function)> _convertToValueTypeFunc; + std::function)> _checkValueTypeFunc; + + static Persistent s_constructorTemplate; +}; + +template +Persistent MapWrapper::s_constructorTemplate; + +} // namespace Collections +}; // namespace NodeRT diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/LICENSE b/build/electron-projection/projection3_backup/windows.devices.midi2/LICENSE new file mode 100644 index 000000000..ffbdd3201 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/LICENSE @@ -0,0 +1,194 @@ +Copyright 2019, The NodeRT Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +``` +------------------------------------------------------------------------- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +``` diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/NodeRtUtils.cpp b/build/electron-projection/projection3_backup/windows.devices.midi2/NodeRtUtils.cpp new file mode 100644 index 000000000..ff9ca0094 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/NodeRtUtils.cpp @@ -0,0 +1,718 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#include "NodeRtUtils.h" +#include +#include +#include "OpaqueWrapper.h" +#include "nan.h" + +#define WCHART_NOT_BUILTIN_IN_NODE 1 + +namespace NodeRT { +namespace Utils { + +using Nan::EscapableHandleScope; +using Nan::False; +using Nan::HandleScope; +using Nan::MaybeLocal; +using Nan::Null; +using Nan::Persistent; +using Nan::True; +using Nan::Undefined; +using v8::Boolean; +using v8::Date; +using v8::Function; +using v8::FunctionTemplate; +using v8::Local; +using v8::Integer; +using v8::Local; +using v8::Number; +using v8::Object; +using v8::Primitive; +using v8::PropertyAttribute; +using v8::String; +using v8::Value; + +v8::Local WinRtExceptionToJsError(Platform::Exception ^ exception) { + EscapableHandleScope scope; + + if (exception == nullptr) { + return scope.Escape(Undefined()); + } + + // we use casting here in case that wchar_t is not a built-in type + const wchar_t* errorMessage = exception->Message->Data(); + unsigned int length = exception->Message->Length(); + + Local error = Nan::Error( + Nan::New(reinterpret_cast(errorMessage)) + .ToLocalChecked()); + Nan::Set(Nan::To(error).ToLocalChecked(), + Nan::New("HRESULT").ToLocalChecked(), + Nan::New(exception->HResult)); + + return scope.Escape(error); +} + +void ThrowWinRtExceptionInJs(Platform::Exception ^ exception) { + if (exception == nullptr) { + return; + } + + Nan::ThrowError(WinRtExceptionToJsError(exception)); +} + +// creates an object with the following structure: +// { +// "callback" : [callback fuction] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +Local CreateCallbackObjectInDomain(Local callback) { + EscapableHandleScope scope; + + // get the current domain: + MaybeLocal callbackObject = Nan::New(); + + Nan::Set(callbackObject.ToLocalChecked(), + Nan::New("callback").ToLocalChecked(), callback); + + MaybeLocal processVal = + Nan::Get(Nan::GetCurrentContext()->Global(), + Nan::New("process").ToLocalChecked()); + v8::Local process = + Nan::To(processVal.ToLocalChecked()).ToLocalChecked(); + if (process.IsEmpty() || Nan::Equals(process, Undefined()).FromMaybe(true)) { + return scope.Escape(callbackObject.ToLocalChecked()); + } + + MaybeLocal currentDomain = + Nan::Get(process, Nan::New("domain").ToLocalChecked()); + + if (!currentDomain.IsEmpty() && + !Nan::Equals(currentDomain.ToLocalChecked(), Undefined()) + .FromMaybe(true)) { + Nan::Set(callbackObject.ToLocalChecked(), + Nan::New("domain").ToLocalChecked(), + currentDomain.ToLocalChecked()); + } + + return scope.Escape(callbackObject.ToLocalChecked()); +} + +// Calls the callback in the appropriate domwin, expects an object in the +// following format: +// { +// "callback" : [callback function] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +Local CallCallbackInDomain(Local callbackObject, + int argc, + Local argv[]) { + Nan::AsyncResource asyncResource(Nan::New("CallCallbackInDomain").ToLocalChecked()); + return asyncResource.runInAsyncScope( + callbackObject, + Nan::New("callback").ToLocalChecked(), argc, + argv) + .FromMaybe(v8::Local()); +} + +::Platform::Object ^ + GetObjectInstance(Local value) { + // nulls are allowed when a WinRT wrapped object is expected + if (value->IsNull()) { + return nullptr; + } + + WrapperBase* wrapper = Nan::ObjectWrap::Unwrap( + Nan::To(value).ToLocalChecked()); + return wrapper->GetObjectInstance(); + } + + Local NewString(const wchar_t* str) { +#ifdef WCHART_NOT_BUILTIN_IN_NODE + return Nan::New(reinterpret_cast(str)) + .ToLocalChecked(); +#else + return Nan::New(str).ToLocalChecked(); +#endif +} + +const wchar_t* StringToWchar(v8::String::Value& str) { +#ifdef WCHART_NOT_BUILTIN_IN_NODE + return reinterpret_cast(*str); +#else + return *str; +#endif +} + +// Note: current implementation converts any JS value that has a toString method +// to a ::Platform::String^ Changes to this code might break the Collection +// Convertor logic +::Platform::String ^ + V8StringToPlatformString(Local value) { + v8::String::Value stringVal(v8::Isolate::GetCurrent(), value); +#ifdef WCHART_NOT_BUILTIN_IN_NODE + return ref new Platform::String( + reinterpret_cast(*stringVal)); +#else + return ref new Platform::String(*stringVal); +#endif + } + +#ifndef min + size_t min(size_t one, size_t two) { + if (one < two) { + return one; + } + + return two; +} +#endif + +#ifdef WCHART_NOT_BUILTIN_IN_NODE +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const uint16_t* str2) { + int maxCount = static_cast( + min(wcslen(str1), wcslen(reinterpret_cast(str2)))); + return (_wcsnicmp(str1, reinterpret_cast(str2), maxCount) == + 0); +} +#endif + +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const wchar_t* str2) { + int maxCount = static_cast(min(wcslen(str1), wcslen(str2))); + return (_wcsnicmp(str1, str2, maxCount) == 0); +} + +void RegisterNameSpace(const char* ns, Local nsExports) { + HandleScope scope; + Local global = Nan::GetCurrentContext()->Global(); + + if (!Nan::Has(global, + Nan::New("__winRtNamespaces__").ToLocalChecked()) + .FromMaybe(false)) { + Nan::ForceSet(global, + Nan::New("__winRtNamespaces__").ToLocalChecked(), + Nan::New(), + (v8::PropertyAttribute)(v8::PropertyAttribute::DontEnum & + v8::PropertyAttribute::DontDelete)); + } + + MaybeLocal nsObject = Nan::Get( + global, Nan::New("__winRtNamespaces__").ToLocalChecked()); + Nan::Set(Nan::To(nsObject.ToLocalChecked()).ToLocalChecked(), + Nan::New(ns).ToLocalChecked(), nsExports); +} + +Local CreateExternalWinRTObject(const char* ns, + const char* objectName, + ::Platform::Object ^ instance) { + EscapableHandleScope scope; + Local opaqueWrapper = CreateOpaqueWrapper(instance); + + Local global = Nan::GetCurrentContext()->Global(); + if (!Nan::Has(global, + Nan::New("__winRtNamespaces__").ToLocalChecked()) + .FromMaybe(false)) { + return scope.Escape(opaqueWrapper); + } + + Local winRtObj = + Nan::To( + Nan::Get(global, + Nan::New("__winRtNamespaces__").ToLocalChecked()) + .ToLocalChecked()) + .ToLocalChecked(); + + Local nsSymbol = Nan::New(ns).ToLocalChecked(); + if (!Nan::Has(winRtObj, nsSymbol).FromMaybe(false)) { + return scope.Escape(opaqueWrapper); + } + + v8::MaybeLocal maybeLocalRef = Nan::Get(winRtObj, nsSymbol); + + if (maybeLocalRef.IsEmpty()) { + return scope.Escape(opaqueWrapper); + } + + Local nsObjectValue = maybeLocalRef.ToLocalChecked(); + + if (Nan::Equals(nsObjectValue, Undefined()).FromMaybe(false)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( + L"Failed to obtain external namespace object"))); + return Undefined(); + } + + Local nsObject = Nan::To(nsObjectValue).ToLocalChecked(); + + Local objectNameSymbol = + Nan::New(objectName).ToLocalChecked(); + if (!Nan::Has(nsObject, objectNameSymbol).FromMaybe(false)) { + return scope.Escape(opaqueWrapper); + } + + Local objectFunc = + Nan::Get(nsObject, objectNameSymbol).ToLocalChecked().As(); + Local args[] = {opaqueWrapper}; + return scope.Escape( + Nan::NewInstance(objectFunc, _countof(args), args).ToLocalChecked()); +} + +bool IsWinRtWrapper(Local value) { + if (value.IsEmpty() || (!value->IsObject() && !value->IsNull())) { + return false; + } + + // allow passing nulls when a WinRT wrapped object is expected + if (value->IsNull()) { + return true; + } + + if (NodeRT::OpaqueWrapper::IsOpaqueWrapper(value)) { + return true; + } + + Local hiddenVal = + GetHiddenValue(Nan::To(value).ToLocalChecked(), + Nan::New("__winRtInstance__").ToLocalChecked()); + + return (!hiddenVal.IsEmpty() && hiddenVal->IsTrue()); +} + +void SetHiddenValue(Local obj, + Local symbol, + Local data) { + Nan::ForceSet(obj, symbol, data, + static_cast(v8::ReadOnly & v8::DontEnum)); +} + +void SetHiddenValueWithObject(Local obj, + Local symbol, + Local data) { + Nan::ForceSet(obj, symbol, data, + static_cast(v8::ReadOnly & v8::DontEnum)); +} + +Local GetHiddenValue(Local obj, Local symbol) { + return Nan::Get(obj, symbol).ToLocalChecked(); +} + +::Windows::Foundation::TimeSpan TimeSpanFromMilli(int64_t millis) { + ::Windows::Foundation::TimeSpan timeSpan; + timeSpan.Duration = millis * 10000; + + return timeSpan; +} + +::Windows::Foundation::DateTime DateTimeFromJSDate(Local value) { + ::Windows::Foundation::DateTime time; + time.UniversalTime = 0; + if (value->IsDate()) { + // 116444736000000000 = The time in 100 nanoseconds between 1/1/1970(UTC) to + // 1/1/1601(UTC) ux_time = (Current time since 1601 in 100 nano sec + // units)/10000 - 116444736000000000; + time.UniversalTime = value->IntegerValue(Nan::GetCurrentContext()).FromMaybe(0) * 10000 + 116444736000000000; + } + + return time; +} + +Local DateTimeToJS(::Windows::Foundation::DateTime value) { + // 116444736000000000 = The time 100 nanoseconds between 1/1/1970(UTC) to + // 1/1/1601(UTC) ux_time = (Current time since 1601 in 100 nano sec + // units)/10000 - 11644473600000; + return Nan::New(value.UniversalTime / 10000.0 - 11644473600000) + .ToLocalChecked(); +} + +bool StrToGuid(Local value, LPCLSID guid) { + if (value.IsEmpty() || !value->IsString()) { + return false; + } + + v8::String::Value stringVal(v8::Isolate::GetCurrent(), value); + std::wstring guidStr(L"{"); + guidStr += StringToWchar(stringVal); + guidStr += L"}"; + + HRESULT hr = CLSIDFromString(guidStr.c_str(), guid); + if (FAILED(hr)) { + return false; + } + + return true; +} + +bool IsGuid(Local value) { + GUID guid; + return StrToGuid(value, &guid); +} + +::Platform::Guid GuidFromJs(Local value) { + GUID guid; + if (!StrToGuid(value, &guid)) { + return ::Platform::Guid(); + } + + return ::Platform::Guid(guid); +} + +Local GuidToJs(::Platform::Guid guid) { + OLECHAR* bstrGuid; + StringFromCLSID(guid, &bstrGuid); + + Local strVal = NewString(bstrGuid); + CoTaskMemFree(bstrGuid); + return strVal; +} + +Local ColorToJs(::Windows::UI::Color color) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("G").ToLocalChecked(), + Nan::New(color.G)); + Nan::Set(obj, Nan::New("B").ToLocalChecked(), + Nan::New(color.B)); + Nan::Set(obj, Nan::New("A").ToLocalChecked(), + Nan::New(color.A)); + Nan::Set(obj, Nan::New("R").ToLocalChecked(), + Nan::New(color.R)); + + return scope.Escape(obj); +} + +::Windows::UI::Color ColorFromJs(Local value) { + ::Windows::UI::Color retVal = ::Windows::UI::Colors::Black; + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return retVal; + } + + Local obj = Nan::To(value).ToLocalChecked(); + if (!Nan::Has(obj, Nan::New("G").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("G").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + if (!Nan::Has(obj, Nan::New("A").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("A").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + if (!Nan::Has(obj, Nan::New("B").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("B").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + if (!Nan::Has(obj, Nan::New("R").ToLocalChecked()).FromMaybe(false)) { + retVal.G = static_cast( + Nan::To(Nan::Get(obj, Nan::New("R").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0)); + } + + return retVal; +} + +bool IsColor(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + if (!Nan::Has(obj, Nan::New("G").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("A").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("B").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("R").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + return true; +} + +Local RectToJs(::Windows::Foundation::Rect rect) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("bottom").ToLocalChecked(), + Nan::New(rect.Bottom)); + Nan::Set(obj, Nan::New("height").ToLocalChecked(), + Nan::New(rect.Height)); + Nan::Set(obj, Nan::New("left").ToLocalChecked(), + Nan::New(rect.Left)); + Nan::Set(obj, Nan::New("right").ToLocalChecked(), + Nan::New(rect.Right)); + Nan::Set(obj, Nan::New("top").ToLocalChecked(), + Nan::New(rect.Top)); + Nan::Set(obj, Nan::New("width").ToLocalChecked(), + Nan::New(rect.Width)); + Nan::Set(obj, Nan::New("x").ToLocalChecked(), + Nan::New(rect.X)); + Nan::Set(obj, Nan::New("y").ToLocalChecked(), + Nan::New(rect.Y)); + + return scope.Escape(obj); +} + +::Windows::Foundation::Rect RectFromJs(Local value) { + ::Windows::Foundation::Rect rect = ::Windows::Foundation::Rect::Empty; + + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return rect; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + rect.X = static_cast( + Nan::To(Nan::Get(obj, Nan::New("x").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + rect.Y = static_cast( + Nan::To(Nan::Get(obj, Nan::New("y").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + rect.Height = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("height").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + rect.Width = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("width").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + return rect; +} + +bool IsRect(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (!Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + return true; +} + +Local PointToJs(::Windows::Foundation::Point point) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("x").ToLocalChecked(), + Nan::New(point.X)); + Nan::Set(obj, Nan::New("y").ToLocalChecked(), + Nan::New(point.Y)); + + return scope.Escape(obj); +} + +::Windows::Foundation::Point PointFromJs(Local value) { + ::Windows::Foundation::Point point(0, 0); + + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return point; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + point.X = static_cast( + Nan::To(Nan::Get(obj, Nan::New("x").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + point.Y = static_cast( + Nan::To(Nan::Get(obj, Nan::New("y").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + return point; +} + +bool IsPoint(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (!Nan::Has(obj, Nan::New("x").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("y").ToLocalChecked()).FromMaybe(false)) { + return false; + } + + return true; +} + +Local SizeToJs(::Windows::Foundation::Size size) { + EscapableHandleScope scope; + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("height").ToLocalChecked(), + Nan::New(size.Height)); + Nan::Set(obj, Nan::New("width").ToLocalChecked(), + Nan::New(size.Width)); + + return scope.Escape(obj); +} + +::Windows::Foundation::Size SizeFromJs(Local value) { + ::Windows::Foundation::Size size(0, 0); + + if (!value->IsObject()) { + Nan::ThrowError(Nan::Error( + NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return size; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + size.Height = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("height").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + if (Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + size.Width = static_cast( + Nan::To( + Nan::Get(obj, Nan::New("width").ToLocalChecked()) + .ToLocalChecked()) + .FromMaybe(0.0)); + } + + return size; +} + +bool IsSize(Local value) { + if (!value->IsObject()) { + return false; + } + + Local obj = Nan::To(value).ToLocalChecked(); + + if (!Nan::Has(obj, Nan::New("height").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + if (!Nan::Has(obj, Nan::New("width").ToLocalChecked()) + .FromMaybe(false)) { + return false; + } + + return true; +} + +wchar_t GetFirstChar(Local value) { + wchar_t retVal = 0; + + if (!value->IsString()) { + return retVal; + } + + Local str = Nan::To(value).ToLocalChecked(); + if (str->Length() == 0) { + return retVal; + } + + String::Value val(v8::Isolate::GetCurrent(), str); + retVal = (*val)[0]; + return retVal; +} + +Local JsStringFromChar(wchar_t value) { + wchar_t str[2]; + str[0] = value; + str[1] = L'\0'; + + return NewString(str); +} + +::Windows::Foundation::HResult HResultFromJsInt32(int32_t value) { + ::Windows::Foundation::HResult res; + res.Value = value; + return res; +} + +} // namespace Utils +} // namespace NodeRT diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/NodeRtUtils.h b/build/electron-projection/projection3_backup/windows.devices.midi2/NodeRtUtils.h new file mode 100644 index 000000000..a5743648e --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/NodeRtUtils.h @@ -0,0 +1,139 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +#include +#include "nan.h" + +#define WCHART_NOT_BUILTIN_IN_NODE 1 + +namespace NodeRT { +namespace Utils { + +v8::Local WinRtExceptionToJsError(Platform::Exception ^ exception); + +void ThrowWinRtExceptionInJs(Platform::Exception ^ exception); + +// creates an object with the following structure: +// { +// "callback" : [callback function] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +v8::Local CreateCallbackObjectInDomain( + v8::Local callback); + +// Calls the callback in the appropriate domwin, expects an object in the +// following format: +// { +// "callback" : [callback fuction] +// "domain" : [the domain in which the async function/event was +// called/registered] (this is optional) +// } +v8::Local CallCallbackInDomain(v8::Local callbackObject, + int argc, + v8::Local argv[]); + +v8::Local NewString(const wchar_t* str); + +const wchar_t* StringToWchar(v8::String::Value& str); + +::Platform::String ^ V8StringToPlatformString(v8::Local value); + +#ifdef WCHART_NOT_BUILTIN_IN_NODE +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const uint16_t* str2); +#endif + +// compares 2 strings using a case insensitive comparison +bool CaseInsenstiveEquals(const wchar_t* str1, const wchar_t* str2); + +// registers the namespace & required object on the global object +void RegisterNameSpace(const char* ns, v8::Local nsExports); + +v8::Local CreateExternalWinRTObject(const char* ns, + const char* objectName, + ::Platform::Object ^ instance); + +bool IsWinRtWrapper(v8::Local value); + +template +bool IsWinRtWrapperOf(v8::Local value) { + if (!IsWinRtWrapper(value)) { + return false; + } + + if (value->IsNull()) { + return true; + } + + WrapperBase* wrapper = + Nan::ObjectWrap::Unwrap(value.As()); + + if (wrapper->GetObjectInstance() == nullptr) { + return false; + } + + try { + T instance = dynamic_cast(wrapper->GetObjectInstance()); + return (instance != nullptr); + } catch (...) { + return false; + } +} + +::Platform::Object ^ GetObjectInstance(v8::Local value); + +void SetHiddenValue(v8::Local obj, + v8::Local symbol, + v8::Local data); +void SetHiddenValueWithObject(v8::Local obj, + v8::Local symbol, + v8::Local data); +v8::Local GetHiddenValue(v8::Local obj, + v8::Local symbol); + +v8::Local DateTimeToJS(::Windows::Foundation::DateTime value); +::Windows::Foundation::TimeSpan TimeSpanFromMilli(int64_t millis); +::Windows::Foundation::DateTime DateTimeFromJSDate(v8::Local value); + +bool IsGuid(v8::Local value); +::Platform::Guid GuidFromJs(v8::Local value); +v8::Local GuidToJs(::Platform::Guid guid); + +v8::Local ColorToJs(::Windows::UI::Color color); +::Windows::UI::Color ColorFromJs(v8::Local value); +bool IsColor(v8::Local value); + +v8::Local RectToJs(::Windows::Foundation::Rect rect); +::Windows::Foundation::Rect RectFromJs(v8::Local value); +bool IsRect(v8::Local value); + +v8::Local PointToJs(::Windows::Foundation::Point point); +::Windows::Foundation::Point PointFromJs(v8::Local value); +bool IsPoint(v8::Local value); + +v8::Local SizeToJs(::Windows::Foundation::Size size); +::Windows::Foundation::Size SizeFromJs(v8::Local value); +bool IsSize(v8::Local value); + +wchar_t GetFirstChar(v8::Local value); +v8::Local JsStringFromChar(wchar_t value); + +::Windows::Foundation::HResult HResultFromJsInt32(int32_t value); + +} // namespace Utils +} // namespace NodeRT \ No newline at end of file diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/OpaqueWrapper.cpp b/build/electron-projection/projection3_backup/windows.devices.midi2/OpaqueWrapper.cpp new file mode 100644 index 000000000..dda89ede9 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/OpaqueWrapper.cpp @@ -0,0 +1,68 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing permissions +// and limitations under the License. + +#include "OpaqueWrapper.h" +#include "NodeRtUtils.h" + +using v8::String; +using v8::FunctionTemplate; + +Nan::Persistent NodeRT::OpaqueWrapper::s_constructorTemplate; + +void NodeRT::OpaqueWrapper::New(Nan::NAN_METHOD_ARGS_TYPE info) +{ + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winrtOpaqueWrapper__").ToLocalChecked(), Nan::True()); + + info.GetReturnValue().Set(info.This()); +} + + +void NodeRT::OpaqueWrapper::Init() +{ + Nan::HandleScope scope; + // Prepare constructor template + s_constructorTemplate.Reset(Nan::New(New)); + v8::Local localRef = Nan::New(s_constructorTemplate); + localRef->SetClassName(Nan::New("OpaqueWrapper").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); +} + +namespace NodeRT { + v8::Local CreateOpaqueWrapper(::Platform::Object^ winRtInstance) + { + Nan::EscapableHandleScope scope; + if (winRtInstance == nullptr) + { + return scope.Escape(Nan::Undefined()); + } + + v8::Local args[] = { Nan::Undefined() }; + if (OpaqueWrapper::s_constructorTemplate.IsEmpty()) + { + OpaqueWrapper::Init(); + } + + v8::Local localRef = Nan::New(OpaqueWrapper::s_constructorTemplate); + v8::Local objectInstance = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args).ToLocalChecked(); + if (objectInstance.IsEmpty()) + { + return scope.Escape(Nan::Undefined()); + } + OpaqueWrapper* wrapperInstance = new OpaqueWrapper(winRtInstance); + wrapperInstance->Wrap(objectInstance); + return scope.Escape(objectInstance); + } +} + diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/OpaqueWrapper.h b/build/electron-projection/projection3_backup/windows.devices.midi2/OpaqueWrapper.h new file mode 100644 index 000000000..94e9a953f --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/OpaqueWrapper.h @@ -0,0 +1,67 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +#include +#include +#include +#include "NodeRTUtils.h" +#include "WrapperBase.h" +#include "nan.h" +#include "nan_object_wrap.h" + +namespace NodeRT { +class OpaqueWrapperInitializer; + +v8::Local CreateOpaqueWrapper(::Platform::Object ^ wintRtHandle); + +class OpaqueWrapper : public WrapperBase { + public: + virtual ::Platform::Object ^ GetObjectInstance() const override { + return _instance; + } + + static bool IsOpaqueWrapper(v8::Local value) { + if (value.IsEmpty() || !value->IsObject()) { + return false; + } + + v8::Local hiddenVal = NodeRT::Utils::GetHiddenValue( + value.As(), + Nan::New("__winrtOpaqueWrapper__").ToLocalChecked()); + + if (hiddenVal.IsEmpty() || !hiddenVal->IsBoolean()) { + return false; + } + + return hiddenVal->IsTrue(); + } + + private: + OpaqueWrapper(::Platform::Object ^ instance) : _instance(instance) {} + + static void New(Nan::NAN_METHOD_ARGS_TYPE info); + static void Init(); + + private: + ::Platform::Object ^ _instance; + static Nan::Persistent s_constructorTemplate; + + friend OpaqueWrapperInitializer; + friend v8::Local CreateOpaqueWrapper(::Platform::Object ^ + wintRtInstance); +}; +} // namespace NodeRT diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/README.md b/build/electron-projection/projection3_backup/windows.devices.midi2/README.md new file mode 100644 index 000000000..9a88e8db0 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/README.md @@ -0,0 +1,46 @@ +windows.devices.midi2 +===== + +A Node.js wrapper for the Windows.Devices.Midi2 WinRT namespace, compatible with Windows 10 APIs. + +Using this module, you'll be able to consume the Windows.Devices.Midi2 API directly from Node.js. + +This module was automatically generated by NodeRT. +For more information on NodeRT and examples on how to use NodeRT modules, please visit the project page at: https://github.com/NodeRT/NodeRT. + +The API exposed by this module is (almost) the same as the API that is listed in: http://msdn.microsoft.com/en-us/library/windows/apps/Windows.Devices.Midi2.aspx + +The only difference in the API is in the way that asynchronous methods and events are used. (See https://github.com/NodeRT/NodeRT#ConsumingNodeRT for more details) + +This module also contains TypeScript definition files for the API exposed by the module, as well as JavaScript intellisense support for Node.js tools for Visual Studio. + +Prequisites: +============ +* Visual Studio version 2019 and above. (Express Desktop versions also work!) +* Python 2.7 (for node-gyp) +* Important: Updated versions of npm and node-gyp. (Note that the ones that are bundled with node might not be up to date). In order to install latest npm, run: +``` +npm install -g npm +``` + +In order to install latest node-gyp run: +``` +npm install -g node-gyp +``` + +Installation: +============= +In order to install this module, run npm install: + +``` +npm install windows.devices.midi2 +``` + +If you wish to rebuild this module using node-gyp, make sure to use the appropriate VS version using --msvs_version=2012/2013/2015/2017 flag: + +For example: + +``` +cd [module folder path] +node-gyp rebuild --msvs_version=2019 +``` \ No newline at end of file diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/WrapperBase.h b/build/electron-projection/projection3_backup/windows.devices.midi2/WrapperBase.h new file mode 100644 index 000000000..2e935a093 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/WrapperBase.h @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once +#include + +namespace NodeRT { +class WrapperBase : public Nan::ObjectWrap { + public: + virtual ::Platform::Object ^ GetObjectInstance() const = 0; +}; +} // namespace NodeRT \ No newline at end of file diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/_nodert_generated.cpp b/build/electron-projection/projection3_backup/windows.devices.midi2/_nodert_generated.cpp new file mode 100644 index 000000000..caa93b0ec --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/_nodert_generated.cpp @@ -0,0 +1,23019 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing permissions +// and limitations under the License. + +// TODO: Verify that this is is still needed.. +#define NTDDI_VERSION 0x06010000 + +#include +#include "nan.h" +#include +#include +#include "CollectionsConverter.h" +#include "CollectionsWrap.h" +#include "node-async.h" +#include "NodeRtUtils.h" +#include "OpaqueWrapper.h" +#include "WrapperBase.h" + +#using + +// this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search +// Some of the node header files brings windows definitions with the same names as some of the WinRT methods +#undef DocumentProperties +#undef GetObject +#undef CreateEvent +#undef FindText +#undef SendMessage + +const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__"; + +using v8::Array; +using v8::String; +using v8::Value; +using v8::Boolean; +using v8::Integer; +using v8::FunctionTemplate; +using v8::Object; +using v8::Local; +using v8::Function; +using v8::Date; +using v8::Number; +using v8::PropertyAttribute; +using v8::Primitive; +using Nan::HandleScope; +using Nan::Persistent; +using Nan::Undefined; +using Nan::True; +using Nan::False; +using Nan::Null; +using Nan::MaybeLocal; +using Nan::EscapableHandleScope; +using Nan::HandleScope; +using Nan::TryCatch; +using namespace concurrency; + +namespace NodeRT { namespace Windows { namespace Devices { namespace Midi2 { + v8::Local WrapIMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ UnwrapIMidiEndpointConnectionSettings(Local value); + + v8::Local WrapIMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ UnwrapIMidiEndpointConnectionSource(Local value); + + v8::Local WrapIMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ UnwrapIMidiEndpointMessageProcessingPlugin(Local value); + + v8::Local WrapIMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ UnwrapIMidiMessageReceivedEventSource(Local value); + + v8::Local WrapIMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ UnwrapIMidiServiceMessageProcessingPluginConfiguration(Local value); + + v8::Local WrapIMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ UnwrapIMidiServiceTransportPluginConfiguration(Local value); + + v8::Local WrapIMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ wintRtInstance); + ::Windows::Devices::Midi2::IMidiUniversalPacket^ UnwrapIMidiUniversalPacket(Local value); + + v8::Local WrapMidiChannel(::Windows::Devices::Midi2::MidiChannel^ wintRtInstance); + ::Windows::Devices::Midi2::MidiChannel^ UnwrapMidiChannel(Local value); + + v8::Local WrapMidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ wintRtInstance); + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ UnwrapMidiChannelEndpointListener(Local value); + + v8::Local WrapMidiClock(::Windows::Devices::Midi2::MidiClock^ wintRtInstance); + ::Windows::Devices::Midi2::MidiClock^ UnwrapMidiClock(Local value); + + v8::Local WrapMidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointConnection^ UnwrapMidiEndpointConnection(Local value); + + v8::Local WrapMidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ UnwrapMidiEndpointDeviceInformation(Local value); + + v8::Local WrapMidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ UnwrapMidiEndpointDeviceInformationAddedEventArgs(Local value); + + v8::Local WrapMidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ UnwrapMidiEndpointDeviceInformationRemovedEventArgs(Local value); + + v8::Local WrapMidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ UnwrapMidiEndpointDeviceInformationUpdatedEventArgs(Local value); + + v8::Local WrapMidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ wintRtInstance); + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ UnwrapMidiEndpointDeviceWatcher(Local value); + + v8::Local WrapMidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ wintRtInstance); + ::Windows::Devices::Midi2::MidiFunctionBlock^ UnwrapMidiFunctionBlock(Local value); + + v8::Local WrapMidiGroup(::Windows::Devices::Midi2::MidiGroup^ wintRtInstance); + ::Windows::Devices::Midi2::MidiGroup^ UnwrapMidiGroup(Local value); + + v8::Local WrapMidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ wintRtInstance); + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ UnwrapMidiGroupEndpointListener(Local value); + + v8::Local WrapMidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ wintRtInstance); + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ UnwrapMidiGroupTerminalBlock(Local value); + + v8::Local WrapMidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage128^ UnwrapMidiMessage128(Local value); + + v8::Local WrapMidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage32^ UnwrapMidiMessage32(Local value); + + v8::Local WrapMidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage64^ UnwrapMidiMessage64(Local value); + + v8::Local WrapMidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessage96^ UnwrapMidiMessage96(Local value); + + v8::Local WrapMidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageBuilder^ UnwrapMidiMessageBuilder(Local value); + + v8::Local WrapMidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageConverter^ UnwrapMidiMessageConverter(Local value); + + v8::Local WrapMidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ UnwrapMidiMessageReceivedEventArgs(Local value); + + v8::Local WrapMidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ UnwrapMidiMessageTypeEndpointListener(Local value); + + v8::Local WrapMidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ wintRtInstance); + ::Windows::Devices::Midi2::MidiMessageUtility^ UnwrapMidiMessageUtility(Local value); + + v8::Local WrapMidiService(::Windows::Devices::Midi2::MidiService^ wintRtInstance); + ::Windows::Devices::Midi2::MidiService^ UnwrapMidiService(Local value); + + v8::Local WrapMidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ UnwrapMidiServiceConfigurationResponse(Local value); + + v8::Local WrapMidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ UnwrapMidiServiceLoopbackEndpointCreationResult(Local value); + + v8::Local WrapMidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ UnwrapMidiServiceLoopbackEndpointDefinition(Local value); + + v8::Local WrapMidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ UnwrapMidiServiceMessageProcessingPluginInfo(Local value); + + v8::Local WrapMidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServicePingResponse^ UnwrapMidiServicePingResponse(Local value); + + v8::Local WrapMidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ UnwrapMidiServicePingResponseSummary(Local value); + + v8::Local WrapMidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ UnwrapMidiServiceSessionConnectionInfo(Local value); + + v8::Local WrapMidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ UnwrapMidiServiceSessionInfo(Local value); + + v8::Local WrapMidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ wintRtInstance); + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ UnwrapMidiServiceTransportPluginInfo(Local value); + + v8::Local WrapMidiSession(::Windows::Devices::Midi2::MidiSession^ wintRtInstance); + ::Windows::Devices::Midi2::MidiSession^ UnwrapMidiSession(Local value); + + v8::Local WrapMidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ wintRtInstance); + ::Windows::Devices::Midi2::MidiSessionSettings^ UnwrapMidiSessionSettings(Local value); + + v8::Local WrapMidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ wintRtInstance); + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ UnwrapMidiStreamConfigurationRequestReceivedEventArgs(Local value); + + v8::Local WrapMidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ wintRtInstance); + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ UnwrapMidiStreamConfigurationRequestedSettings(Local value); + + v8::Local WrapMidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ wintRtInstance); + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ UnwrapMidiStreamMessageBuilder(Local value); + + v8::Local WrapMidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ wintRtInstance); + ::Windows::Devices::Midi2::MidiUniqueId^ UnwrapMidiUniqueId(Local value); + + v8::Local WrapMidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ wintRtInstance); + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ UnwrapMidiVirtualEndpointDevice(Local value); + + v8::Local WrapMidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ wintRtInstance); + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ UnwrapMidiVirtualEndpointDeviceDefinition(Local value); + + + + + static void InitMidi1ChannelVoiceMessageStatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("Midi1ChannelVoiceMessageStatus").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("noteOff").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::NoteOff))); + Nan::Set(enumObject, Nan::New("noteOn").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::NoteOn))); + Nan::Set(enumObject, Nan::New("polyPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::PolyPressure))); + Nan::Set(enumObject, Nan::New("controlChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::ControlChange))); + Nan::Set(enumObject, Nan::New("programChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::ProgramChange))); + Nan::Set(enumObject, Nan::New("channelPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::ChannelPressure))); + Nan::Set(enumObject, Nan::New("pitchBend").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus::PitchBend))); + } + + static void InitMidi2ChannelVoiceMessageStatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("Midi2ChannelVoiceMessageStatus").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("registeredPerNoteController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RegisteredPerNoteController))); + Nan::Set(enumObject, Nan::New("assignablePerNoteController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::AssignablePerNoteController))); + Nan::Set(enumObject, Nan::New("registeredController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RegisteredController))); + Nan::Set(enumObject, Nan::New("assignableController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::AssignableController))); + Nan::Set(enumObject, Nan::New("relativeRegisteredController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RelativeRegisteredController))); + Nan::Set(enumObject, Nan::New("relativeAssignableController").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::RelativeAssignableController))); + Nan::Set(enumObject, Nan::New("perNotePitchBend").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PerNotePitchBend))); + Nan::Set(enumObject, Nan::New("noteOff").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::NoteOff))); + Nan::Set(enumObject, Nan::New("noteOn").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::NoteOn))); + Nan::Set(enumObject, Nan::New("polyPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PolyPressure))); + Nan::Set(enumObject, Nan::New("controlChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::ControlChange))); + Nan::Set(enumObject, Nan::New("programChange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::ProgramChange))); + Nan::Set(enumObject, Nan::New("channelPressure").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::ChannelPressure))); + Nan::Set(enumObject, Nan::New("pitchBend").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PitchBend))); + Nan::Set(enumObject, Nan::New("perNoteManagement").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus::PerNoteManagement))); + } + + static void InitMidiEndpointDeviceInformationFiltersEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationFilters").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("includeClientUmpNative").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeClientUmpNative))); + Nan::Set(enumObject, Nan::New("includeClientByteStreamNative").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeClientByteStreamNative))); + Nan::Set(enumObject, Nan::New("allTypicalEndpoints").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::AllTypicalEndpoints))); + Nan::Set(enumObject, Nan::New("includeVirtualDeviceResponder").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeVirtualDeviceResponder))); + Nan::Set(enumObject, Nan::New("includeDiagnosticLoopback").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeDiagnosticLoopback))); + Nan::Set(enumObject, Nan::New("includeDiagnosticPing").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters::IncludeDiagnosticPing))); + } + + static void InitMidiEndpointDeviceInformationSortOrderEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationSortOrder").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("none").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::None))); + Nan::Set(enumObject, Nan::New("name").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::Name))); + Nan::Set(enumObject, Nan::New("endpointDeviceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::EndpointDeviceId))); + Nan::Set(enumObject, Nan::New("deviceInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::DeviceInstanceId))); + Nan::Set(enumObject, Nan::New("containerThenName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::ContainerThenName))); + Nan::Set(enumObject, Nan::New("containerThenEndpointDeviceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::ContainerThenEndpointDeviceId))); + Nan::Set(enumObject, Nan::New("containerThenDeviceInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::ContainerThenDeviceInstanceId))); + Nan::Set(enumObject, Nan::New("transportMnemonicThenName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::TransportMnemonicThenName))); + Nan::Set(enumObject, Nan::New("transportMnemonicThenEndpointDeviceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::TransportMnemonicThenEndpointDeviceId))); + Nan::Set(enumObject, Nan::New("transportMnemonicThenDeviceInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder::TransportMnemonicThenDeviceInstanceId))); + } + + static void InitMidiEndpointDevicePurposeEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDevicePurpose").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("normalMessageEndpoint").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::NormalMessageEndpoint))); + Nan::Set(enumObject, Nan::New("virtualDeviceResponder").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::VirtualDeviceResponder))); + Nan::Set(enumObject, Nan::New("inBoxGeneralMidiSynth").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::InBoxGeneralMidiSynth))); + Nan::Set(enumObject, Nan::New("diagnosticLoopback").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::DiagnosticLoopback))); + Nan::Set(enumObject, Nan::New("diagnosticPing").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDevicePurpose::DiagnosticPing))); + } + + static void InitMidiEndpointDiscoveryRequestsEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointDiscoveryRequests").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("none").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::None))); + Nan::Set(enumObject, Nan::New("requestEndpointInfo").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestEndpointInfo))); + Nan::Set(enumObject, Nan::New("requestDeviceIdentity").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestDeviceIdentity))); + Nan::Set(enumObject, Nan::New("requestEndpointName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestEndpointName))); + Nan::Set(enumObject, Nan::New("requestProductInstanceId").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestProductInstanceId))); + Nan::Set(enumObject, Nan::New("requestStreamConfiguration").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests::RequestStreamConfiguration))); + } + + static void InitMidiEndpointNativeDataFormatEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiEndpointNativeDataFormat").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknown").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointNativeDataFormat::Unknown))); + Nan::Set(enumObject, Nan::New("byteStream").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointNativeDataFormat::ByteStream))); + Nan::Set(enumObject, Nan::New("universalMidiPacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiEndpointNativeDataFormat::UniversalMidiPacket))); + } + + static void InitMidiFunctionBlockDirectionEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockDirection").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("undefined").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::Undefined))); + Nan::Set(enumObject, Nan::New("blockInput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::BlockInput))); + Nan::Set(enumObject, Nan::New("blockOutput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::BlockOutput))); + Nan::Set(enumObject, Nan::New("bidirectional").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDirection::Bidirectional))); + } + + static void InitMidiFunctionBlockDiscoveryRequestsEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockDiscoveryRequests").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("none").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests::None))); + Nan::Set(enumObject, Nan::New("requestFunctionBlockInfo").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests::RequestFunctionBlockInfo))); + Nan::Set(enumObject, Nan::New("requestFunctionBlockName").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests::RequestFunctionBlockName))); + } + + static void InitMidiFunctionBlockMidi10Enum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockMidi10").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("not10").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::Not10))); + Nan::Set(enumObject, Nan::New("yesBandwidthUnrestricted").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::YesBandwidthUnrestricted))); + Nan::Set(enumObject, Nan::New("yesBandwidthRestricted").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::YesBandwidthRestricted))); + Nan::Set(enumObject, Nan::New("reserved").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockMidi10::Reserved))); + } + + static void InitMidiFunctionBlockUIHintEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiFunctionBlockUIHint").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknown").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Unknown))); + Nan::Set(enumObject, Nan::New("receiver").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Receiver))); + Nan::Set(enumObject, Nan::New("sender").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Sender))); + Nan::Set(enumObject, Nan::New("bidirectional").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiFunctionBlockUIHint::Bidirectional))); + } + + static void InitMidiGroupTerminalBlockDirectionEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiGroupTerminalBlockDirection").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("bidirectional").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection::Bidirectional))); + Nan::Set(enumObject, Nan::New("blockInput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection::BlockInput))); + Nan::Set(enumObject, Nan::New("blockOutput").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection::BlockOutput))); + } + + static void InitMidiGroupTerminalBlockProtocolEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiGroupTerminalBlockProtocol").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknown").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Unknown))); + Nan::Set(enumObject, Nan::New("midi1Message64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message64))); + Nan::Set(enumObject, Nan::New("midi1Message64WithJitterReduction").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message64WithJitterReduction))); + Nan::Set(enumObject, Nan::New("midi1Message128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message128))); + Nan::Set(enumObject, Nan::New("midi1Message128WithJitterReduction").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi1Message128WithJitterReduction))); + Nan::Set(enumObject, Nan::New("midi2").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi2))); + Nan::Set(enumObject, Nan::New("midi2WithJitterReduction").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol::Midi2WithJitterReduction))); + } + + static void InitMidiMessageTypeEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiMessageType").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("utilityMessage32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::UtilityMessage32))); + Nan::Set(enumObject, Nan::New("systemCommon32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::SystemCommon32))); + Nan::Set(enumObject, Nan::New("midi1ChannelVoice32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::Midi1ChannelVoice32))); + Nan::Set(enumObject, Nan::New("dataMessage64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::DataMessage64))); + Nan::Set(enumObject, Nan::New("midi2ChannelVoice64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::Midi2ChannelVoice64))); + Nan::Set(enumObject, Nan::New("dataMessage128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::DataMessage128))); + Nan::Set(enumObject, Nan::New("futureReserved632").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved632))); + Nan::Set(enumObject, Nan::New("futureReserved732").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved732))); + Nan::Set(enumObject, Nan::New("futureReserved864").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved864))); + Nan::Set(enumObject, Nan::New("futureReserved964").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReserved964))); + Nan::Set(enumObject, Nan::New("futureReservedA64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedA64))); + Nan::Set(enumObject, Nan::New("futureReservedB96").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedB96))); + Nan::Set(enumObject, Nan::New("futureReservedC96").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedC96))); + Nan::Set(enumObject, Nan::New("flexData128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FlexData128))); + Nan::Set(enumObject, Nan::New("futureReservedE128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::FutureReservedE128))); + Nan::Set(enumObject, Nan::New("stream128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiMessageType::Stream128))); + } + + static void InitMidiPacketTypeEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiPacketType").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("unknownOrInvalid").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UnknownOrInvalid))); + Nan::Set(enumObject, Nan::New("universalMidiPacket32").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket32))); + Nan::Set(enumObject, Nan::New("universalMidiPacket64").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket64))); + Nan::Set(enumObject, Nan::New("universalMidiPacket96").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket96))); + Nan::Set(enumObject, Nan::New("universalMidiPacket128").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiPacketType::UniversalMidiPacket128))); + } + + static void InitMidiProtocolEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiProtocol").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("default").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiProtocol::Default))); + Nan::Set(enumObject, Nan::New("midi1").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiProtocol::Midi1))); + Nan::Set(enumObject, Nan::New("midi2").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiProtocol::Midi2))); + } + + static void InitMidiSendMessageResultsEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiSendMessageResults").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("bufferFull").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::BufferFull))); + Nan::Set(enumObject, Nan::New("endpointConnectionClosedOrInvalid").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::EndpointConnectionClosedOrInvalid))); + Nan::Set(enumObject, Nan::New("invalidMessageTypeForWordCount").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::InvalidMessageTypeForWordCount))); + Nan::Set(enumObject, Nan::New("invalidMessageOther").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::InvalidMessageOther))); + Nan::Set(enumObject, Nan::New("dataIndexOutOfRange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::DataIndexOutOfRange))); + Nan::Set(enumObject, Nan::New("timestampOutOfRange").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::TimestampOutOfRange))); + Nan::Set(enumObject, Nan::New("messageListPartiallyProcessed").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::MessageListPartiallyProcessed))); + Nan::Set(enumObject, Nan::New("other").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::Other))); + Nan::Set(enumObject, Nan::New("failed").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::Failed))); + Nan::Set(enumObject, Nan::New("succeeded").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSendMessageResults::Succeeded))); + } + + static void InitMidiServiceConfigurationResponseStatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiServiceConfigurationResponseStatus").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("success").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::Success))); + Nan::Set(enumObject, Nan::New("errorTargetNotFound").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorTargetNotFound))); + Nan::Set(enumObject, Nan::New("errorJsonNullOrEmpty").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorJsonNullOrEmpty))); + Nan::Set(enumObject, Nan::New("errorProcessingJson").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorProcessingJson))); + Nan::Set(enumObject, Nan::New("errorNotImplemented").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorNotImplemented))); + Nan::Set(enumObject, Nan::New("errorOther").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus::ErrorOther))); + } + + static void InitMidiSystemExclusive8StatusEnum(const Local exports) { + HandleScope scope; + + Local enumObject = Nan::New(); + + Nan::Set(exports, Nan::New("MidiSystemExclusive8Status").ToLocalChecked(), enumObject); + Nan::Set(enumObject, Nan::New("completeMessageInSingleMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::CompleteMessageInSingleMessagePacket))); + Nan::Set(enumObject, Nan::New("startMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::StartMessagePacket))); + Nan::Set(enumObject, Nan::New("continueMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::ContinueMessagePacket))); + Nan::Set(enumObject, Nan::New("endMessagePacket").ToLocalChecked(), Nan::New(static_cast(::Windows::Devices::Midi2::MidiSystemExclusive8Status::EndMessagePacket))); + } + + static bool IsMidiMessageStructJsObject(Local value) { + if (!value->IsObject()) { + return false; + } + + Local symbol; + Local obj = Nan::To(value).ToLocalChecked(); + + symbol = Nan::New("word0").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + symbol = Nan::New("word1").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + symbol = Nan::New("word2").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + symbol = Nan::New("word3").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) { + return false; + } + } + + return true; + } + + ::Windows::Devices::Midi2::MidiMessageStruct MidiMessageStructFromJsObject(Local value) { + HandleScope scope; + ::Windows::Devices::Midi2::MidiMessageStruct returnValue; + + if (!value->IsObject()) { + Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object"))); + return returnValue; + } + + Local obj = Nan::To(value).ToLocalChecked(); + Local symbol; + + symbol = Nan::New("word0").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word0 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + symbol = Nan::New("word1").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word1 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + symbol = Nan::New("word2").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word2 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + symbol = Nan::New("word3").ToLocalChecked(); + if (Nan::Has(obj, symbol).FromMaybe(false)) { + returnValue.Word3 = static_cast(Nan::To(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0)); + } + + return returnValue; + } + + Local MidiMessageStructToJsObject(::Windows::Devices::Midi2::MidiMessageStruct value) { + EscapableHandleScope scope; + + Local obj = Nan::New(); + + Nan::Set(obj, Nan::New("word0").ToLocalChecked(), Nan::New(value.Word0)); + Nan::Set(obj, Nan::New("word1").ToLocalChecked(), Nan::New(value.Word1)); + Nan::Set(obj, Nan::New("word2").ToLocalChecked(), Nan::New(value.Word2)); + Nan::Set(obj, Nan::New("word3").ToLocalChecked(), Nan::New(value.Word3)); + + return scope.Escape(obj); + } + + + class IMidiEndpointConnectionSettings : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiEndpointConnectionSettings").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settingsJson").ToLocalChecked(), SettingsJsonGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiEndpointConnectionSettings").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiEndpointConnectionSettings *wrapperInstance = new IMidiEndpointConnectionSettings(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiEndpointConnectionSettings(winRtInstance)); + } + + + + + + static void SettingsJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info.This())) { + return; + } + + IMidiEndpointConnectionSettings *wrapper = IMidiEndpointConnectionSettings::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SettingsJson; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ UnwrapIMidiEndpointConnectionSettings(Local value); + }; + + Persistent IMidiEndpointConnectionSettings::s_constructorTemplate; + + v8::Local WrapIMidiEndpointConnectionSettings(::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiEndpointConnectionSettings::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ UnwrapIMidiEndpointConnectionSettings(Local value) { + return IMidiEndpointConnectionSettings::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiEndpointConnectionSettings(Local exports) { + IMidiEndpointConnectionSettings::Init(exports); + } + + class IMidiEndpointConnectionSource : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiEndpointConnectionSource").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiEndpointConnectionSource").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiEndpointConnectionSource *wrapperInstance = new IMidiEndpointConnectionSource(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointConnectionSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiEndpointConnectionSource(winRtInstance)); + } + + + + + + + + private: + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ UnwrapIMidiEndpointConnectionSource(Local value); + }; + + Persistent IMidiEndpointConnectionSource::s_constructorTemplate; + + v8::Local WrapIMidiEndpointConnectionSource(::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiEndpointConnectionSource::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ UnwrapIMidiEndpointConnectionSource(Local value) { + return IMidiEndpointConnectionSource::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiEndpointConnectionSource(Local exports) { + IMidiEndpointConnectionSource::Init(exports); + } + + class IMidiEndpointMessageProcessingPlugin : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiEndpointMessageProcessingPlugin").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiEndpointMessageProcessingPlugin").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiEndpointMessageProcessingPlugin *wrapperInstance = new IMidiEndpointMessageProcessingPlugin(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiEndpointMessageProcessingPlugin(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info.This())) { + return; + } + + IMidiEndpointMessageProcessingPlugin *wrapper = IMidiEndpointMessageProcessingPlugin::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ UnwrapIMidiEndpointMessageProcessingPlugin(Local value); + }; + + Persistent IMidiEndpointMessageProcessingPlugin::s_constructorTemplate; + + v8::Local WrapIMidiEndpointMessageProcessingPlugin(::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiEndpointMessageProcessingPlugin::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ UnwrapIMidiEndpointMessageProcessingPlugin(Local value) { + return IMidiEndpointMessageProcessingPlugin::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiEndpointMessageProcessingPlugin(Local exports) { + IMidiEndpointMessageProcessingPlugin::Init(exports); + } + + class IMidiMessageReceivedEventSource : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiMessageReceivedEventSource").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiMessageReceivedEventSource").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiMessageReceivedEventSource *wrapperInstance = new IMidiMessageReceivedEventSource(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiMessageReceivedEventSource(winRtInstance)); + } + + + + + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + IMidiMessageReceivedEventSource *wrapper = IMidiMessageReceivedEventSource::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + IMidiMessageReceivedEventSource *wrapper = IMidiMessageReceivedEventSource::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ UnwrapIMidiMessageReceivedEventSource(Local value); + }; + + Persistent IMidiMessageReceivedEventSource::s_constructorTemplate; + + v8::Local WrapIMidiMessageReceivedEventSource(::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiMessageReceivedEventSource::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ UnwrapIMidiMessageReceivedEventSource(Local value) { + return IMidiMessageReceivedEventSource::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiMessageReceivedEventSource(Local exports) { + IMidiMessageReceivedEventSource::Init(exports); + } + + class IMidiServiceMessageProcessingPluginConfiguration : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiServiceMessageProcessingPluginConfiguration").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceId").ToLocalChecked(), EndpointDeviceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isFromConfigurationFile").ToLocalChecked(), IsFromConfigurationFileGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageProcessingPluginId").ToLocalChecked(), MessageProcessingPluginIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("pluginInstanceId").ToLocalChecked(), PluginInstanceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settingsJson").ToLocalChecked(), SettingsJsonGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiServiceMessageProcessingPluginConfiguration").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiServiceMessageProcessingPluginConfiguration *wrapperInstance = new IMidiServiceMessageProcessingPluginConfiguration(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiServiceMessageProcessingPluginConfiguration(winRtInstance)); + } + + + + + + static void EndpointDeviceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsFromConfigurationFileGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsFromConfigurationFile; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageProcessingPluginIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->MessageProcessingPluginId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PluginInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->PluginInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceMessageProcessingPluginConfiguration *wrapper = IMidiServiceMessageProcessingPluginConfiguration::Unwrap(info.This()); + + try { + ::Windows::Data::Json::JsonObject^ result = wrapper->_instance->SettingsJson; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Data.Json", "JsonObject", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ UnwrapIMidiServiceMessageProcessingPluginConfiguration(Local value); + }; + + Persistent IMidiServiceMessageProcessingPluginConfiguration::s_constructorTemplate; + + v8::Local WrapIMidiServiceMessageProcessingPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiServiceMessageProcessingPluginConfiguration::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ UnwrapIMidiServiceMessageProcessingPluginConfiguration(Local value) { + return IMidiServiceMessageProcessingPluginConfiguration::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiServiceMessageProcessingPluginConfiguration(Local exports) { + IMidiServiceMessageProcessingPluginConfiguration::Init(exports); + } + + class IMidiServiceTransportPluginConfiguration : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiServiceTransportPluginConfiguration").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isFromConfigurationFile").ToLocalChecked(), IsFromConfigurationFileGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settingsJson").ToLocalChecked(), SettingsJsonGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportId").ToLocalChecked(), TransportIdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiServiceTransportPluginConfiguration").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiServiceTransportPluginConfiguration *wrapperInstance = new IMidiServiceTransportPluginConfiguration(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiServiceTransportPluginConfiguration(winRtInstance)); + } + + + + + + static void IsFromConfigurationFileGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceTransportPluginConfiguration *wrapper = IMidiServiceTransportPluginConfiguration::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsFromConfigurationFile; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceTransportPluginConfiguration *wrapper = IMidiServiceTransportPluginConfiguration::Unwrap(info.This()); + + try { + ::Windows::Data::Json::JsonObject^ result = wrapper->_instance->SettingsJson; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Data.Json", "JsonObject", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info.This())) { + return; + } + + IMidiServiceTransportPluginConfiguration *wrapper = IMidiServiceTransportPluginConfiguration::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->TransportId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ UnwrapIMidiServiceTransportPluginConfiguration(Local value); + }; + + Persistent IMidiServiceTransportPluginConfiguration::s_constructorTemplate; + + v8::Local WrapIMidiServiceTransportPluginConfiguration(::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiServiceTransportPluginConfiguration::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ UnwrapIMidiServiceTransportPluginConfiguration(Local value) { + return IMidiServiceTransportPluginConfiguration::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiServiceTransportPluginConfiguration(Local exports) { + IMidiServiceTransportPluginConfiguration::Init(exports); + } + + class IMidiUniversalPacket : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("IMidiUniversalPacket").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("IMidiUniversalPacket").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + IMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiUniversalPacket^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + IMidiUniversalPacket *wrapperInstance = new IMidiUniversalPacket(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::IMidiUniversalPacket^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapIMidiUniversalPacket(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info.This())) { + return; + } + + IMidiUniversalPacket *wrapper = IMidiUniversalPacket::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::IMidiUniversalPacket^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapIMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ wintRtInstance); + friend ::Windows::Devices::Midi2::IMidiUniversalPacket^ UnwrapIMidiUniversalPacket(Local value); + }; + + Persistent IMidiUniversalPacket::s_constructorTemplate; + + v8::Local WrapIMidiUniversalPacket(::Windows::Devices::Midi2::IMidiUniversalPacket^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(IMidiUniversalPacket::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ UnwrapIMidiUniversalPacket(Local value) { + return IMidiUniversalPacket::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitIMidiUniversalPacket(Local exports) { + IMidiUniversalPacket::Init(exports); + } + + class MidiChannel : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiChannel").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("index").ToLocalChecked(), IndexGetter, IndexSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("numberForDisplay").ToLocalChecked(), NumberForDisplayGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "isValidChannelIndex", IsValidChannelIndex); + Nan::SetAccessor(constructor, Nan::New("labelFull").ToLocalChecked(), LabelFullGetter); + Nan::SetAccessor(constructor, Nan::New("labelShort").ToLocalChecked(), LabelShortGetter); + + + Nan::Set(exports, Nan::New("MidiChannel").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiChannel(::Windows::Devices::Midi2::MidiChannel^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiChannel^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannel^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsInt32()) + { + try { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiChannel(arg0); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiChannel(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiChannel *wrapperInstance = new MidiChannel(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiChannel^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannel^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiChannel(winRtInstance)); + } + + + + + + static void IsValidChannelIndex(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiChannel::IsValidChannelIndex(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void IndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info.This())) { + return; + } + + MidiChannel *wrapper = MidiChannel::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Index; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IndexSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info.This())) { + return; + } + + MidiChannel *wrapper = MidiChannel::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Index = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NumberForDisplayGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info.This())) { + return; + } + + MidiChannel *wrapper = MidiChannel::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->NumberForDisplay; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void LabelFullGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiChannel::LabelFull; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void LabelShortGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiChannel::LabelShort; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiChannel^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiChannel(::Windows::Devices::Midi2::MidiChannel^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiChannel^ UnwrapMidiChannel(Local value); + }; + + Persistent MidiChannel::s_constructorTemplate; + + v8::Local WrapMidiChannel(::Windows::Devices::Midi2::MidiChannel^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiChannel::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiChannel^ UnwrapMidiChannel(Local value) { + return MidiChannel::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiChannel(Local exports) { + MidiChannel::Init(exports); + } + + class MidiChannelEndpointListener : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiChannelEndpointListener").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventFiringMainMessageReceivedEvent").ToLocalChecked(), PreventFiringMainMessageReceivedEventGetter, PreventFiringMainMessageReceivedEventSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventCallingFurtherListeners").ToLocalChecked(), PreventCallingFurtherListenersGetter, PreventCallingFurtherListenersSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeGroup").ToLocalChecked(), IncludeGroupGetter, IncludeGroupSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeChannels").ToLocalChecked(), IncludeChannelsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiChannelEndpointListener").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannelEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiChannelEndpointListener(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiChannelEndpointListener *wrapperInstance = new MidiChannelEndpointListener(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiChannelEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiChannelEndpointListener(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void PreventFiringMainMessageReceivedEventGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventFiringMainMessageReceivedEvent; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventFiringMainMessageReceivedEvent = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreventCallingFurtherListenersGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventCallingFurtherListeners; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventCallingFurtherListenersSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventCallingFurtherListeners = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeGroupGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiGroup^ result = wrapper->_instance->IncludeGroup; + info.GetReturnValue().Set(WrapMidiGroup(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IncludeGroupSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiGroup^ winRtValue = dynamic_cast<::Windows::Devices::Midi2::MidiGroup^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->IncludeGroup = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeChannelsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiChannel^>^ result = wrapper->_instance->IncludeChannels; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiChannel^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiChannel^ val) -> Local { + return WrapMidiChannel(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiChannel^ { + return UnwrapMidiChannel(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) { + return; + } + + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannelEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiChannelEndpointListener *wrapper = MidiChannelEndpointListener::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiChannelEndpointListener^ UnwrapMidiChannelEndpointListener(Local value); + }; + + Persistent MidiChannelEndpointListener::s_constructorTemplate; + + v8::Local WrapMidiChannelEndpointListener(::Windows::Devices::Midi2::MidiChannelEndpointListener^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiChannelEndpointListener::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiChannelEndpointListener^ UnwrapMidiChannelEndpointListener(Local value) { + return MidiChannelEndpointListener::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiChannelEndpointListener(Local exports) { + MidiChannelEndpointListener::Init(exports); + } + + class MidiClock : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiClock").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "convertTimestampToMicroseconds", ConvertTimestampToMicroseconds); + Nan::SetMethod(constructor, "convertTimestampToMilliseconds", ConvertTimestampToMilliseconds); + Nan::SetMethod(constructor, "convertTimestampToSeconds", ConvertTimestampToSeconds); + Nan::SetMethod(constructor, "offsetTimestampByTicks", OffsetTimestampByTicks); + Nan::SetMethod(constructor, "offsetTimestampByMicroseconds", OffsetTimestampByMicroseconds); + Nan::SetMethod(constructor, "offsetTimestampByMilliseconds", OffsetTimestampByMilliseconds); + Nan::SetMethod(constructor, "offsetTimestampBySeconds", OffsetTimestampBySeconds); + Nan::SetAccessor(constructor, Nan::New("now").ToLocalChecked(), NowGetter); + Nan::SetAccessor(constructor, Nan::New("timestampConstantSendImmediately").ToLocalChecked(), TimestampConstantSendImmediatelyGetter); + Nan::SetAccessor(constructor, Nan::New("timestampFrequency").ToLocalChecked(), TimestampFrequencyGetter); + + + Nan::Set(exports, Nan::New("MidiClock").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiClock(::Windows::Devices::Midi2::MidiClock^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiClock^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiClock^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiClock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiClock *wrapperInstance = new MidiClock(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiClock^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiClock^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiClock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiClock(winRtInstance)); + } + + + + + + static void ConvertTimestampToMicroseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + double result; + result = ::Windows::Devices::Midi2::MidiClock::ConvertTimestampToMicroseconds(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertTimestampToMilliseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + double result; + result = ::Windows::Devices::Midi2::MidiClock::ConvertTimestampToMilliseconds(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertTimestampToSeconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + double result; + result = ::Windows::Devices::Midi2::MidiClock::ConvertTimestampToSeconds(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampByTicks(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampByTicks(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampByMicroseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampByMicroseconds(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampByMilliseconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampByMilliseconds(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void OffsetTimestampBySeconds(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsNumber()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + __int64 arg1 = Nan::To(info[1]).FromMaybe(0); + + unsigned __int64 result; + result = ::Windows::Devices::Midi2::MidiClock::OffsetTimestampBySeconds(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void NowGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + unsigned __int64 result = ::Windows::Devices::Midi2::MidiClock::Now; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void TimestampConstantSendImmediatelyGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + unsigned __int64 result = ::Windows::Devices::Midi2::MidiClock::TimestampConstantSendImmediately; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void TimestampFrequencyGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + unsigned __int64 result = ::Windows::Devices::Midi2::MidiClock::TimestampFrequency; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiClock^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiClock(::Windows::Devices::Midi2::MidiClock^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiClock^ UnwrapMidiClock(Local value); + }; + + Persistent MidiClock::s_constructorTemplate; + + v8::Local WrapMidiClock(::Windows::Devices::Midi2::MidiClock^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiClock::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiClock^ UnwrapMidiClock(Local value) { + return MidiClock::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiClock(Local exports) { + MidiClock::Init(exports); + } + + class MidiEndpointConnection : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointConnection").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "open", Open); + Nan::SetPrototypeMethod(localRef, "addMessageProcessingPlugin", AddMessageProcessingPlugin); + Nan::SetPrototypeMethod(localRef, "removeMessageProcessingPlugin", RemoveMessageProcessingPlugin); + Nan::SetPrototypeMethod(localRef, "sendSingleMessagePacket", SendSingleMessagePacket); + //Nan::SetPrototypeMethod(localRef, "sendSingleMessageStruct", SendSingleMessageStruct); + Nan::SetPrototypeMethod(localRef, "sendSingleMessageWordArray", SendSingleMessageWordArray); + Nan::SetPrototypeMethod(localRef, "sendSingleMessageWords", SendSingleMessageWords); + Nan::SetPrototypeMethod(localRef, "sendSingleMessageBuffer", SendSingleMessageBuffer); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesWordList", SendMultipleMessagesWordList); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesWordArray", SendMultipleMessagesWordArray); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesPacketList", SendMultipleMessagesPacketList); + //Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesStructList", SendMultipleMessagesStructList); + //Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesStructArray", SendMultipleMessagesStructArray); + Nan::SetPrototypeMethod(localRef, "sendMultipleMessagesBuffer", SendMultipleMessagesBuffer); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("connectionId").ToLocalChecked(), ConnectionIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceId").ToLocalChecked(), EndpointDeviceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isOpen").ToLocalChecked(), IsOpenGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageProcessingPlugins").ToLocalChecked(), MessageProcessingPluginsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settings").ToLocalChecked(), SettingsGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "getDeviceSelector", GetDeviceSelector); + Nan::SetMethod(constructor, "sendMessageSucceeded", SendMessageSucceeded); + Nan::SetMethod(constructor, "sendMessageFailed", SendMessageFailed); + + + Nan::Set(exports, Nan::New("MidiEndpointConnection").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointConnection^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointConnection^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointConnection *wrapperInstance = new MidiEndpointConnection(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointConnection^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointConnection^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointConnection(winRtInstance)); + } + + + static void Open(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + bool result; + result = wrapper->_instance->Open(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AddMessageProcessingPlugin(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ arg0 = UnwrapIMidiEndpointMessageProcessingPlugin(info[0]); + + wrapper->_instance->AddMessageProcessingPlugin(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void RemoveMessageProcessingPlugin(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsGuid(info[0])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + + wrapper->_instance->RemoveMessageProcessingPlugin(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendSingleMessagePacket(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiUniversalPacket^ arg0 = UnwrapIMidiUniversalPacket(info[0]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessagePacket(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + // static void SendSingleMessageStruct(Nan::NAN_METHOD_ARGS_TYPE info) { + // HandleScope scope; + + // if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + // return; + // } + + // MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + // if (info.Length() == 3 + // && info[0]->IsNumber() + // && info[1]->IsInt32() + // && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageStruct&^>(info[2])) + // { + // try + // { + // unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + // unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + // ::Windows::Devices::Midi2::MidiMessageStruct arg2 = MidiMessageStructFromJsObject(info[2]); + // + // ::Windows::Devices::Midi2::MidiSendMessageResults result; + // result = wrapper->_instance->SendSingleMessageStruct(arg0, arg1, arg2); + // info.GetReturnValue().Set(Nan::New(static_cast(result))); + // return; + // } catch (Platform::Exception ^exception) { + // NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + // return; + // } + // } + //else { + // Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + // return; + // } + // } + static void SendSingleMessageWordArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsInt32() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[3]) || info[3]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Platform::Array^ arg3 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[3]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWordArray(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendSingleMessageWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1, arg2); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 5 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32() + && info[4]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned int arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageWords(arg0, arg1, arg2, arg3, arg4); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendSingleMessageBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[3])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg3 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[3])); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendSingleMessageBuffer(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendMultipleMessagesWordList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable^>(info[1]) || info[1]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::Collections::IIterable^ arg1 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesWordList(arg0, arg1); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendMultipleMessagesWordArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[3]) || info[3]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Platform::Array^ arg3 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[3]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesWordArray(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void SendMultipleMessagesPacketList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesPacketList(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + // static void SendMultipleMessagesStructList(Nan::NAN_METHOD_ARGS_TYPE info) { + // HandleScope scope; + + // if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + // return; + // } + + // MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + // if (info.Length() == 2 + // && info[0]->IsNumber() + // && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^>(info[1]) || info[1]->IsArray())) + // { + // try + // { + // unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + // ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^ arg1 = + // [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^ + // { + // if (value->IsArray()) + // { + // return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::MidiMessageStruct>(value.As(), + // [](Local value) -> bool { + // return IsMidiMessageStructJsObject(value); + // }, + // [](Local value) -> ::Windows::Devices::Midi2::MidiMessageStruct { + // return MidiMessageStructFromJsObject(value); + // } + // ); + // } + // else + // { + // return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::MidiMessageStruct>^>(NodeRT::Utils::GetObjectInstance(value)); + // } + // } (info[1]); + // + // ::Windows::Devices::Midi2::MidiSendMessageResults result; + // result = wrapper->_instance->SendMultipleMessagesStructList(arg0, arg1); + // info.GetReturnValue().Set(Nan::New(static_cast(result))); + // return; + // } catch (Platform::Exception ^exception) { + // NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + // return; + // } + // } + //else { + // Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + // return; + // } + // } + // static void SendMultipleMessagesStructArray(Nan::NAN_METHOD_ARGS_TYPE info) { + // HandleScope scope; + + // if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + // return; + // } + + // MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + // if (info.Length() == 4 + // && info[0]->IsNumber() + // && info[1]->IsUint32() + // && info[2]->IsUint32() + // && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^>(info[3]) || info[3]->IsArray())) + // { + // try + // { + // unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + // unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + // unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + // ::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^ arg3 = + // [] (v8::Local value) -> ::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^ + // { + // if (value->IsArray()) + // { + // return NodeRT::Collections::JsArrayToWinrtArray<::Windows::Devices::Midi2::MidiMessageStruct>(value.As(), + // [](Local value) -> bool { + // return IsMidiMessageStructJsObject(value); + // }, + // [](Local value) -> ::Windows::Devices::Midi2::MidiMessageStruct { + // return MidiMessageStructFromJsObject(value); + // } + // ); + // } + // else + // { + // return dynamic_cast<::Platform::Array<::Windows::Devices::Midi2::MidiMessageStruct>^>(NodeRT::Utils::GetObjectInstance(value)); + // } + // } (info[3]); + // + // ::Windows::Devices::Midi2::MidiSendMessageResults result; + // result = wrapper->_instance->SendMultipleMessagesStructArray(arg0, arg1, arg2, arg3); + // info.GetReturnValue().Set(Nan::New(static_cast(result))); + // return; + // } catch (Platform::Exception ^exception) { + // NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + // return; + // } + // } + //else { + // Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + // return; + // } + // } + static void SendMultipleMessagesBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[3])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg3 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[3])); + + ::Windows::Devices::Midi2::MidiSendMessageResults result; + result = wrapper->_instance->SendMultipleMessagesBuffer(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void GetDeviceSelector(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiEndpointConnection::GetDeviceSelector(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void SendMessageSucceeded(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiSendMessageResults arg0 = static_cast<::Windows::Devices::Midi2::MidiSendMessageResults>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiEndpointConnection::SendMessageSucceeded(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void SendMessageFailed(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiSendMessageResults arg0 = static_cast<::Windows::Devices::Midi2::MidiSendMessageResults>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiEndpointConnection::SendMessageFailed(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void ConnectionIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->ConnectionId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsOpenGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsOpen; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageProcessingPluginsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>^ result = wrapper->_instance->MessageProcessingPlugins; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ val) -> Local { + return WrapIMidiEndpointMessageProcessingPlugin(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiEndpointMessageProcessingPlugin^ { + return UnwrapIMidiEndpointMessageProcessingPlugin(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) { + return; + } + + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ result = wrapper->_instance->Settings; + info.GetReturnValue().Set(WrapIMidiEndpointConnectionSettings(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointConnection^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointConnection *wrapper = MidiEndpointConnection::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiEndpointConnection^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointConnection^ UnwrapMidiEndpointConnection(Local value); + }; + + Persistent MidiEndpointConnection::s_constructorTemplate; + + v8::Local WrapMidiEndpointConnection(::Windows::Devices::Midi2::MidiEndpointConnection^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointConnection::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointConnection^ UnwrapMidiEndpointConnection(Local value) { + return MidiEndpointConnection::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointConnection(Local exports) { + MidiEndpointConnection::Init(exports); + } + + class MidiEndpointDeviceInformation : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformation").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "updateFromDeviceInformation", UpdateFromDeviceInformation); + Nan::SetPrototypeMethod(localRef, "updateFromDeviceInformationUpdate", UpdateFromDeviceInformationUpdate); + Nan::SetPrototypeMethod(localRef, "getParentDeviceInformation", GetParentDeviceInformation); + Nan::SetPrototypeMethod(localRef, "getContainerInformation", GetContainerInformation); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("configuredProtocol").ToLocalChecked(), ConfiguredProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("configuredToReceiveJRTimestamps").ToLocalChecked(), ConfiguredToReceiveJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("configuredToSendJRTimestamps").ToLocalChecked(), ConfiguredToSendJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("containerId").ToLocalChecked(), ContainerIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyLsb").ToLocalChecked(), DeviceIdentityDeviceFamilyLsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyModelNumberLsb").ToLocalChecked(), DeviceIdentityDeviceFamilyModelNumberLsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyModelNumberMsb").ToLocalChecked(), DeviceIdentityDeviceFamilyModelNumberMsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityDeviceFamilyMsb").ToLocalChecked(), DeviceIdentityDeviceFamilyMsbGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentityLastUpdateTime").ToLocalChecked(), DeviceIdentityLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentitySoftwareRevisionLevel").ToLocalChecked(), DeviceIdentitySoftwareRevisionLevelGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceIdentitySystemExclusiveId").ToLocalChecked(), DeviceIdentitySystemExclusiveIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceInstanceId").ToLocalChecked(), DeviceInstanceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointConfigurationLastUpdateTime").ToLocalChecked(), EndpointConfigurationLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointInformationLastUpdateTime").ToLocalChecked(), EndpointInformationLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointPurpose").ToLocalChecked(), EndpointPurposeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointSuppliedName").ToLocalChecked(), EndpointSuppliedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointSuppliedNameLastUpdateTime").ToLocalChecked(), EndpointSuppliedNameLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlockCount").ToLocalChecked(), FunctionBlockCountGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocks").ToLocalChecked(), FunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocksLastUpdateTime").ToLocalChecked(), FunctionBlocksLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("groupTerminalBlocks").ToLocalChecked(), GroupTerminalBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("hasStaticFunctionBlocks").ToLocalChecked(), HasStaticFunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("manufacturerName").ToLocalChecked(), ManufacturerNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("nativeDataFormat").ToLocalChecked(), NativeDataFormatGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("productInstanceId").ToLocalChecked(), ProductInstanceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("productInstanceIdLastUpdateTime").ToLocalChecked(), ProductInstanceIdLastUpdateTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("properties").ToLocalChecked(), PropertiesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("recommendedCCAutomationIntervalMS").ToLocalChecked(), RecommendedCCAutomationIntervalMSGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requiresNoteOffTranslation").ToLocalChecked(), RequiresNoteOffTranslationGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMajor").ToLocalChecked(), SpecificationVersionMajorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMinor").ToLocalChecked(), SpecificationVersionMinorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi10Protocol").ToLocalChecked(), SupportsMidi10ProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi20Protocol").ToLocalChecked(), SupportsMidi20ProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMultiClient").ToLocalChecked(), SupportsMultiClientGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsReceivingJRTimestamps").ToLocalChecked(), SupportsReceivingJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsSendingJRTimestamps").ToLocalChecked(), SupportsSendingJRTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportId").ToLocalChecked(), TransportIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportMnemonic").ToLocalChecked(), TransportMnemonicGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedDescription").ToLocalChecked(), TransportSuppliedDescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedName").ToLocalChecked(), TransportSuppliedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedProductId").ToLocalChecked(), TransportSuppliedProductIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedSerialNumber").ToLocalChecked(), TransportSuppliedSerialNumberGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedVendorId").ToLocalChecked(), TransportSuppliedVendorIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedDescription").ToLocalChecked(), UserSuppliedDescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedLargeImagePath").ToLocalChecked(), UserSuppliedLargeImagePathGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedName").ToLocalChecked(), UserSuppliedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("userSuppliedSmallImagePath").ToLocalChecked(), UserSuppliedSmallImagePathGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createFromId", CreateFromId); + Nan::SetMethod(constructor, "findAll", FindAll); + Nan::SetMethod(constructor, "getAdditionalPropertiesList", GetAdditionalPropertiesList); + Nan::SetMethod(constructor, "deviceMatchesFilter", DeviceMatchesFilter); + Nan::SetAccessor(constructor, Nan::New("diagnosticsLoopbackAEndpointId").ToLocalChecked(), DiagnosticsLoopbackAEndpointIdGetter); + Nan::SetAccessor(constructor, Nan::New("diagnosticsLoopbackBEndpointId").ToLocalChecked(), DiagnosticsLoopbackBEndpointIdGetter); + Nan::SetAccessor(constructor, Nan::New("endpointInterfaceClass").ToLocalChecked(), EndpointInterfaceClassGetter); + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformation").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformation^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformation *wrapperInstance = new MidiEndpointDeviceInformation(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformation^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformation(winRtInstance)); + } + + + static void UpdateFromDeviceInformation(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Enumeration::DeviceInformation^>(info[0])) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformation^ arg0 = dynamic_cast<::Windows::Devices::Enumeration::DeviceInformation^>(NodeRT::Utils::GetObjectInstance(info[0])); + + bool result; + result = wrapper->_instance->UpdateFromDeviceInformation(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void UpdateFromDeviceInformationUpdate(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Enumeration::DeviceInformationUpdate^>(info[0])) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformationUpdate^ arg0 = dynamic_cast<::Windows::Devices::Enumeration::DeviceInformationUpdate^>(NodeRT::Utils::GetObjectInstance(info[0])); + + bool result; + result = wrapper->_instance->UpdateFromDeviceInformationUpdate(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetParentDeviceInformation(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformation^ result; + result = wrapper->_instance->GetParentDeviceInformation(); + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformation", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetContainerInformation(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Enumeration::DeviceInformation^ result; + result = wrapper->_instance->GetContainerInformation(); + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformation", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CreateFromId(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::CreateFromId(arg0); + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformation(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void FindAll(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::FindAll(); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ { + return UnwrapMidiEndpointDeviceInformation(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder arg0 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder>(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::FindAll(arg0); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ { + return UnwrapMidiEndpointDeviceInformation(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsInt32() + && info[1]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder arg0 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationSortOrder>(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters arg1 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters>(Nan::To(info[1]).FromMaybe(0)); + + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::FindAll(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ { + return UnwrapMidiEndpointDeviceInformation(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetAdditionalPropertiesList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::GetAdditionalPropertiesList(); + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Platform::String^>::CreateVectorViewWrapper(result, + [](::Platform::String^ val) -> Local { + return NodeRT::Utils::NewString(val->Data()); + }, + [](Local value) -> bool { + return value->IsString(); + }, + [](Local value) -> ::Platform::String^ { + return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void DeviceMatchesFilter(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info[0]) + && info[1]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ arg0 = UnwrapMidiEndpointDeviceInformation(info[0]); + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters arg1 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters>(Nan::To(info[1]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::DeviceMatchesFilter(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConfiguredProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiProtocol result = wrapper->_instance->ConfiguredProtocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ConfiguredToReceiveJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->ConfiguredToReceiveJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ConfiguredToSendJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->ConfiguredToSendJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ContainerIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->ContainerId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyModelNumberLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyModelNumberLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyModelNumberMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyModelNumberMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityDeviceFamilyMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceIdentityDeviceFamilyMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentityLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->DeviceIdentityLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentitySoftwareRevisionLevelGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Array^ result = wrapper->_instance->DeviceIdentitySoftwareRevisionLevel; + info.GetReturnValue().Set(NodeRT::Collections::ArrayWrapper::CreateArrayWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceIdentitySystemExclusiveIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Array^ result = wrapper->_instance->DeviceIdentitySystemExclusiveId; + info.GetReturnValue().Set(NodeRT::Collections::ArrayWrapper::CreateArrayWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->DeviceInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointConfigurationLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EndpointConfigurationLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointInformationLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EndpointInformationLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointPurposeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiEndpointDevicePurpose result = wrapper->_instance->EndpointPurpose; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointSuppliedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointSuppliedName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointSuppliedNameLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EndpointSuppliedNameLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlockCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->FunctionBlockCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView^ result = wrapper->_instance->FunctionBlocks; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper::CreateMapViewWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + }, + [](::Windows::Devices::Midi2::MidiFunctionBlock^ val) -> Local { + return WrapMidiFunctionBlock(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->FunctionBlocksLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void GroupTerminalBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>^ result = wrapper->_instance->GroupTerminalBlocks; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiGroupTerminalBlock^ val) -> Local { + return WrapMidiGroupTerminalBlock(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ { + return UnwrapMidiGroupTerminalBlock(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void HasStaticFunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->HasStaticFunctionBlocks; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ManufacturerNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ManufacturerName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NativeDataFormatGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiEndpointNativeDataFormat result = wrapper->_instance->NativeDataFormat; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProductInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ProductInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProductInstanceIdLastUpdateTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->ProductInstanceIdLastUpdateTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PropertiesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView<::Platform::String^, ::Platform::Object^>^ result = wrapper->_instance->Properties; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper<::Platform::String^,::Platform::Object^>::CreateMapViewWrapper(result, + [](::Platform::String^ val) -> Local { + return NodeRT::Utils::NewString(val->Data()); + }, + [](Local value) -> bool { + return value->IsString(); + }, + [](Local value) -> ::Platform::String^ { + return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + }, + [](::Platform::Object^ val) -> Local { + return CreateOpaqueWrapper(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RecommendedCCAutomationIntervalMSGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->RecommendedCCAutomationIntervalMS; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequiresNoteOffTranslationGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequiresNoteOffTranslation; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMajorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMajor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMinorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMinor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi10ProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi10Protocol; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi20ProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi20Protocol; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMultiClientGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMultiClient; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsReceivingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsReceivingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsSendingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsSendingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->TransportId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportMnemonicGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportMnemonic; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedDescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedDescription; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedProductIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->TransportSuppliedProductId; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedSerialNumberGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedSerialNumber; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedVendorIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->TransportSuppliedVendorId; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedDescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedDescription; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedLargeImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedLargeImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UserSuppliedSmallImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>(info.This())) { + return; + } + + MidiEndpointDeviceInformation *wrapper = MidiEndpointDeviceInformation::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UserSuppliedSmallImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void DiagnosticsLoopbackAEndpointIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::DiagnosticsLoopbackAEndpointId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void DiagnosticsLoopbackBEndpointIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::DiagnosticsLoopbackBEndpointId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void EndpointInterfaceClassGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiEndpointDeviceInformation::EndpointInterfaceClass; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ UnwrapMidiEndpointDeviceInformation(Local value); + }; + + Persistent MidiEndpointDeviceInformation::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformation(::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformation::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ UnwrapMidiEndpointDeviceInformation(Local value) { + return MidiEndpointDeviceInformation::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformation(Local exports) { + MidiEndpointDeviceInformation::Init(exports); + } + + class MidiEndpointDeviceInformationAddedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformationAddedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("addedDevice").ToLocalChecked(), AddedDeviceGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationAddedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformationAddedEventArgs *wrapperInstance = new MidiEndpointDeviceInformationAddedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformationAddedEventArgs(winRtInstance)); + } + + + + + + static void AddedDeviceGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationAddedEventArgs *wrapper = MidiEndpointDeviceInformationAddedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ result = wrapper->_instance->AddedDevice; + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformation(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ UnwrapMidiEndpointDeviceInformationAddedEventArgs(Local value); + }; + + Persistent MidiEndpointDeviceInformationAddedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformationAddedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformationAddedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ UnwrapMidiEndpointDeviceInformationAddedEventArgs(Local value) { + return MidiEndpointDeviceInformationAddedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformationAddedEventArgs(Local exports) { + MidiEndpointDeviceInformationAddedEventArgs::Init(exports); + } + + class MidiEndpointDeviceInformationRemovedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformationRemovedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceInformationUpdate").ToLocalChecked(), DeviceInformationUpdateGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationRemovedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformationRemovedEventArgs *wrapperInstance = new MidiEndpointDeviceInformationRemovedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformationRemovedEventArgs(winRtInstance)); + } + + + + + + static void DeviceInformationUpdateGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationRemovedEventArgs *wrapper = MidiEndpointDeviceInformationRemovedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Enumeration::DeviceInformationUpdate^ result = wrapper->_instance->DeviceInformationUpdate; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformationUpdate", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationRemovedEventArgs *wrapper = MidiEndpointDeviceInformationRemovedEventArgs::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ UnwrapMidiEndpointDeviceInformationRemovedEventArgs(Local value); + }; + + Persistent MidiEndpointDeviceInformationRemovedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformationRemovedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformationRemovedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ UnwrapMidiEndpointDeviceInformationRemovedEventArgs(Local value) { + return MidiEndpointDeviceInformationRemovedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformationRemovedEventArgs(Local exports) { + MidiEndpointDeviceInformationRemovedEventArgs::Init(exports); + } + + class MidiEndpointDeviceInformationUpdatedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceInformationUpdatedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceInformationUpdate").ToLocalChecked(), DeviceInformationUpdateGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedAdditionalCapabilities").ToLocalChecked(), UpdatedAdditionalCapabilitiesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedDeviceIdentity").ToLocalChecked(), UpdatedDeviceIdentityGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedEndpointInformation").ToLocalChecked(), UpdatedEndpointInformationGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedFunctionBlocks").ToLocalChecked(), UpdatedFunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedName").ToLocalChecked(), UpdatedNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedStreamConfiguration").ToLocalChecked(), UpdatedStreamConfigurationGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("updatedUserMetadata").ToLocalChecked(), UpdatedUserMetadataGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceInformationUpdatedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapperInstance = new MidiEndpointDeviceInformationUpdatedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceInformationUpdatedEventArgs(winRtInstance)); + } + + + + + + static void DeviceInformationUpdateGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Enumeration::DeviceInformationUpdate^ result = wrapper->_instance->DeviceInformationUpdate; + info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Devices.Enumeration", "DeviceInformationUpdate", result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedAdditionalCapabilitiesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedAdditionalCapabilities; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedDeviceIdentityGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedDeviceIdentity; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedEndpointInformationGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedEndpointInformation; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedFunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedFunctionBlocks; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedName; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedStreamConfigurationGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedStreamConfiguration; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UpdatedUserMetadataGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>(info.This())) { + return; + } + + MidiEndpointDeviceInformationUpdatedEventArgs *wrapper = MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UpdatedUserMetadata; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ UnwrapMidiEndpointDeviceInformationUpdatedEventArgs(Local value); + }; + + Persistent MidiEndpointDeviceInformationUpdatedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceInformationUpdatedEventArgs(::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceInformationUpdatedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ UnwrapMidiEndpointDeviceInformationUpdatedEventArgs(Local value) { + return MidiEndpointDeviceInformationUpdatedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceInformationUpdatedEventArgs(Local exports) { + MidiEndpointDeviceInformationUpdatedEventArgs::Init(exports); + } + + class MidiEndpointDeviceWatcher : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiEndpointDeviceWatcher").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "start", Start); + Nan::SetPrototypeMethod(localRef, "stop", Stop); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("enumeratedEndpointDevices").ToLocalChecked(), EnumeratedEndpointDevicesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("status").ToLocalChecked(), StatusGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createWatcher", CreateWatcher); + + + Nan::Set(exports, Nan::New("MidiEndpointDeviceWatcher").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiEndpointDeviceWatcher *wrapperInstance = new MidiEndpointDeviceWatcher(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiEndpointDeviceWatcher(winRtInstance)); + } + + + static void Start(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Start(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Stop(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Stop(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CreateWatcher(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters arg0 = static_cast<::Windows::Devices::Midi2::MidiEndpointDeviceInformationFilters>(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ result; + result = ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher::CreateWatcher(arg0); + info.GetReturnValue().Set(WrapMidiEndpointDeviceWatcher(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void EnumeratedEndpointDevicesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView<::Platform::String^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>^ result = wrapper->_instance->EnumeratedEndpointDevices; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper<::Platform::String^,::Windows::Devices::Midi2::MidiEndpointDeviceInformation^>::CreateMapViewWrapper(result, + [](::Platform::String^ val) -> Local { + return NodeRT::Utils::NewString(val->Data()); + }, + [](Local value) -> bool { + return value->IsString(); + }, + [](Local value) -> ::Platform::String^ { + return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + }, + [](::Windows::Devices::Midi2::MidiEndpointDeviceInformation^ val) -> Local { + return WrapMidiEndpointDeviceInformation(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void StatusGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) { + return; + } + + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + ::Windows::Devices::Enumeration::DeviceWatcherStatus result = wrapper->_instance->Status; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"added", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Added::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationAddedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = WrapMidiEndpointDeviceInformationAddedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"enumerationCompleted", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->EnumerationCompleted::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Platform::Object^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Platform::Object^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = CreateOpaqueWrapper(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"removed", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Removed::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationRemovedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = WrapMidiEndpointDeviceInformationRemovedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"stopped", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Stopped::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Platform::Object^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Platform::Object^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = CreateOpaqueWrapper(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"updated", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->Updated::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ arg0, ::Windows::Devices::Midi2::MidiEndpointDeviceInformationUpdatedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiEndpointDeviceWatcher(arg0); + wrappedArg1 = WrapMidiEndpointDeviceInformationUpdatedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"added", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"enumerationCompleted", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"removed", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"stopped", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"updated", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"added", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Added::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"enumerationCompleted", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->EnumerationCompleted::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"removed", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Removed::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"stopped", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Stopped::remove(registrationToken); + } + else if (NodeRT::Utils::CaseInsenstiveEquals(L"updated", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiEndpointDeviceWatcher *wrapper = MidiEndpointDeviceWatcher::Unwrap(info.This()); + wrapper->_instance->Updated::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ UnwrapMidiEndpointDeviceWatcher(Local value); + }; + + Persistent MidiEndpointDeviceWatcher::s_constructorTemplate; + + v8::Local WrapMidiEndpointDeviceWatcher(::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiEndpointDeviceWatcher::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiEndpointDeviceWatcher^ UnwrapMidiEndpointDeviceWatcher(Local value) { + return MidiEndpointDeviceWatcher::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiEndpointDeviceWatcher(Local exports) { + MidiEndpointDeviceWatcher::Init(exports); + } + + class MidiFunctionBlock : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiFunctionBlock").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "includesGroup", IncludesGroup); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("uIHint").ToLocalChecked(), UIHintGetter, UIHintSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("number").ToLocalChecked(), NumberGetter, NumberSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("midiCIMessageVersionFormat").ToLocalChecked(), MidiCIMessageVersionFormatGetter, MidiCIMessageVersionFormatSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("midi10Connection").ToLocalChecked(), Midi10ConnectionGetter, Midi10ConnectionSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("maxSystemExclusive8Streams").ToLocalChecked(), MaxSystemExclusive8StreamsGetter, MaxSystemExclusive8StreamsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isActive").ToLocalChecked(), IsActiveGetter, IsActiveSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("groupCount").ToLocalChecked(), GroupCountGetter, GroupCountSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("firstGroupIndex").ToLocalChecked(), FirstGroupIndexGetter, FirstGroupIndexSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("direction").ToLocalChecked(), DirectionGetter, DirectionSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isReadOnly").ToLocalChecked(), IsReadOnlyGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiFunctionBlock").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiFunctionBlock^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiFunctionBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiFunctionBlock(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiFunctionBlock *wrapperInstance = new MidiFunctionBlock(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiFunctionBlock^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiFunctionBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiFunctionBlock(winRtInstance)); + } + + + static void IncludesGroup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiGroup^ arg0 = UnwrapMidiGroup(info[0]); + + bool result; + result = wrapper->_instance->IncludesGroup(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void UIHintGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiFunctionBlockUIHint result = wrapper->_instance->UIHint; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UIHintSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiFunctionBlockUIHint winRtValue = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockUIHint>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->UIHint = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NumberGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Number; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NumberSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Number = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MidiCIMessageVersionFormatGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->MidiCIMessageVersionFormat; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MidiCIMessageVersionFormatSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MidiCIMessageVersionFormat = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Midi10ConnectionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiFunctionBlockMidi10 result = wrapper->_instance->Midi10Connection; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Midi10ConnectionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiFunctionBlockMidi10 winRtValue = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockMidi10>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Midi10Connection = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MaxSystemExclusive8StreamsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->MaxSystemExclusive8Streams; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MaxSystemExclusive8StreamsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MaxSystemExclusive8Streams = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsActiveGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsActive; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsActiveSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsActive = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void GroupCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->GroupCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void GroupCountSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->GroupCount = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void FirstGroupIndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->FirstGroupIndex; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FirstGroupIndexSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->FirstGroupIndex = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DirectionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiFunctionBlockDirection result = wrapper->_instance->Direction; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DirectionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiFunctionBlockDirection winRtValue = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockDirection>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Direction = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsReadOnlyGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info.This())) { + return; + } + + MidiFunctionBlock *wrapper = MidiFunctionBlock::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsReadOnly; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiFunctionBlock^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiFunctionBlock^ UnwrapMidiFunctionBlock(Local value); + }; + + Persistent MidiFunctionBlock::s_constructorTemplate; + + v8::Local WrapMidiFunctionBlock(::Windows::Devices::Midi2::MidiFunctionBlock^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiFunctionBlock::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiFunctionBlock^ UnwrapMidiFunctionBlock(Local value) { + return MidiFunctionBlock::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiFunctionBlock(Local exports) { + MidiFunctionBlock::Init(exports); + } + + class MidiGroup : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiGroup").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("index").ToLocalChecked(), IndexGetter, IndexSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("numberForDisplay").ToLocalChecked(), NumberForDisplayGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "isValidGroupIndex", IsValidGroupIndex); + Nan::SetAccessor(constructor, Nan::New("labelFull").ToLocalChecked(), LabelFullGetter); + Nan::SetAccessor(constructor, Nan::New("labelShort").ToLocalChecked(), LabelShortGetter); + + + Nan::Set(exports, Nan::New("MidiGroup").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiGroup(::Windows::Devices::Midi2::MidiGroup^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiGroup^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroup^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsInt32()) + { + try { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiGroup(arg0); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiGroup(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiGroup *wrapperInstance = new MidiGroup(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiGroup^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroup^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiGroup(winRtInstance)); + } + + + + + + static void IsValidGroupIndex(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiGroup::IsValidGroupIndex(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void IndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info.This())) { + return; + } + + MidiGroup *wrapper = MidiGroup::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Index; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IndexSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info.This())) { + return; + } + + MidiGroup *wrapper = MidiGroup::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Index = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NumberForDisplayGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info.This())) { + return; + } + + MidiGroup *wrapper = MidiGroup::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->NumberForDisplay; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void LabelFullGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiGroup::LabelFull; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void LabelShortGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiGroup::LabelShort; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiGroup^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiGroup(::Windows::Devices::Midi2::MidiGroup^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiGroup^ UnwrapMidiGroup(Local value); + }; + + Persistent MidiGroup::s_constructorTemplate; + + v8::Local WrapMidiGroup(::Windows::Devices::Midi2::MidiGroup^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiGroup::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiGroup^ UnwrapMidiGroup(Local value) { + return MidiGroup::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiGroup(Local exports) { + MidiGroup::Init(exports); + } + + class MidiGroupEndpointListener : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiGroupEndpointListener").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventFiringMainMessageReceivedEvent").ToLocalChecked(), PreventFiringMainMessageReceivedEventGetter, PreventFiringMainMessageReceivedEventSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventCallingFurtherListeners").ToLocalChecked(), PreventCallingFurtherListenersGetter, PreventCallingFurtherListenersSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeGroups").ToLocalChecked(), IncludeGroupsGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiGroupEndpointListener").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiGroupEndpointListener(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiGroupEndpointListener *wrapperInstance = new MidiGroupEndpointListener(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiGroupEndpointListener(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventFiringMainMessageReceivedEvent; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventFiringMainMessageReceivedEvent = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreventCallingFurtherListenersGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventCallingFurtherListeners; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventCallingFurtherListenersSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventCallingFurtherListeners = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeGroupsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) { + return; + } + + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiGroup^>^ result = wrapper->_instance->IncludeGroups; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiGroup^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiGroup^ val) -> Local { + return WrapMidiGroup(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiGroup^ { + return UnwrapMidiGroup(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiGroupEndpointListener *wrapper = MidiGroupEndpointListener::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiGroupEndpointListener^ UnwrapMidiGroupEndpointListener(Local value); + }; + + Persistent MidiGroupEndpointListener::s_constructorTemplate; + + v8::Local WrapMidiGroupEndpointListener(::Windows::Devices::Midi2::MidiGroupEndpointListener^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiGroupEndpointListener::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiGroupEndpointListener^ UnwrapMidiGroupEndpointListener(Local value) { + return MidiGroupEndpointListener::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiGroupEndpointListener(Local exports) { + MidiGroupEndpointListener::Init(exports); + } + + class MidiGroupTerminalBlock : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiGroupTerminalBlock").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "includesGroup", IncludesGroup); + Nan::SetPrototypeMethod(localRef, "asEquivalentFunctionBlock", AsEquivalentFunctionBlock); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("calculatedMaxDeviceInputBandwidthBitsPerSecond").ToLocalChecked(), CalculatedMaxDeviceInputBandwidthBitsPerSecondGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("calculatedMaxDeviceOutputBandwidthBitsPerSecond").ToLocalChecked(), CalculatedMaxDeviceOutputBandwidthBitsPerSecondGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("direction").ToLocalChecked(), DirectionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("firstGroupIndex").ToLocalChecked(), FirstGroupIndexGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("groupCount").ToLocalChecked(), GroupCountGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("maxDeviceInputBandwidthIn4KBitsPerSecondUnits").ToLocalChecked(), MaxDeviceInputBandwidthIn4KBitsPerSecondUnitsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("maxDeviceOutputBandwidthIn4KBitsPerSecondUnits").ToLocalChecked(), MaxDeviceOutputBandwidthIn4KBitsPerSecondUnitsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("number").ToLocalChecked(), NumberGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("protocol").ToLocalChecked(), ProtocolGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiGroupTerminalBlock").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupTerminalBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiGroupTerminalBlock *wrapperInstance = new MidiGroupTerminalBlock(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiGroupTerminalBlock^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiGroupTerminalBlock(winRtInstance)); + } + + + static void IncludesGroup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiGroup^ arg0 = UnwrapMidiGroup(info[0]); + + bool result; + result = wrapper->_instance->IncludesGroup(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AsEquivalentFunctionBlock(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiFunctionBlock^ result; + result = wrapper->_instance->AsEquivalentFunctionBlock(); + info.GetReturnValue().Set(WrapMidiFunctionBlock(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CalculatedMaxDeviceInputBandwidthBitsPerSecondGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->CalculatedMaxDeviceInputBandwidthBitsPerSecond; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void CalculatedMaxDeviceOutputBandwidthBitsPerSecondGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->CalculatedMaxDeviceOutputBandwidthBitsPerSecond; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DirectionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiGroupTerminalBlockDirection result = wrapper->_instance->Direction; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FirstGroupIndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->FirstGroupIndex; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void GroupCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->GroupCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MaxDeviceInputBandwidthIn4KBitsPerSecondUnitsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->MaxDeviceInputBandwidthIn4KBitsPerSecondUnits; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MaxDeviceOutputBandwidthIn4KBitsPerSecondUnitsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->MaxDeviceOutputBandwidthIn4KBitsPerSecondUnits; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NumberGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Number; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroupTerminalBlock^>(info.This())) { + return; + } + + MidiGroupTerminalBlock *wrapper = MidiGroupTerminalBlock::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiGroupTerminalBlockProtocol result = wrapper->_instance->Protocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ UnwrapMidiGroupTerminalBlock(Local value); + }; + + Persistent MidiGroupTerminalBlock::s_constructorTemplate; + + v8::Local WrapMidiGroupTerminalBlock(::Windows::Devices::Midi2::MidiGroupTerminalBlock^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiGroupTerminalBlock::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiGroupTerminalBlock^ UnwrapMidiGroupTerminalBlock(Local value) { + return MidiGroupTerminalBlock::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiGroupTerminalBlock(Local exports) { + MidiGroupTerminalBlock::Init(exports); + } + + class MidiMessage128 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage128").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word3").ToLocalChecked(), Word3Getter, Word3Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word2").ToLocalChecked(), Word2Getter, Word2Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word1").ToLocalChecked(), Word1Getter, Word1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage128").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage128^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage128^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage128(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 5 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32() + && info[4]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned int arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage128(arg0,arg1,arg2,arg3,arg4); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[1]) || info[1]->IsArray())) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Platform::Array^ arg1 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage128(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage128 *wrapperInstance = new MidiMessage128(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage128^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage128^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage128(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word3Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word3; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word3Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word3 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word2Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word2; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word2Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word2 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info.This())) { + return; + } + + MidiMessage128 *wrapper = MidiMessage128::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage128^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage128^ UnwrapMidiMessage128(Local value); + }; + + Persistent MidiMessage128::s_constructorTemplate; + + v8::Local WrapMidiMessage128(::Windows::Devices::Midi2::MidiMessage128^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage128::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage128^ UnwrapMidiMessage128(Local value) { + return MidiMessage128::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage128(Local exports) { + MidiMessage128::Init(exports); + } + + class MidiMessage32 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage32").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage32").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage32^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage32^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage32(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage32(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage32 *wrapperInstance = new MidiMessage32(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage32^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage32^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage32(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info.This())) { + return; + } + + MidiMessage32 *wrapper = MidiMessage32::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage32^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage32^ UnwrapMidiMessage32(Local value); + }; + + Persistent MidiMessage32::s_constructorTemplate; + + v8::Local WrapMidiMessage32(::Windows::Devices::Midi2::MidiMessage32^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage32::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage32^ UnwrapMidiMessage32(Local value) { + return MidiMessage32::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage32(Local exports) { + MidiMessage32::Init(exports); + } + + class MidiMessage64 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage64").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word1").ToLocalChecked(), Word1Getter, Word1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage64").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage64^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage64^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage64(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage64(arg0,arg1,arg2); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[1]) || info[1]->IsArray())) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Platform::Array^ arg1 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage64(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage64 *wrapperInstance = new MidiMessage64(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage64^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage64^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage64(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info.This())) { + return; + } + + MidiMessage64 *wrapper = MidiMessage64::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage64^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage64^ UnwrapMidiMessage64(Local value); + }; + + Persistent MidiMessage64::s_constructorTemplate; + + v8::Local WrapMidiMessage64(::Windows::Devices::Midi2::MidiMessage64^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage64::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage64^ UnwrapMidiMessage64(Local value) { + return MidiMessage64::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage64(Local exports) { + MidiMessage64::Init(exports); + } + + class MidiMessage96 : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessage96").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getAllWords", GetAllWords); + Nan::SetPrototypeMethod(localRef, "appendAllMessageWordsToList", AppendAllMessageWordsToList); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "toString", ToString); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word2").ToLocalChecked(), Word2Getter, Word2Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word1").ToLocalChecked(), Word1Getter, Word1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("word0").ToLocalChecked(), Word0Getter, Word0Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter, MessageTypeSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessage96").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessage96^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage96^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage96(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsUint32() + && info[2]->IsUint32() + && info[3]->IsUint32()) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned int arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage96(arg0,arg1,arg2,arg3); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array^>(info[1]) || info[1]->IsArray())) + { + try { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Platform::Array^ arg1 = + [] (v8::Local value) -> ::Platform::Array^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtArray(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Platform::Array^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessage96(arg0,arg1); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessage96 *wrapperInstance = new MidiMessage96(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessage96^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessage96^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessage96(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetAllWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector^ result; + result = wrapper->_instance->GetAllWords(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendAllMessageWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendAllMessageWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ToString(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + Platform::String^ result; + result = wrapper->_instance->ToString(); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void Word2Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word2; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word2Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word2 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Word0Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Word0; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Word0Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsUint32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned int winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Word0 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsNumber()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + unsigned __int64 winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Timestamp = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MessageTypeSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiMessageType winRtValue = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->MessageType = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info.This())) { + return; + } + + MidiMessage96 *wrapper = MidiMessage96::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessage96^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessage96^ UnwrapMidiMessage96(Local value); + }; + + Persistent MidiMessage96::s_constructorTemplate; + + v8::Local WrapMidiMessage96(::Windows::Devices::Midi2::MidiMessage96^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessage96::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessage96^ UnwrapMidiMessage96(Local value) { + return MidiMessage96::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessage96(Local exports) { + MidiMessage96::Init(exports); + } + + class MidiMessageBuilder : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageBuilder").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "buildUtilityMessage", BuildUtilityMessage); + Nan::SetMethod(constructor, "buildSystemMessage", BuildSystemMessage); + Nan::SetMethod(constructor, "buildMidi1ChannelVoiceMessage", BuildMidi1ChannelVoiceMessage); + Nan::SetMethod(constructor, "buildSystemExclusive7Message", BuildSystemExclusive7Message); + Nan::SetMethod(constructor, "buildMidi2ChannelVoiceMessage", BuildMidi2ChannelVoiceMessage); + Nan::SetMethod(constructor, "buildSystemExclusive8Message", BuildSystemExclusive8Message); + Nan::SetMethod(constructor, "buildMixedDataSetChunkHeaderMessage", BuildMixedDataSetChunkHeaderMessage); + Nan::SetMethod(constructor, "buildMixedDataSetChunkDataMessage", BuildMixedDataSetChunkDataMessage); + Nan::SetMethod(constructor, "buildFlexDataMessage", BuildFlexDataMessage); + Nan::SetMethod(constructor, "buildStreamMessage", BuildStreamMessage); + + + Nan::Set(exports, Nan::New("MidiMessageBuilder").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageBuilder^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageBuilder^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageBuilder *wrapperInstance = new MidiMessageBuilder(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageBuilder^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageBuilder^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageBuilder(winRtInstance)); + } + + + + + + static void BuildUtilityMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned int arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildUtilityMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildSystemMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 5 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildSystemMessage(arg0, arg1, arg2, arg3, arg4); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMidi1ChannelVoiceMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 6 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[3]) + && info[4]->IsInt32() + && info[5]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus arg2 = static_cast<::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus>(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg3 = UnwrapMidiChannel(info[3]); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMidi1ChannelVoiceMessage(arg0, arg1, arg2, arg3, arg4, arg5); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildSystemExclusive7Message(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage64^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildSystemExclusive7Message(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapMidiMessage64(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMidi2ChannelVoiceMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 6 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[3]) + && info[4]->IsInt32() + && info[5]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus arg2 = static_cast<::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus>(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg3 = UnwrapMidiChannel(info[3]); + unsigned short arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned int arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage64^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMidi2ChannelVoiceMessage(arg0, arg1, arg2, arg3, arg4, arg5); + info.GetReturnValue().Set(WrapMidiMessage64(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildSystemExclusive8Message(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 18 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32() + && info[10]->IsInt32() + && info[11]->IsInt32() + && info[12]->IsInt32() + && info[13]->IsInt32() + && info[14]->IsInt32() + && info[15]->IsInt32() + && info[16]->IsInt32() + && info[17]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi2::MidiSystemExclusive8Status arg2 = static_cast<::Windows::Devices::Midi2::MidiSystemExclusive8Status>(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + unsigned char arg10 = static_cast(Nan::To(info[10]).FromMaybe(0)); + unsigned char arg11 = static_cast(Nan::To(info[11]).FromMaybe(0)); + unsigned char arg12 = static_cast(Nan::To(info[12]).FromMaybe(0)); + unsigned char arg13 = static_cast(Nan::To(info[13]).FromMaybe(0)); + unsigned char arg14 = static_cast(Nan::To(info[14]).FromMaybe(0)); + unsigned char arg15 = static_cast(Nan::To(info[15]).FromMaybe(0)); + unsigned char arg16 = static_cast(Nan::To(info[16]).FromMaybe(0)); + unsigned char arg17 = static_cast(Nan::To(info[17]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildSystemExclusive8Message(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMixedDataSetChunkHeaderMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned short arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned short arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned short arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned short arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned short arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned short arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned short arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMixedDataSetChunkHeaderMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildMixedDataSetChunkDataMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 17 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32() + && info[10]->IsInt32() + && info[11]->IsInt32() + && info[12]->IsInt32() + && info[13]->IsInt32() + && info[14]->IsInt32() + && info[15]->IsInt32() + && info[16]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + unsigned char arg10 = static_cast(Nan::To(info[10]).FromMaybe(0)); + unsigned char arg11 = static_cast(Nan::To(info[11]).FromMaybe(0)); + unsigned char arg12 = static_cast(Nan::To(info[12]).FromMaybe(0)); + unsigned char arg13 = static_cast(Nan::To(info[13]).FromMaybe(0)); + unsigned char arg14 = static_cast(Nan::To(info[14]).FromMaybe(0)); + unsigned char arg15 = static_cast(Nan::To(info[15]).FromMaybe(0)); + unsigned char arg16 = static_cast(Nan::To(info[16]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildMixedDataSetChunkDataMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFlexDataMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[4]) + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsUint32() + && info[8]->IsUint32() + && info[9]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg4 = UnwrapMidiChannel(info[4]); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned int arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned int arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned int arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildFlexDataMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildStreamMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 7 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsUint32() + && info[5]->IsUint32() + && info[6]->IsUint32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned short arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned short arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned int arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned int arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned int arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage128^ result; + result = ::Windows::Devices::Midi2::MidiMessageBuilder::BuildStreamMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + info.GetReturnValue().Set(WrapMidiMessage128(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageBuilder^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageBuilder^ UnwrapMidiMessageBuilder(Local value); + }; + + Persistent MidiMessageBuilder::s_constructorTemplate; + + v8::Local WrapMidiMessageBuilder(::Windows::Devices::Midi2::MidiMessageBuilder^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageBuilder::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageBuilder^ UnwrapMidiMessageBuilder(Local value) { + return MidiMessageBuilder::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageBuilder(Local exports) { + MidiMessageBuilder::Init(exports); + } + + class MidiMessageConverter : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageConverter").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "convertMidi1Message", ConvertMidi1Message); + Nan::SetMethod(constructor, "convertMidi1ChannelPressureMessage", ConvertMidi1ChannelPressureMessage); + Nan::SetMethod(constructor, "convertMidi1NoteOffMessage", ConvertMidi1NoteOffMessage); + Nan::SetMethod(constructor, "convertMidi1NoteOnMessage", ConvertMidi1NoteOnMessage); + Nan::SetMethod(constructor, "convertMidi1PitchBendChangeMessage", ConvertMidi1PitchBendChangeMessage); + Nan::SetMethod(constructor, "convertMidi1PolyphonicKeyPressureMessage", ConvertMidi1PolyphonicKeyPressureMessage); + Nan::SetMethod(constructor, "convertMidi1ProgramChangeMessage", ConvertMidi1ProgramChangeMessage); + Nan::SetMethod(constructor, "convertMidi1TimeCodeMessage", ConvertMidi1TimeCodeMessage); + Nan::SetMethod(constructor, "convertMidi1SongPositionPointerMessage", ConvertMidi1SongPositionPointerMessage); + Nan::SetMethod(constructor, "convertMidi1SongSelectMessage", ConvertMidi1SongSelectMessage); + Nan::SetMethod(constructor, "convertMidi1TuneRequestMessage", ConvertMidi1TuneRequestMessage); + Nan::SetMethod(constructor, "convertMidi1TimingClockMessage", ConvertMidi1TimingClockMessage); + Nan::SetMethod(constructor, "convertMidi1StartMessage", ConvertMidi1StartMessage); + Nan::SetMethod(constructor, "convertMidi1ContinueMessage", ConvertMidi1ContinueMessage); + Nan::SetMethod(constructor, "convertMidi1StopMessage", ConvertMidi1StopMessage); + Nan::SetMethod(constructor, "convertMidi1ActiveSensingMessage", ConvertMidi1ActiveSensingMessage); + Nan::SetMethod(constructor, "convertMidi1SystemResetMessage", ConvertMidi1SystemResetMessage); + + + Nan::Set(exports, Nan::New("MidiMessageConverter").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageConverter^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageConverter^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageConverter^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageConverter *wrapperInstance = new MidiMessageConverter(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageConverter^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageConverter^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageConverter^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageConverter(winRtInstance)); + } + + + + + + static void ConvertMidi1Message(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1Message(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1Message(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 5 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1Message(arg0, arg1, arg2, arg3, arg4); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ChannelPressureMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiChannelPressureMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiChannelPressureMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiChannelPressureMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ChannelPressureMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1NoteOffMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiNoteOffMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiNoteOffMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiNoteOffMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1NoteOffMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1NoteOnMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiNoteOnMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiNoteOnMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiNoteOnMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1NoteOnMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1PitchBendChangeMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiPitchBendChangeMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiPitchBendChangeMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiPitchBendChangeMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1PitchBendChangeMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1PolyphonicKeyPressureMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiPolyphonicKeyPressureMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiPolyphonicKeyPressureMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiPolyphonicKeyPressureMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1PolyphonicKeyPressureMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ProgramChangeMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiProgramChangeMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiProgramChangeMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiProgramChangeMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ProgramChangeMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1TimeCodeMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiTimeCodeMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiTimeCodeMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiTimeCodeMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1TimeCodeMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1SongPositionPointerMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiSongPositionPointerMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiSongPositionPointerMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiSongPositionPointerMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1SongPositionPointerMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1SongSelectMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiSongSelectMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiSongSelectMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiSongSelectMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1SongSelectMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1TuneRequestMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiTuneRequestMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiTuneRequestMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiTuneRequestMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1TuneRequestMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1TimingClockMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiTimingClockMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiTimingClockMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiTimingClockMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1TimingClockMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1StartMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiStartMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiStartMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiStartMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1StartMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ContinueMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiContinueMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiContinueMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiContinueMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ContinueMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1StopMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiStopMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiStopMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiStopMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1StopMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1ActiveSensingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiActiveSensingMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiActiveSensingMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiActiveSensingMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1ActiveSensingMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConvertMidi1SystemResetMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi::MidiSystemResetMessage^>(info[2])) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + ::Windows::Devices::Midi::MidiSystemResetMessage^ arg2 = dynamic_cast<::Windows::Devices::Midi::MidiSystemResetMessage^>(NodeRT::Utils::GetObjectInstance(info[2])); + + ::Windows::Devices::Midi2::MidiMessage32^ result; + result = ::Windows::Devices::Midi2::MidiMessageConverter::ConvertMidi1SystemResetMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiMessage32(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageConverter^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageConverter^ UnwrapMidiMessageConverter(Local value); + }; + + Persistent MidiMessageConverter::s_constructorTemplate; + + v8::Local WrapMidiMessageConverter(::Windows::Devices::Midi2::MidiMessageConverter^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageConverter::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageConverter^ UnwrapMidiMessageConverter(Local value) { + return MidiMessageConverter::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageConverter(Local exports) { + MidiMessageConverter::Init(exports); + } + + class MidiMessageReceivedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageReceivedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "peekFirstWord", PeekFirstWord); + Nan::SetPrototypeMethod(localRef, "getMessagePacket", GetMessagePacket); + Nan::SetPrototypeMethod(localRef, "fillWords", FillWords); + Nan::SetPrototypeMethod(localRef, "fillMessageStruct", FillMessageStruct); + Nan::SetPrototypeMethod(localRef, "fillMessage32", FillMessage32); + Nan::SetPrototypeMethod(localRef, "fillMessage64", FillMessage64); + Nan::SetPrototypeMethod(localRef, "fillMessage96", FillMessage96); + Nan::SetPrototypeMethod(localRef, "fillMessage128", FillMessage128); + Nan::SetPrototypeMethod(localRef, "fillWordArray", FillWordArray); + Nan::SetPrototypeMethod(localRef, "fillByteArray", FillByteArray); + Nan::SetPrototypeMethod(localRef, "fillBuffer", FillBuffer); + Nan::SetPrototypeMethod(localRef, "appendWordsToList", AppendWordsToList); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("messageType").ToLocalChecked(), MessageTypeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("packetType").ToLocalChecked(), PacketTypeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessageReceivedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageReceivedEventArgs *wrapperInstance = new MidiMessageReceivedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageReceivedEventArgs(winRtInstance)); + } + + + static void PeekFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int result; + result = wrapper->_instance->PeekFirstWord(); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void GetMessagePacket(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = wrapper->_instance->GetMessagePacket(); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillWords(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + unsigned int arg0; + unsigned int arg1; + unsigned int arg2; + unsigned int arg3; + + unsigned char result; + result = wrapper->_instance->FillWords(&arg0, &arg1, &arg2, &arg3); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("number").ToLocalChecked(), Nan::New(result)); + Nan::Set(resObj, Nan::New("word0").ToLocalChecked(), Nan::New(arg0)); + Nan::Set(resObj, Nan::New("word1").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("word2").ToLocalChecked(), Nan::New(arg2)); + Nan::Set(resObj, Nan::New("word3").ToLocalChecked(), Nan::New(arg3)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessageStruct(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiMessageStruct arg0; + + unsigned char result; + result = wrapper->_instance->FillMessageStruct(&arg0); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("number").ToLocalChecked(), Nan::New(result)); + Nan::Set(resObj, Nan::New("message").ToLocalChecked(), MidiMessageStructToJsObject(arg0)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage32(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage32^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage32^ arg0 = UnwrapMidiMessage32(info[0]); + + bool result; + result = wrapper->_instance->FillMessage32(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage64(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage64^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage64^ arg0 = UnwrapMidiMessage64(info[0]); + + bool result; + result = wrapper->_instance->FillMessage64(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage96(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage96^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage96^ arg0 = UnwrapMidiMessage96(info[0]); + + bool result; + result = wrapper->_instance->FillMessage96(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillMessage128(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessage128^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessage128^ arg0 = UnwrapMidiMessage128(info[0]); + + bool result; + result = wrapper->_instance->FillMessage128(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void FillWordArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + } + static void FillByteArray(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); + } + static void FillBuffer(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::IMemoryBuffer^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::IMemoryBuffer^ arg1 = dynamic_cast<::Windows::Foundation::IMemoryBuffer^>(NodeRT::Utils::GetObjectInstance(info[1])); + + unsigned char result; + result = wrapper->_instance->FillBuffer(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void AppendWordsToList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IVector^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IVector^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IVector^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IVector^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + unsigned char result; + result = wrapper->_instance->AppendWordsToList(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void MessageTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiMessageType result = wrapper->_instance->MessageType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PacketTypeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiPacketType result = wrapper->_instance->PacketType; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info.This())) { + return; + } + + MidiMessageReceivedEventArgs *wrapper = MidiMessageReceivedEventArgs::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ UnwrapMidiMessageReceivedEventArgs(Local value); + }; + + Persistent MidiMessageReceivedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiMessageReceivedEventArgs(::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageReceivedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ UnwrapMidiMessageReceivedEventArgs(Local value) { + return MidiMessageReceivedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageReceivedEventArgs(Local exports) { + MidiMessageReceivedEventArgs::Init(exports); + } + + class MidiMessageTypeEndpointListener : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageTypeEndpointListener").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventFiringMainMessageReceivedEvent").ToLocalChecked(), PreventFiringMainMessageReceivedEventGetter, PreventFiringMainMessageReceivedEventSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preventCallingFurtherListeners").ToLocalChecked(), PreventCallingFurtherListenersGetter, PreventCallingFurtherListenersSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("includeMessageTypes").ToLocalChecked(), IncludeMessageTypesGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiMessageTypeEndpointListener").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageTypeEndpointListener *wrapperInstance = new MidiMessageTypeEndpointListener(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageTypeEndpointListener(winRtInstance)); + } + + + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventFiringMainMessageReceivedEvent; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventFiringMainMessageReceivedEventSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventFiringMainMessageReceivedEvent = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreventCallingFurtherListenersGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->PreventCallingFurtherListeners; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreventCallingFurtherListenersSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->PreventCallingFurtherListeners = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IncludeMessageTypesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) { + return; + } + + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiMessageType>^ result = wrapper->_instance->IncludeMessageTypes; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiMessageType>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiMessageType val) -> Local { + return Nan::New(static_cast(val)); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiMessageType { + return static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->MessageReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::IMidiMessageReceivedEventSource^ arg0, ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapIMidiMessageReceivedEventSource(arg0); + wrappedArg1 = WrapMidiMessageReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"messageReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiMessageTypeEndpointListener *wrapper = MidiMessageTypeEndpointListener::Unwrap(info.This()); + wrapper->_instance->MessageReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ UnwrapMidiMessageTypeEndpointListener(Local value); + }; + + Persistent MidiMessageTypeEndpointListener::s_constructorTemplate; + + v8::Local WrapMidiMessageTypeEndpointListener(::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageTypeEndpointListener::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageTypeEndpointListener^ UnwrapMidiMessageTypeEndpointListener(Local value) { + return MidiMessageTypeEndpointListener::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageTypeEndpointListener(Local exports) { + MidiMessageTypeEndpointListener::Init(exports); + } + + class MidiMessageUtility : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiMessageUtility").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "validateMessage32MessageType", ValidateMessage32MessageType); + Nan::SetMethod(constructor, "validateMessage64MessageType", ValidateMessage64MessageType); + Nan::SetMethod(constructor, "validateMessage96MessageType", ValidateMessage96MessageType); + Nan::SetMethod(constructor, "validateMessage128MessageType", ValidateMessage128MessageType); + Nan::SetMethod(constructor, "getMessageTypeFromMessageFirstWord", GetMessageTypeFromMessageFirstWord); + Nan::SetMethod(constructor, "getPacketTypeFromMessageFirstWord", GetPacketTypeFromMessageFirstWord); + Nan::SetMethod(constructor, "messageTypeHasGroupField", MessageTypeHasGroupField); + Nan::SetMethod(constructor, "replaceGroupInMessageFirstWord", ReplaceGroupInMessageFirstWord); + Nan::SetMethod(constructor, "getGroupFromMessageFirstWord", GetGroupFromMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromUtilityMessage", GetStatusFromUtilityMessage); + Nan::SetMethod(constructor, "getStatusFromMidi1ChannelVoiceMessage", GetStatusFromMidi1ChannelVoiceMessage); + Nan::SetMethod(constructor, "getStatusFromMidi2ChannelVoiceMessageFirstWord", GetStatusFromMidi2ChannelVoiceMessageFirstWord); + Nan::SetMethod(constructor, "getStatusBankFromFlexDataMessageFirstWord", GetStatusBankFromFlexDataMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromFlexDataMessageFirstWord", GetStatusFromFlexDataMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromSystemCommonMessage", GetStatusFromSystemCommonMessage); + Nan::SetMethod(constructor, "getStatusFromDataMessage64FirstWord", GetStatusFromDataMessage64FirstWord); + Nan::SetMethod(constructor, "getNumberOfBytesFromDataMessage64FirstWord", GetNumberOfBytesFromDataMessage64FirstWord); + Nan::SetMethod(constructor, "getStatusFromDataMessage128FirstWord", GetStatusFromDataMessage128FirstWord); + Nan::SetMethod(constructor, "getNumberOfBytesFromDataMessage128FirstWord", GetNumberOfBytesFromDataMessage128FirstWord); + Nan::SetMethod(constructor, "messageTypeHasChannelField", MessageTypeHasChannelField); + Nan::SetMethod(constructor, "replaceChannelInMessageFirstWord", ReplaceChannelInMessageFirstWord); + Nan::SetMethod(constructor, "getChannelFromMessageFirstWord", GetChannelFromMessageFirstWord); + Nan::SetMethod(constructor, "getFormFromStreamMessageFirstWord", GetFormFromStreamMessageFirstWord); + Nan::SetMethod(constructor, "getStatusFromStreamMessageFirstWord", GetStatusFromStreamMessageFirstWord); + Nan::SetMethod(constructor, "getMessageFriendlyNameFromFirstWord", GetMessageFriendlyNameFromFirstWord); + Nan::SetMethod(constructor, "getPacketListFromWordList", GetPacketListFromWordList); + Nan::SetMethod(constructor, "getWordListFromPacketList", GetWordListFromPacketList); + + + Nan::Set(exports, Nan::New("MidiMessageUtility").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiMessageUtility^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageUtility^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageUtility^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiMessageUtility *wrapperInstance = new MidiMessageUtility(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageUtility^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiMessageUtility^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiMessageUtility^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiMessageUtility(winRtInstance)); + } + + + + + + static void ValidateMessage32MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage32MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ValidateMessage64MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage64MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ValidateMessage96MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage96MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ValidateMessage128MessageType(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ValidateMessage128MessageType(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetMessageTypeFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiMessageType result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetMessageTypeFromMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetPacketTypeFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiPacketType result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetPacketTypeFromMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void MessageTypeHasGroupField(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiMessageType arg0 = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::MessageTypeHasGroupField(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ReplaceGroupInMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiGroup^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiGroup^ arg1 = UnwrapMidiGroup(info[1]); + + unsigned int result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ReplaceGroupInMessageFirstWord(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetGroupFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiGroup^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetGroupFromMessageFirstWord(arg0); + info.GetReturnValue().Set(WrapMidiGroup(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromUtilityMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromUtilityMessage(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromMidi1ChannelVoiceMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::Midi1ChannelVoiceMessageStatus result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromMidi1ChannelVoiceMessage(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromMidi2ChannelVoiceMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::Midi2ChannelVoiceMessageStatus result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromMidi2ChannelVoiceMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusBankFromFlexDataMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusBankFromFlexDataMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromFlexDataMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromFlexDataMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromSystemCommonMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromSystemCommonMessage(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromDataMessage64FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromDataMessage64FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetNumberOfBytesFromDataMessage64FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetNumberOfBytesFromDataMessage64FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromDataMessage128FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromDataMessage128FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetNumberOfBytesFromDataMessage128FirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetNumberOfBytesFromDataMessage128FirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void MessageTypeHasChannelField(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + ::Windows::Devices::Midi2::MidiMessageType arg0 = static_cast<::Windows::Devices::Midi2::MidiMessageType>(Nan::To(info[0]).FromMaybe(0)); + + bool result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::MessageTypeHasChannelField(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ReplaceChannelInMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsUint32() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiChannel^>(info[1])) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiChannel^ arg1 = UnwrapMidiChannel(info[1]); + + unsigned int result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::ReplaceChannelInMessageFirstWord(arg0, arg1); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetChannelFromMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiChannel^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetChannelFromMessageFirstWord(arg0); + info.GetReturnValue().Set(WrapMidiChannel(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetFormFromStreamMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned char result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetFormFromStreamMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetStatusFromStreamMessageFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + unsigned short result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetStatusFromStreamMessageFirstWord(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetMessageFriendlyNameFromFirstWord(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsUint32()) + { + try + { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetMessageFriendlyNameFromFirstWord(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetPacketListFromWordList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable^>(info[1]) || info[1]->IsArray())) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + ::Windows::Foundation::Collections::IIterable^ arg1 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector(value.As(), + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[1]); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetPacketListFromWordList(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetWordListFromPacketList(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + ::Windows::Foundation::Collections::IVector^ result; + result = ::Windows::Devices::Midi2::MidiMessageUtility::GetWordListFromPacketList(arg0); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned int val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsUint32(); + }, + [](Local value) -> unsigned int { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiMessageUtility^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiMessageUtility^ UnwrapMidiMessageUtility(Local value); + }; + + Persistent MidiMessageUtility::s_constructorTemplate; + + v8::Local WrapMidiMessageUtility(::Windows::Devices::Midi2::MidiMessageUtility^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiMessageUtility::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiMessageUtility^ UnwrapMidiMessageUtility(Local value) { + return MidiMessageUtility::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiMessageUtility(Local exports) { + MidiMessageUtility::Init(exports); + } + + class MidiService : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiService").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "pingService", PingService); + Nan::SetMethod(constructor, "getInstalledTransportPlugins", GetInstalledTransportPlugins); + Nan::SetMethod(constructor, "getInstalledMessageProcessingPlugins", GetInstalledMessageProcessingPlugins); + Nan::SetMethod(constructor, "getActiveSessions", GetActiveSessions); + Nan::SetMethod(constructor, "createTemporaryLoopbackEndpoints", CreateTemporaryLoopbackEndpoints); + Nan::SetMethod(constructor, "removeTemporaryLoopbackEndpoints", RemoveTemporaryLoopbackEndpoints); + Nan::SetMethod(constructor, "updateTransportPluginConfiguration", UpdateTransportPluginConfiguration); + Nan::SetMethod(constructor, "updateProcessingPluginConfiguration", UpdateProcessingPluginConfiguration); + + + Nan::Set(exports, Nan::New("MidiService").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiService(::Windows::Devices::Midi2::MidiService^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiService^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiService^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiService^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiService *wrapperInstance = new MidiService(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiService^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiService^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiService^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiService(winRtInstance)); + } + + + + + + static void PingService(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsInt32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ result; + result = ::Windows::Devices::Midi2::MidiService::PingService(arg0); + info.GetReturnValue().Set(WrapMidiServicePingResponseSummary(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsInt32() + && info[1]->IsUint32()) + { + try + { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned int arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ result; + result = ::Windows::Devices::Midi2::MidiService::PingService(arg0, arg1); + info.GetReturnValue().Set(WrapMidiServicePingResponseSummary(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetInstalledTransportPlugins(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>^ result; + result = ::Windows::Devices::Midi2::MidiService::GetInstalledTransportPlugins(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ val) -> Local { + return WrapMidiServiceTransportPluginInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ { + return UnwrapMidiServiceTransportPluginInfo(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetInstalledMessageProcessingPlugins(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>^ result; + result = ::Windows::Devices::Midi2::MidiService::GetInstalledMessageProcessingPlugins(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ val) -> Local { + return WrapMidiServiceMessageProcessingPluginInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ { + return UnwrapMidiServiceMessageProcessingPluginInfo(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void GetActiveSessions(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiServiceSessionInfo^>^ result; + result = ::Windows::Devices::Midi2::MidiService::GetActiveSessions(); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiServiceSessionInfo^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceSessionInfo^ val) -> Local { + return WrapMidiServiceSessionInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceSessionInfo^ { + return UnwrapMidiServiceSessionInfo(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void CreateTemporaryLoopbackEndpoints(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && NodeRT::Utils::IsGuid(info[0]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[1]) + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[2])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ arg1 = UnwrapMidiServiceLoopbackEndpointDefinition(info[1]); + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ arg2 = UnwrapMidiServiceLoopbackEndpointDefinition(info[2]); + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ result; + result = ::Windows::Devices::Midi2::MidiService::CreateTemporaryLoopbackEndpoints(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapMidiServiceLoopbackEndpointCreationResult(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void RemoveTemporaryLoopbackEndpoints(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && NodeRT::Utils::IsGuid(info[0])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + + bool result; + result = ::Windows::Devices::Midi2::MidiService::RemoveTemporaryLoopbackEndpoints(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void UpdateTransportPluginConfiguration(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiServiceTransportPluginConfiguration^ arg0 = UnwrapIMidiServiceTransportPluginConfiguration(info[0]); + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ result; + result = ::Windows::Devices::Midi2::MidiService::UpdateTransportPluginConfiguration(arg0); + info.GetReturnValue().Set(WrapMidiServiceConfigurationResponse(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void UpdateProcessingPluginConfiguration(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiServiceMessageProcessingPluginConfiguration^ arg0 = UnwrapIMidiServiceMessageProcessingPluginConfiguration(info[0]); + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ result; + result = ::Windows::Devices::Midi2::MidiService::UpdateProcessingPluginConfiguration(arg0); + info.GetReturnValue().Set(WrapMidiServiceConfigurationResponse(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiService^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiService(::Windows::Devices::Midi2::MidiService^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiService^ UnwrapMidiService(Local value); + }; + + Persistent MidiService::s_constructorTemplate; + + v8::Local WrapMidiService(::Windows::Devices::Midi2::MidiService^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiService::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiService^ UnwrapMidiService(Local value) { + return MidiService::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiService(Local exports) { + MidiService::Init(exports); + } + + class MidiServiceConfigurationResponse : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceConfigurationResponse").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("responseJson").ToLocalChecked(), ResponseJsonGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("status").ToLocalChecked(), StatusGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceConfigurationResponse").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceConfigurationResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceConfigurationResponse *wrapperInstance = new MidiServiceConfigurationResponse(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceConfigurationResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceConfigurationResponse(winRtInstance)); + } + + + + + + static void ResponseJsonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info.This())) { + return; + } + + MidiServiceConfigurationResponse *wrapper = MidiServiceConfigurationResponse::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ResponseJson; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void StatusGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceConfigurationResponse^>(info.This())) { + return; + } + + MidiServiceConfigurationResponse *wrapper = MidiServiceConfigurationResponse::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiServiceConfigurationResponseStatus result = wrapper->_instance->Status; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ UnwrapMidiServiceConfigurationResponse(Local value); + }; + + Persistent MidiServiceConfigurationResponse::s_constructorTemplate; + + v8::Local WrapMidiServiceConfigurationResponse(::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceConfigurationResponse::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceConfigurationResponse^ UnwrapMidiServiceConfigurationResponse(Local value) { + return MidiServiceConfigurationResponse::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceConfigurationResponse(Local exports) { + MidiServiceConfigurationResponse::Init(exports); + } + + class MidiServiceLoopbackEndpointCreationResult : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceLoopbackEndpointCreationResult").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("associationId").ToLocalChecked(), AssociationIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceIdA").ToLocalChecked(), EndpointDeviceIdAGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceIdB").ToLocalChecked(), EndpointDeviceIdBGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("success").ToLocalChecked(), SuccessGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceLoopbackEndpointCreationResult").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceLoopbackEndpointCreationResult *wrapperInstance = new MidiServiceLoopbackEndpointCreationResult(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceLoopbackEndpointCreationResult(winRtInstance)); + } + + + + + + static void AssociationIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->AssociationId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdAGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceIdA; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdBGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceIdB; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuccessGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointCreationResult *wrapper = MidiServiceLoopbackEndpointCreationResult::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->Success; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ UnwrapMidiServiceLoopbackEndpointCreationResult(Local value); + }; + + Persistent MidiServiceLoopbackEndpointCreationResult::s_constructorTemplate; + + v8::Local WrapMidiServiceLoopbackEndpointCreationResult(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceLoopbackEndpointCreationResult::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointCreationResult^ UnwrapMidiServiceLoopbackEndpointCreationResult(Local value) { + return MidiServiceLoopbackEndpointCreationResult::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceLoopbackEndpointCreationResult(Local exports) { + MidiServiceLoopbackEndpointCreationResult::Init(exports); + } + + class MidiServiceLoopbackEndpointDefinition : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceLoopbackEndpointDefinition").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("uniqueId").ToLocalChecked(), UniqueIdGetter, UniqueIdSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("description").ToLocalChecked(), DescriptionGetter, DescriptionSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceLoopbackEndpointDefinition").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceLoopbackEndpointDefinition *wrapperInstance = new MidiServiceLoopbackEndpointDefinition(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceLoopbackEndpointDefinition(winRtInstance)); + } + + + + + + static void UniqueIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->UniqueId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UniqueIdSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->UniqueId = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Description; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DescriptionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^>(info.This())) { + return; + } + + MidiServiceLoopbackEndpointDefinition *wrapper = MidiServiceLoopbackEndpointDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Description = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ UnwrapMidiServiceLoopbackEndpointDefinition(Local value); + }; + + Persistent MidiServiceLoopbackEndpointDefinition::s_constructorTemplate; + + v8::Local WrapMidiServiceLoopbackEndpointDefinition(::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceLoopbackEndpointDefinition::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceLoopbackEndpointDefinition^ UnwrapMidiServiceLoopbackEndpointDefinition(Local value) { + return MidiServiceLoopbackEndpointDefinition::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceLoopbackEndpointDefinition(Local exports) { + MidiServiceLoopbackEndpointDefinition::Init(exports); + } + + class MidiServiceMessageProcessingPluginInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceMessageProcessingPluginInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("author").ToLocalChecked(), AuthorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientConfigurationAssemblyName").ToLocalChecked(), ClientConfigurationAssemblyNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("description").ToLocalChecked(), DescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isClientConfigurable").ToLocalChecked(), IsClientConfigurableGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isSystemManaged").ToLocalChecked(), IsSystemManagedGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("smallImagePath").ToLocalChecked(), SmallImagePathGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMultipleInstancesPerDevice").ToLocalChecked(), SupportsMultipleInstancesPerDeviceGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("version").ToLocalChecked(), VersionGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceMessageProcessingPluginInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceMessageProcessingPluginInfo *wrapperInstance = new MidiServiceMessageProcessingPluginInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceMessageProcessingPluginInfo(winRtInstance)); + } + + + + + + static void AuthorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Author; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientConfigurationAssemblyNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ClientConfigurationAssemblyName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Description; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsClientConfigurableGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsClientConfigurable; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsSystemManagedGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsSystemManaged; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SmallImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SmallImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMultipleInstancesPerDeviceGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMultipleInstancesPerDevice; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void VersionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^>(info.This())) { + return; + } + + MidiServiceMessageProcessingPluginInfo *wrapper = MidiServiceMessageProcessingPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Version; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ UnwrapMidiServiceMessageProcessingPluginInfo(Local value); + }; + + Persistent MidiServiceMessageProcessingPluginInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceMessageProcessingPluginInfo(::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceMessageProcessingPluginInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceMessageProcessingPluginInfo^ UnwrapMidiServiceMessageProcessingPluginInfo(Local value) { + return MidiServiceMessageProcessingPluginInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceMessageProcessingPluginInfo(Local exports) { + MidiServiceMessageProcessingPluginInfo::Init(exports); + } + + class MidiServicePingResponse : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServicePingResponse").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientDeltaTimestamp").ToLocalChecked(), ClientDeltaTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientReceiveMidiTimestamp").ToLocalChecked(), ClientReceiveMidiTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientSendMidiTimestamp").ToLocalChecked(), ClientSendMidiTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("index").ToLocalChecked(), IndexGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("serviceReportedMidiTimestamp").ToLocalChecked(), ServiceReportedMidiTimestampGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("sourceId").ToLocalChecked(), SourceIdGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServicePingResponse").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServicePingResponse^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServicePingResponse *wrapperInstance = new MidiServicePingResponse(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServicePingResponse^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponse^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServicePingResponse(winRtInstance)); + } + + + + + + static void ClientDeltaTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ClientDeltaTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientReceiveMidiTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ClientReceiveMidiTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientSendMidiTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ClientSendMidiTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IndexGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->Index; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ServiceReportedMidiTimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ServiceReportedMidiTimestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SourceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(info.This())) { + return; + } + + MidiServicePingResponse *wrapper = MidiServicePingResponse::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->SourceId; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServicePingResponse^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServicePingResponse^ UnwrapMidiServicePingResponse(Local value); + }; + + Persistent MidiServicePingResponse::s_constructorTemplate; + + v8::Local WrapMidiServicePingResponse(::Windows::Devices::Midi2::MidiServicePingResponse^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServicePingResponse::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServicePingResponse^ UnwrapMidiServicePingResponse(Local value) { + return MidiServicePingResponse::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServicePingResponse(Local exports) { + MidiServicePingResponse::Init(exports); + } + + class MidiServicePingResponseSummary : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServicePingResponseSummary").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("averagePingRoundTripMidiClock").ToLocalChecked(), AveragePingRoundTripMidiClockGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("failureReason").ToLocalChecked(), FailureReasonGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("responses").ToLocalChecked(), ResponsesGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("success").ToLocalChecked(), SuccessGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("totalPingRoundTripMidiClock").ToLocalChecked(), TotalPingRoundTripMidiClockGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServicePingResponseSummary").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponseSummary^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServicePingResponseSummary *wrapperInstance = new MidiServicePingResponseSummary(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServicePingResponseSummary^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServicePingResponseSummary(winRtInstance)); + } + + + + + + static void AveragePingRoundTripMidiClockGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->AveragePingRoundTripMidiClock; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FailureReasonGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->FailureReason; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ResponsesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiServicePingResponse^>^ result = wrapper->_instance->Responses; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiServicePingResponse^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiServicePingResponse^ val) -> Local { + return WrapMidiServicePingResponse(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponse^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServicePingResponse^ { + return UnwrapMidiServicePingResponse(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuccessGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->Success; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TotalPingRoundTripMidiClockGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServicePingResponseSummary^>(info.This())) { + return; + } + + MidiServicePingResponseSummary *wrapper = MidiServicePingResponseSummary::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->TotalPingRoundTripMidiClock; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ UnwrapMidiServicePingResponseSummary(Local value); + }; + + Persistent MidiServicePingResponseSummary::s_constructorTemplate; + + v8::Local WrapMidiServicePingResponseSummary(::Windows::Devices::Midi2::MidiServicePingResponseSummary^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServicePingResponseSummary::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServicePingResponseSummary^ UnwrapMidiServicePingResponseSummary(Local value) { + return MidiServicePingResponseSummary::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServicePingResponseSummary(Local exports) { + MidiServicePingResponseSummary::Init(exports); + } + + class MidiServiceSessionConnectionInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceSessionConnectionInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("earliestConnectionTime").ToLocalChecked(), EarliestConnectionTimeGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointDeviceId").ToLocalChecked(), EndpointDeviceIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("instanceCount").ToLocalChecked(), InstanceCountGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceSessionConnectionInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceSessionConnectionInfo *wrapperInstance = new MidiServiceSessionConnectionInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceSessionConnectionInfo(winRtInstance)); + } + + + + + + static void EarliestConnectionTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info.This())) { + return; + } + + MidiServiceSessionConnectionInfo *wrapper = MidiServiceSessionConnectionInfo::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->EarliestConnectionTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointDeviceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info.This())) { + return; + } + + MidiServiceSessionConnectionInfo *wrapper = MidiServiceSessionConnectionInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointDeviceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void InstanceCountGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(info.This())) { + return; + } + + MidiServiceSessionConnectionInfo *wrapper = MidiServiceSessionConnectionInfo::Unwrap(info.This()); + + try { + unsigned short result = wrapper->_instance->InstanceCount; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ UnwrapMidiServiceSessionConnectionInfo(Local value); + }; + + Persistent MidiServiceSessionConnectionInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceSessionConnectionInfo(::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceSessionConnectionInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ UnwrapMidiServiceSessionConnectionInfo(Local value) { + return MidiServiceSessionConnectionInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceSessionConnectionInfo(Local exports) { + MidiServiceSessionConnectionInfo::Init(exports); + } + + class MidiServiceSessionInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceSessionInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("connections").ToLocalChecked(), ConnectionsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("processId").ToLocalChecked(), ProcessIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("processName").ToLocalChecked(), ProcessNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("sessionId").ToLocalChecked(), SessionIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("sessionName").ToLocalChecked(), SessionNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("startTime").ToLocalChecked(), StartTimeGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceSessionInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceSessionInfo *wrapperInstance = new MidiServiceSessionInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceSessionInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceSessionInfo(winRtInstance)); + } + + + + + + static void ConnectionsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVectorView<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>^ result = wrapper->_instance->Connections; + info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>::CreateVectorViewWrapper(result, + [](::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ val) -> Local { + return WrapMidiServiceSessionConnectionInfo(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiServiceSessionConnectionInfo^ { + return UnwrapMidiServiceSessionConnectionInfo(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProcessIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->ProcessId; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ProcessNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ProcessName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SessionIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->SessionId; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SessionNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SessionName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void StartTimeGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceSessionInfo^>(info.This())) { + return; + } + + MidiServiceSessionInfo *wrapper = MidiServiceSessionInfo::Unwrap(info.This()); + + try { + ::Windows::Foundation::DateTime result = wrapper->_instance->StartTime; + info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceSessionInfo^ UnwrapMidiServiceSessionInfo(Local value); + }; + + Persistent MidiServiceSessionInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceSessionInfo(::Windows::Devices::Midi2::MidiServiceSessionInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceSessionInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceSessionInfo^ UnwrapMidiServiceSessionInfo(Local value) { + return MidiServiceSessionInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceSessionInfo(Local exports) { + MidiServiceSessionInfo::Init(exports); + } + + class MidiServiceTransportPluginInfo : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiServiceTransportPluginInfo").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("author").ToLocalChecked(), AuthorGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("clientConfigurationAssemblyName").ToLocalChecked(), ClientConfigurationAssemblyNameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("description").ToLocalChecked(), DescriptionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isClientConfigurable").ToLocalChecked(), IsClientConfigurableGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isRuntimeCreatableByApps").ToLocalChecked(), IsRuntimeCreatableByAppsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isRuntimeCreatableBySettings").ToLocalChecked(), IsRuntimeCreatableBySettingsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isSystemManaged").ToLocalChecked(), IsSystemManagedGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("mnemonic").ToLocalChecked(), MnemonicGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("smallImagePath").ToLocalChecked(), SmallImagePathGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("version").ToLocalChecked(), VersionGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiServiceTransportPluginInfo").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiServiceTransportPluginInfo *wrapperInstance = new MidiServiceTransportPluginInfo(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiServiceTransportPluginInfo(winRtInstance)); + } + + + + + + static void AuthorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Author; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void ClientConfigurationAssemblyNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->ClientConfigurationAssemblyName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Description; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsClientConfigurableGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsClientConfigurable; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsRuntimeCreatableByAppsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsRuntimeCreatableByApps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsRuntimeCreatableBySettingsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsRuntimeCreatableBySettings; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsSystemManagedGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsSystemManaged; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void MnemonicGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Mnemonic; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SmallImagePathGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->SmallImagePath; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void VersionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^>(info.This())) { + return; + } + + MidiServiceTransportPluginInfo *wrapper = MidiServiceTransportPluginInfo::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Version; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ UnwrapMidiServiceTransportPluginInfo(Local value); + }; + + Persistent MidiServiceTransportPluginInfo::s_constructorTemplate; + + v8::Local WrapMidiServiceTransportPluginInfo(::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiServiceTransportPluginInfo::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiServiceTransportPluginInfo^ UnwrapMidiServiceTransportPluginInfo(Local value) { + return MidiServiceTransportPluginInfo::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiServiceTransportPluginInfo(Local exports) { + MidiServiceTransportPluginInfo::Init(exports); + } + + class MidiSession : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiSession").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "createEndpointConnection", CreateEndpointConnection); + Nan::SetPrototypeMethod(localRef, "createVirtualDeviceAndConnection", CreateVirtualDeviceAndConnection); + Nan::SetPrototypeMethod(localRef, "disconnectEndpointConnection", DisconnectEndpointConnection); + Nan::SetPrototypeMethod(localRef, "updateName", UpdateName); + Nan::SetPrototypeMethod(localRef, "close", Close); + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("connections").ToLocalChecked(), ConnectionsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isOpen").ToLocalChecked(), IsOpenGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("settings").ToLocalChecked(), SettingsGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createSession", CreateSession); + + + Nan::Set(exports, Nan::New("MidiSession").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiSession(::Windows::Devices::Midi2::MidiSession^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiSession^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSession^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiSession *wrapperInstance = new MidiSession(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiSession^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSession^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiSession(winRtInstance)); + } + + + static void CreateEndpointConnection(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + ::Windows::Devices::Midi2::MidiEndpointConnection^ result; + result = wrapper->_instance->CreateEndpointConnection(arg0); + info.GetReturnValue().Set(WrapMidiEndpointConnection(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsString() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^>(info[1])) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + ::Windows::Devices::Midi2::IMidiEndpointConnectionSettings^ arg1 = UnwrapIMidiEndpointConnectionSettings(info[1]); + + ::Windows::Devices::Midi2::MidiEndpointConnection^ result; + result = wrapper->_instance->CreateEndpointConnection(arg0, arg1); + info.GetReturnValue().Set(WrapMidiEndpointConnection(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void CreateVirtualDeviceAndConnection(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ arg0 = UnwrapMidiVirtualEndpointDeviceDefinition(info[0]); + + ::Windows::Devices::Midi2::MidiEndpointConnection^ result; + result = wrapper->_instance->CreateVirtualDeviceAndConnection(arg0); + info.GetReturnValue().Set(WrapMidiEndpointConnection(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void DisconnectEndpointConnection(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsGuid(info[0])) + { + try + { + ::Platform::Guid arg0 = NodeRT::Utils::GuidFromJs(info[0]); + + wrapper->_instance->DisconnectEndpointConnection(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void UpdateName(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + bool result; + result = wrapper->_instance->UpdateName(arg0); + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Close(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + if (info.Length() == 0) { + try { + delete wrapper->_instance; + wrapper->_instance = nullptr; + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void CreateSession(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + ::Windows::Devices::Midi2::MidiSession^ result; + result = ::Windows::Devices::Midi2::MidiSession::CreateSession(arg0); + info.GetReturnValue().Set(WrapMidiSession(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 2 + && info[0]->IsString() + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info[1])) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + ::Windows::Devices::Midi2::MidiSessionSettings^ arg1 = UnwrapMidiSessionSettings(info[1]); + + ::Windows::Devices::Midi2::MidiSession^ result; + result = ::Windows::Devices::Midi2::MidiSession::CreateSession(arg0, arg1); + info.GetReturnValue().Set(WrapMidiSession(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ConnectionsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView<::Platform::Guid, ::Windows::Devices::Midi2::MidiEndpointConnection^>^ result = wrapper->_instance->Connections; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper<::Platform::Guid,::Windows::Devices::Midi2::MidiEndpointConnection^>::CreateMapViewWrapper(result, + [](::Platform::Guid val) -> Local { + return NodeRT::Utils::GuidToJs(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsGuid(value); + }, + [](Local value) -> ::Platform::Guid { + return NodeRT::Utils::GuidFromJs(value); + }, + [](::Windows::Devices::Midi2::MidiEndpointConnection^ val) -> Local { + return WrapMidiEndpointConnection(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsOpenGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsOpen; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SettingsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSession^>(info.This())) { + return; + } + + MidiSession *wrapper = MidiSession::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiSessionSettings^ result = wrapper->_instance->Settings; + info.GetReturnValue().Set(WrapMidiSessionSettings(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiSession^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiSession(::Windows::Devices::Midi2::MidiSession^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiSession^ UnwrapMidiSession(Local value); + }; + + Persistent MidiSession::s_constructorTemplate; + + v8::Local WrapMidiSession(::Windows::Devices::Midi2::MidiSession^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiSession::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiSession^ UnwrapMidiSession(Local value) { + return MidiSession::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiSession(Local exports) { + MidiSession::Init(exports); + } + + class MidiSessionSettings : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiSessionSettings").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("useMmcssThreads").ToLocalChecked(), UseMmcssThreadsGetter, UseMmcssThreadsSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiSessionSettings").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiSessionSettings^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSessionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiSessionSettings(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiSessionSettings *wrapperInstance = new MidiSessionSettings(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiSessionSettings^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiSessionSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiSessionSettings(winRtInstance)); + } + + + + + + static void UseMmcssThreadsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info.This())) { + return; + } + + MidiSessionSettings *wrapper = MidiSessionSettings::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->UseMmcssThreads; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void UseMmcssThreadsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiSessionSettings^>(info.This())) { + return; + } + + MidiSessionSettings *wrapper = MidiSessionSettings::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->UseMmcssThreads = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::MidiSessionSettings^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiSessionSettings^ UnwrapMidiSessionSettings(Local value); + }; + + Persistent MidiSessionSettings::s_constructorTemplate; + + v8::Local WrapMidiSessionSettings(::Windows::Devices::Midi2::MidiSessionSettings^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiSessionSettings::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiSessionSettings^ UnwrapMidiSessionSettings(Local value) { + return MidiSessionSettings::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiSessionSettings(Local exports) { + MidiSessionSettings::Init(exports); + } + + class MidiStreamConfigurationRequestReceivedEventArgs : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiStreamConfigurationRequestReceivedEventArgs").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preferredMidiProtocol").ToLocalChecked(), PreferredMidiProtocolGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointReceiveJitterReductionTimestamps").ToLocalChecked(), RequestEndpointReceiveJitterReductionTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointTransmitJitterReductionTimestamps").ToLocalChecked(), RequestEndpointTransmitJitterReductionTimestampsGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("timestamp").ToLocalChecked(), TimestampGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiStreamConfigurationRequestReceivedEventArgs").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiStreamConfigurationRequestReceivedEventArgs *wrapperInstance = new MidiStreamConfigurationRequestReceivedEventArgs(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiStreamConfigurationRequestReceivedEventArgs(winRtInstance)); + } + + + + + + static void PreferredMidiProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiProtocol result = wrapper->_instance->PreferredMidiProtocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointReceiveJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointReceiveJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointTransmitJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointTransmitJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TimestampGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestReceivedEventArgs *wrapper = MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(info.This()); + + try { + unsigned __int64 result = wrapper->_instance->Timestamp; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ UnwrapMidiStreamConfigurationRequestReceivedEventArgs(Local value); + }; + + Persistent MidiStreamConfigurationRequestReceivedEventArgs::s_constructorTemplate; + + v8::Local WrapMidiStreamConfigurationRequestReceivedEventArgs(::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiStreamConfigurationRequestReceivedEventArgs::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ UnwrapMidiStreamConfigurationRequestReceivedEventArgs(Local value) { + return MidiStreamConfigurationRequestReceivedEventArgs::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiStreamConfigurationRequestReceivedEventArgs(Local exports) { + MidiStreamConfigurationRequestReceivedEventArgs::Init(exports); + } + + class MidiStreamConfigurationRequestedSettings : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiStreamConfigurationRequestedSettings").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMinor").ToLocalChecked(), SpecificationVersionMinorGetter, SpecificationVersionMinorSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("specificationVersionMajor").ToLocalChecked(), SpecificationVersionMajorGetter, SpecificationVersionMajorSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointTransmitJitterReductionTimestamps").ToLocalChecked(), RequestEndpointTransmitJitterReductionTimestampsGetter, RequestEndpointTransmitJitterReductionTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("requestEndpointReceiveJitterReductionTimestamps").ToLocalChecked(), RequestEndpointReceiveJitterReductionTimestampsGetter, RequestEndpointReceiveJitterReductionTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("preferredMidiProtocol").ToLocalChecked(), PreferredMidiProtocolGetter, PreferredMidiProtocolSetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiStreamConfigurationRequestedSettings").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiStreamConfigurationRequestedSettings *wrapperInstance = new MidiStreamConfigurationRequestedSettings(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiStreamConfigurationRequestedSettings(winRtInstance)); + } + + + + + + static void SpecificationVersionMinorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMinor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMinorSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->SpecificationVersionMinor = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SpecificationVersionMajorGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->SpecificationVersionMajor; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SpecificationVersionMajorSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->SpecificationVersionMajor = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void RequestEndpointTransmitJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointTransmitJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointTransmitJitterReductionTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->RequestEndpointTransmitJitterReductionTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void RequestEndpointReceiveJitterReductionTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->RequestEndpointReceiveJitterReductionTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void RequestEndpointReceiveJitterReductionTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->RequestEndpointReceiveJitterReductionTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void PreferredMidiProtocolGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiProtocol result = wrapper->_instance->PreferredMidiProtocol; + info.GetReturnValue().Set(Nan::New(static_cast(result))); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void PreferredMidiProtocolSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^>(info.This())) { + return; + } + + MidiStreamConfigurationRequestedSettings *wrapper = MidiStreamConfigurationRequestedSettings::Unwrap(info.This()); + + try { + + ::Windows::Devices::Midi2::MidiProtocol winRtValue = static_cast<::Windows::Devices::Midi2::MidiProtocol>(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->PreferredMidiProtocol = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + + + private: + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ UnwrapMidiStreamConfigurationRequestedSettings(Local value); + }; + + Persistent MidiStreamConfigurationRequestedSettings::s_constructorTemplate; + + v8::Local WrapMidiStreamConfigurationRequestedSettings(::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiStreamConfigurationRequestedSettings::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiStreamConfigurationRequestedSettings^ UnwrapMidiStreamConfigurationRequestedSettings(Local value) { + return MidiStreamConfigurationRequestedSettings::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiStreamConfigurationRequestedSettings(Local exports) { + MidiStreamConfigurationRequestedSettings::Init(exports); + } + + class MidiStreamMessageBuilder : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiStreamMessageBuilder").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "buildEndpointDiscoveryMessage", BuildEndpointDiscoveryMessage); + Nan::SetMethod(constructor, "buildEndpointInfoNotificationMessage", BuildEndpointInfoNotificationMessage); + Nan::SetMethod(constructor, "buildDeviceIdentityNotificationMessage", BuildDeviceIdentityNotificationMessage); + Nan::SetMethod(constructor, "buildEndpointNameNotificationMessages", BuildEndpointNameNotificationMessages); + Nan::SetMethod(constructor, "buildProductInstanceIdNotificationMessages", BuildProductInstanceIdNotificationMessages); + Nan::SetMethod(constructor, "parseEndpointNameNotificationMessages", ParseEndpointNameNotificationMessages); + Nan::SetMethod(constructor, "parseProductInstanceIdNotificationMessages", ParseProductInstanceIdNotificationMessages); + Nan::SetMethod(constructor, "buildStreamConfigurationRequestMessage", BuildStreamConfigurationRequestMessage); + Nan::SetMethod(constructor, "buildStreamConfigurationNotificationMessage", BuildStreamConfigurationNotificationMessage); + Nan::SetMethod(constructor, "buildFunctionBlockDiscoveryMessage", BuildFunctionBlockDiscoveryMessage); + Nan::SetMethod(constructor, "buildFunctionBlockInfoNotificationMessage", BuildFunctionBlockInfoNotificationMessage); + Nan::SetMethod(constructor, "buildFunctionBlockNameNotificationMessages", BuildFunctionBlockNameNotificationMessages); + Nan::SetMethod(constructor, "parseFunctionBlockNameNotificationMessages", ParseFunctionBlockNameNotificationMessages); + + + Nan::Set(exports, Nan::New("MidiStreamMessageBuilder").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamMessageBuilder^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiStreamMessageBuilder *wrapperInstance = new MidiStreamMessageBuilder(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiStreamMessageBuilder^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiStreamMessageBuilder^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiStreamMessageBuilder(winRtInstance)); + } + + + + + + static void BuildEndpointDiscoveryMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests arg3 = static_cast<::Windows::Devices::Midi2::MidiEndpointDiscoveryRequests>(Nan::To(info[3]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildEndpointDiscoveryMessage(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildEndpointInfoNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 9 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsBoolean() + && info[4]->IsInt32() + && info[5]->IsBoolean() + && info[6]->IsBoolean() + && info[7]->IsBoolean() + && info[8]->IsBoolean()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + bool arg3 = Nan::To(info[3]).FromMaybe(false); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + bool arg5 = Nan::To(info[5]).FromMaybe(false); + bool arg6 = Nan::To(info[6]).FromMaybe(false); + bool arg7 = Nan::To(info[7]).FromMaybe(false); + bool arg8 = Nan::To(info[8]).FromMaybe(false); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildEndpointInfoNotificationMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildDeviceIdentityNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 12 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32() + && info[10]->IsInt32() + && info[11]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + unsigned char arg4 = static_cast(Nan::To(info[4]).FromMaybe(0)); + unsigned char arg5 = static_cast(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + unsigned char arg10 = static_cast(Nan::To(info[10]).FromMaybe(0)); + unsigned char arg11 = static_cast(Nan::To(info[11]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildDeviceIdentityNotificationMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildEndpointNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsString()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1]))); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildEndpointNameNotificationMessages(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildProductInstanceIdNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 2 + && info[0]->IsNumber() + && info[1]->IsString()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1]))); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildProductInstanceIdNotificationMessages(arg0, arg1); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ParseEndpointNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::ParseEndpointNameNotificationMessages(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ParseProductInstanceIdNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::ParseProductInstanceIdNotificationMessages(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildStreamConfigurationRequestMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsBoolean() + && info[3]->IsBoolean()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + bool arg2 = Nan::To(info[2]).FromMaybe(false); + bool arg3 = Nan::To(info[3]).FromMaybe(false); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildStreamConfigurationRequestMessage(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildStreamConfigurationNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 4 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsBoolean() + && info[3]->IsBoolean()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + bool arg2 = Nan::To(info[2]).FromMaybe(false); + bool arg3 = Nan::To(info[3]).FromMaybe(false); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildStreamConfigurationNotificationMessage(arg0, arg1, arg2, arg3); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFunctionBlockDiscoveryMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests arg2 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockDiscoveryRequests>(Nan::To(info[2]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildFunctionBlockDiscoveryMessage(arg0, arg1, arg2); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFunctionBlockInfoNotificationMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 10 + && info[0]->IsNumber() + && info[1]->IsBoolean() + && info[2]->IsInt32() + && info[3]->IsInt32() + && info[4]->IsInt32() + && info[5]->IsInt32() + && info[6]->IsInt32() + && info[7]->IsInt32() + && info[8]->IsInt32() + && info[9]->IsInt32()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + bool arg1 = Nan::To(info[1]).FromMaybe(false); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockUIHint arg3 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockUIHint>(Nan::To(info[3]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockMidi10 arg4 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockMidi10>(Nan::To(info[4]).FromMaybe(0)); + ::Windows::Devices::Midi2::MidiFunctionBlockDirection arg5 = static_cast<::Windows::Devices::Midi2::MidiFunctionBlockDirection>(Nan::To(info[5]).FromMaybe(0)); + unsigned char arg6 = static_cast(Nan::To(info[6]).FromMaybe(0)); + unsigned char arg7 = static_cast(Nan::To(info[7]).FromMaybe(0)); + unsigned char arg8 = static_cast(Nan::To(info[8]).FromMaybe(0)); + unsigned char arg9 = static_cast(Nan::To(info[9]).FromMaybe(0)); + + ::Windows::Devices::Midi2::IMidiUniversalPacket^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildFunctionBlockInfoNotificationMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + info.GetReturnValue().Set(WrapIMidiUniversalPacket(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void BuildFunctionBlockNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 3 + && info[0]->IsNumber() + && info[1]->IsInt32() + && info[2]->IsString()) + { + try + { + unsigned __int64 arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[2]))); + + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::BuildFunctionBlockNameNotificationMessages(arg0, arg1, arg2); + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::IMidiUniversalPacket^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::IMidiUniversalPacket^ val) -> Local { + return WrapIMidiUniversalPacket(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + )); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void ParseFunctionBlockNameNotificationMessages(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 1 + && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(info[0]) || info[0]->IsArray())) + { + try + { + ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ arg0 = + [] (v8::Local value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^ + { + if (value->IsArray()) + { + return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value.As(), + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiUniversalPacket^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::IMidiUniversalPacket^ { + return UnwrapIMidiUniversalPacket(value); + } + ); + } + else + { + return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Devices::Midi2::IMidiUniversalPacket^>^>(NodeRT::Utils::GetObjectInstance(value)); + } + } (info[0]); + + Platform::String^ result; + result = ::Windows::Devices::Midi2::MidiStreamMessageBuilder::ParseFunctionBlockNameNotificationMessages(arg0); + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ UnwrapMidiStreamMessageBuilder(Local value); + }; + + Persistent MidiStreamMessageBuilder::s_constructorTemplate; + + v8::Local WrapMidiStreamMessageBuilder(::Windows::Devices::Midi2::MidiStreamMessageBuilder^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiStreamMessageBuilder::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiStreamMessageBuilder^ UnwrapMidiStreamMessageBuilder(Local value) { + return MidiStreamMessageBuilder::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiStreamMessageBuilder(Local exports) { + MidiStreamMessageBuilder::Init(exports); + } + + class MidiUniqueId : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiUniqueId").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte4").ToLocalChecked(), Byte4Getter, Byte4Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte3").ToLocalChecked(), Byte3Getter, Byte3Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte2").ToLocalChecked(), Byte2Getter, Byte2Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("byte1").ToLocalChecked(), Byte1Getter, Byte1Setter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("asCombined28BitValue").ToLocalChecked(), AsCombined28BitValueGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isBroadcast").ToLocalChecked(), IsBroadcastGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isReserved").ToLocalChecked(), IsReservedGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + Nan::SetMethod(constructor, "createBroadcast", CreateBroadcast); + Nan::SetMethod(constructor, "createRandom", CreateRandom); + Nan::SetAccessor(constructor, Nan::New("labelFull").ToLocalChecked(), LabelFullGetter); + Nan::SetAccessor(constructor, Nan::New("labelShort").ToLocalChecked(), LabelShortGetter); + + + Nan::Set(exports, Nan::New("MidiUniqueId").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiUniqueId^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiUniqueId^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 1 + && info[0]->IsUint32()) + { + try { + unsigned int arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiUniqueId(arg0); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 4 + && info[0]->IsInt32() + && info[1]->IsInt32() + && info[2]->IsInt32() + && info[3]->IsInt32()) + { + try { + unsigned char arg0 = static_cast(Nan::To(info[0]).FromMaybe(0)); + unsigned char arg1 = static_cast(Nan::To(info[1]).FromMaybe(0)); + unsigned char arg2 = static_cast(Nan::To(info[2]).FromMaybe(0)); + unsigned char arg3 = static_cast(Nan::To(info[3]).FromMaybe(0)); + + winRtInstance = ref new ::Windows::Devices::Midi2::MidiUniqueId(arg0,arg1,arg2,arg3); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiUniqueId(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiUniqueId *wrapperInstance = new MidiUniqueId(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiUniqueId^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiUniqueId^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiUniqueId(winRtInstance)); + } + + + + + + static void CreateBroadcast(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiUniqueId^ result; + result = ::Windows::Devices::Midi2::MidiUniqueId::CreateBroadcast(); + info.GetReturnValue().Set(WrapMidiUniqueId(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void CreateRandom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() == 0) + { + try + { + ::Windows::Devices::Midi2::MidiUniqueId^ result; + result = ::Windows::Devices::Midi2::MidiUniqueId::CreateRandom(); + info.GetReturnValue().Set(WrapMidiUniqueId(result)); + return; + } + catch (Platform::Exception ^exception) + { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + static void Byte4Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte4; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte4Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte4 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Byte3Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte3; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte3Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte3 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Byte2Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte2; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte2Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte2 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void Byte1Getter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->Byte1; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void Byte1Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->Byte1 = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void AsCombined28BitValueGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + unsigned int result = wrapper->_instance->AsCombined28BitValue; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsBroadcastGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsBroadcast; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsReservedGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiUniqueId^>(info.This())) { + return; + } + + MidiUniqueId *wrapper = MidiUniqueId::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsReserved; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void LabelFullGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiUniqueId::LabelFull; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + static void LabelShortGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + try + { + Platform::String^ result = ::Windows::Devices::Midi2::MidiUniqueId::LabelShort; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + private: + ::Windows::Devices::Midi2::MidiUniqueId^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiUniqueId^ UnwrapMidiUniqueId(Local value); + }; + + Persistent MidiUniqueId::s_constructorTemplate; + + v8::Local WrapMidiUniqueId(::Windows::Devices::Midi2::MidiUniqueId^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiUniqueId::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiUniqueId^ UnwrapMidiUniqueId(Local value) { + return MidiUniqueId::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiUniqueId(Local exports) { + MidiUniqueId::Init(exports); + } + + class MidiVirtualEndpointDevice : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiVirtualEndpointDevice").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + Nan::SetPrototypeMethod(localRef, "updateFunctionBlock", UpdateFunctionBlock); + Nan::SetPrototypeMethod(localRef, "updateEndpointName", UpdateEndpointName); + Nan::SetPrototypeMethod(localRef, "initialize", Initialize); + Nan::SetPrototypeMethod(localRef, "onEndpointConnectionOpened", OnEndpointConnectionOpened); + Nan::SetPrototypeMethod(localRef, "processIncomingMessage", ProcessIncomingMessage); + Nan::SetPrototypeMethod(localRef, "cleanup", Cleanup); + + + + + Nan::SetPrototypeMethod(localRef,"addListener", AddListener); + Nan::SetPrototypeMethod(localRef,"on", AddListener); + Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); + Nan::SetPrototypeMethod(localRef, "off", RemoveListener); + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("tag").ToLocalChecked(), TagGetter, TagSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("name").ToLocalChecked(), NameGetter, NameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("isEnabled").ToLocalChecked(), IsEnabledGetter, IsEnabledSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("id").ToLocalChecked(), IdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("suppressHandledMessages").ToLocalChecked(), SuppressHandledMessagesGetter, SuppressHandledMessagesSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceDefinition").ToLocalChecked(), DeviceDefinitionGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocks").ToLocalChecked(), FunctionBlocksGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiVirtualEndpointDevice").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDevice^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiVirtualEndpointDevice *wrapperInstance = new MidiVirtualEndpointDevice(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDevice^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiVirtualEndpointDevice(winRtInstance)); + } + + + static void UpdateFunctionBlock(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiFunctionBlock^ arg0 = UnwrapMidiFunctionBlock(info[0]); + + wrapper->_instance->UpdateFunctionBlock(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void UpdateEndpointName(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && info[0]->IsString()) + { + try + { + Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0]))); + + wrapper->_instance->UpdateEndpointName(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Initialize(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::IMidiEndpointConnectionSource^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::IMidiEndpointConnectionSource^ arg0 = UnwrapIMidiEndpointConnectionSource(info[0]); + + wrapper->_instance->Initialize(arg0); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void OnEndpointConnectionOpened(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->OnEndpointConnectionOpened(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void ProcessIncomingMessage(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 1 + && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^>(info[0])) + { + try + { + ::Windows::Devices::Midi2::MidiMessageReceivedEventArgs^ arg0 = UnwrapMidiMessageReceivedEventArgs(info[0]); + bool arg1; + bool arg2; + + wrapper->_instance->ProcessIncomingMessage(arg0, &arg1, &arg2); + Local resObj = Nan::New(); + Nan::Set(resObj, Nan::New("skipFurtherListeners").ToLocalChecked(), Nan::New(arg1)); + Nan::Set(resObj, Nan::New("skipMainMessageReceivedEvent").ToLocalChecked(), Nan::New(arg2)); + info.GetReturnValue().Set(resObj); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + static void Cleanup(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + if (info.Length() == 0) + { + try + { + wrapper->_instance->Cleanup(); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); + return; + } + } + + + + static void TagGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Platform::Object^ result = wrapper->_instance->Tag; + info.GetReturnValue().Set(CreateOpaqueWrapper(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TagSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(value)) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + ::Platform::Object^ winRtValue = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(value)); + + wrapper->_instance->Tag = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void NameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->Name; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void NameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->Name = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IsEnabledGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->IsEnabled; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void IsEnabledSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->IsEnabled = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void IdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Platform::Guid result = wrapper->_instance->Id; + info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuppressHandledMessagesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SuppressHandledMessages; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SuppressHandledMessagesSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SuppressHandledMessages = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceDefinitionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ result = wrapper->_instance->DeviceDefinition; + info.GetReturnValue().Set(WrapMidiVirtualEndpointDeviceDefinition(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) { + return; + } + + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IMapView^ result = wrapper->_instance->FunctionBlocks; + info.GetReturnValue().Set(NodeRT::Collections::MapViewWrapper::CreateMapViewWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + }, + [](::Windows::Devices::Midi2::MidiFunctionBlock^ val) -> Local { + return WrapMidiFunctionBlock(val); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + Local callback = info[1].As(); + + ::Windows::Foundation::EventRegistrationToken registrationToken; + if (NodeRT::Utils::CaseInsenstiveEquals(L"streamConfigurationRequestReceived", str)) + { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + + try { + Persistent* perstPtr = new Persistent(); + perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); + std::shared_ptr> callbackObjPtr(perstPtr, + [] (Persistent *ptr ) { + NodeUtils::Async::RunOnMain([ptr]() { + ptr->Reset(); + delete ptr; + }); + }); + + registrationToken = wrapper->_instance->StreamConfigurationRequestReceived::add( + ref new ::Windows::Foundation::TypedEventHandler<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^, ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^>( + [callbackObjPtr](::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ arg0, ::Windows::Devices::Midi2::MidiStreamConfigurationRequestReceivedEventArgs^ arg1) { + NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() { + HandleScope scope; + + + Local wrappedArg0; + Local wrappedArg1; + + { + TryCatch tryCatch; + + + wrappedArg0 = WrapMidiVirtualEndpointDevice(arg0); + wrappedArg1 = WrapMidiStreamConfigurationRequestReceivedEventArgs(arg1); + + + if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined(); + if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined(); + } + + Local args[] = { wrappedArg0, wrappedArg1 }; + Local callbackObjLocalRef = Nan::New(*callbackObjPtr); + NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); + }); + }) + ); + } + catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + } + else { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + Local tokenMap; + + if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { + tokenMap = Nan::New(); + NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); + } else { + tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); + } + + Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); + } + + static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); + return; + } + + String::Value eventName(v8::Isolate::GetCurrent(), info[0]); + auto str = *eventName; + + if ((!NodeRT::Utils::CaseInsenstiveEquals(L"streamConfigurationRequestReceived", str))) { + Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); + return; + } + + Local callback = info[1].As(); + Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); + + if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { + return; + } + + Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); + + if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { + return; + } + + OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); + + long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); + ::Windows::Foundation::EventRegistrationToken registrationToken; + registrationToken.Value = tokenValue; + + try { + if (NodeRT::Utils::CaseInsenstiveEquals(L"streamConfigurationRequestReceived", str)) { + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDevice^>(info.This())) + { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); + return; + } + MidiVirtualEndpointDevice *wrapper = MidiVirtualEndpointDevice::Unwrap(info.This()); + wrapper->_instance->StreamConfigurationRequestReceived::remove(registrationToken); + } + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + + Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); + } + private: + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ UnwrapMidiVirtualEndpointDevice(Local value); + }; + + Persistent MidiVirtualEndpointDevice::s_constructorTemplate; + + v8::Local WrapMidiVirtualEndpointDevice(::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiVirtualEndpointDevice::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDevice^ UnwrapMidiVirtualEndpointDevice(Local value) { + return MidiVirtualEndpointDevice::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiVirtualEndpointDevice(Local exports) { + MidiVirtualEndpointDevice::Init(exports); + } + + class MidiVirtualEndpointDeviceDefinition : public WrapperBase { + public: + + static void Init(const Local exports) { + HandleScope scope; + + Local localRef = Nan::New(New); + s_constructorTemplate.Reset(localRef); + localRef->SetClassName(Nan::New("MidiVirtualEndpointDeviceDefinition").ToLocalChecked()); + localRef->InstanceTemplate()->SetInternalFieldCount(1); + + + + + + + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("transportSuppliedDescription").ToLocalChecked(), TransportSuppliedDescriptionGetter, TransportSuppliedDescriptionSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsSendingJRTimestamps").ToLocalChecked(), SupportsSendingJRTimestampsGetter, SupportsSendingJRTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsReceivingJRTimestamps").ToLocalChecked(), SupportsReceivingJRTimestampsGetter, SupportsReceivingJRTimestampsSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi2ProtocolMessages").ToLocalChecked(), SupportsMidi2ProtocolMessagesGetter, SupportsMidi2ProtocolMessagesSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("supportsMidi1ProtocolMessages").ToLocalChecked(), SupportsMidi1ProtocolMessagesGetter, SupportsMidi1ProtocolMessagesSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointProductInstanceId").ToLocalChecked(), EndpointProductInstanceIdGetter, EndpointProductInstanceIdSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("endpointName").ToLocalChecked(), EndpointNameGetter, EndpointNameSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyMsb").ToLocalChecked(), DeviceFamilyMsbGetter, DeviceFamilyMsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyModelMsb").ToLocalChecked(), DeviceFamilyModelMsbGetter, DeviceFamilyModelMsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyModelLsb").ToLocalChecked(), DeviceFamilyModelLsbGetter, DeviceFamilyModelLsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceFamilyLsb").ToLocalChecked(), DeviceFamilyLsbGetter, DeviceFamilyLsbSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("areFunctionBlocksStatic").ToLocalChecked(), AreFunctionBlocksStaticGetter, AreFunctionBlocksStaticSetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("deviceManufacturerSystemExclusiveId").ToLocalChecked(), DeviceManufacturerSystemExclusiveIdGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("functionBlocks").ToLocalChecked(), FunctionBlocksGetter); + Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("softwareRevisionLevel").ToLocalChecked(), SoftwareRevisionLevelGetter); + + Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); + Nan::SetMethod(constructor, "castFrom", CastFrom); + + + + Nan::Set(exports, Nan::New("MidiVirtualEndpointDeviceDefinition").ToLocalChecked(), constructor); + } + + virtual ::Platform::Object^ GetObjectInstance() const override { + return _instance; + } + + private: + + MidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ instance) { + _instance = instance; + } + + + static void New(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + + Local localRef = Nan::New(s_constructorTemplate); + + // in case the constructor was called without the new operator + if (!localRef->HasInstance(info.This())) { + if (info.Length() > 0) { + std::unique_ptr []> constructorArgs(new Local[info.Length()]); + + Local *argsPtr = constructorArgs.get(); + for (int i = 0; i < info.Length(); i++) { + argsPtr[i] = info[i]; + } + + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } else { + MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); + + if (res.IsEmpty()) { + return; + } + + info.GetReturnValue().Set(res.ToLocalChecked()); + return; + } + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ winRtInstance; + + + if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && + NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info[0])) { + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else if (info.Length() == 0) + { + try { + winRtInstance = ref new ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition(); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + else { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); + return; + } + + NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); + + MidiVirtualEndpointDeviceDefinition *wrapperInstance = new MidiVirtualEndpointDeviceDefinition(winRtInstance); + wrapperInstance->Wrap(info.This()); + + info.GetReturnValue().Set(info.This()); + } + + + + static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { + HandleScope scope; + if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info[0])) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); + return; + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ winRtInstance; + try { + winRtInstance = (::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^) NodeRT::Utils::GetObjectInstance(info[0]); + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + + info.GetReturnValue().Set(WrapMidiVirtualEndpointDeviceDefinition(winRtInstance)); + } + + + + + + static void TransportSuppliedDescriptionGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->TransportSuppliedDescription; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void TransportSuppliedDescriptionSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->TransportSuppliedDescription = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsSendingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsSendingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsSendingJRTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsSendingJRTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsReceivingJRTimestampsGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsReceivingJRTimestamps; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsReceivingJRTimestampsSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsReceivingJRTimestamps = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsMidi2ProtocolMessagesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi2ProtocolMessages; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi2ProtocolMessagesSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsMidi2ProtocolMessages = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void SupportsMidi1ProtocolMessagesGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->SupportsMidi1ProtocolMessages; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SupportsMidi1ProtocolMessagesSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->SupportsMidi1ProtocolMessages = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void EndpointProductInstanceIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointProductInstanceId; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointProductInstanceIdSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->EndpointProductInstanceId = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void EndpointNameGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + Platform::String^ result = wrapper->_instance->EndpointName; + info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data())); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void EndpointNameSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsString()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value))); + + wrapper->_instance->EndpointName = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyMsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyMsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyModelMsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyModelMsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyModelMsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyModelMsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyModelLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyModelLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyModelLsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyModelLsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceFamilyLsbGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + unsigned char result = wrapper->_instance->DeviceFamilyLsb; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void DeviceFamilyLsbSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsInt32()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + unsigned char winRtValue = static_cast(Nan::To(value).FromMaybe(0)); + + wrapper->_instance->DeviceFamilyLsb = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void AreFunctionBlocksStaticGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + bool result = wrapper->_instance->AreFunctionBlocksStatic; + info.GetReturnValue().Set(Nan::New(result)); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void AreFunctionBlocksStaticSetter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!value->IsBoolean()) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); + return; + } + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + + bool winRtValue = Nan::To(value).FromMaybe(false); + + wrapper->_instance->AreFunctionBlocksStatic = winRtValue; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + } + } + + static void DeviceManufacturerSystemExclusiveIdGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector^ result = wrapper->_instance->DeviceManufacturerSystemExclusiveId; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void FunctionBlocksGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector<::Windows::Devices::Midi2::MidiFunctionBlock^>^ result = wrapper->_instance->FunctionBlocks; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::Devices::Midi2::MidiFunctionBlock^>::CreateVectorWrapper(result, + [](::Windows::Devices::Midi2::MidiFunctionBlock^ val) -> Local { + return WrapMidiFunctionBlock(val); + }, + [](Local value) -> bool { + return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiFunctionBlock^>(value); + }, + [](Local value) -> ::Windows::Devices::Midi2::MidiFunctionBlock^ { + return UnwrapMidiFunctionBlock(value); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + static void SoftwareRevisionLevelGetter(Local property, const Nan::PropertyCallbackInfo &info) { + HandleScope scope; + + if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^>(info.This())) { + return; + } + + MidiVirtualEndpointDeviceDefinition *wrapper = MidiVirtualEndpointDeviceDefinition::Unwrap(info.This()); + + try { + ::Windows::Foundation::Collections::IVector^ result = wrapper->_instance->SoftwareRevisionLevel; + info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper::CreateVectorWrapper(result, + [](unsigned char val) -> Local { + return Nan::New(val); + }, + [](Local value) -> bool { + return value->IsInt32(); + }, + [](Local value) -> unsigned char { + return static_cast(Nan::To(value).FromMaybe(0)); + } + )); + return; + } catch (Platform::Exception ^exception) { + NodeRT::Utils::ThrowWinRtExceptionInJs(exception); + return; + } + } + + + + private: + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ _instance; + static Persistent s_constructorTemplate; + + friend v8::Local WrapMidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ wintRtInstance); + friend ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ UnwrapMidiVirtualEndpointDeviceDefinition(Local value); + }; + + Persistent MidiVirtualEndpointDeviceDefinition::s_constructorTemplate; + + v8::Local WrapMidiVirtualEndpointDeviceDefinition(::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ winRtInstance) { + EscapableHandleScope scope; + + if (winRtInstance == nullptr) { + return scope.Escape(Undefined()); + } + + Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); + Local args[] = {opaqueWrapper}; + Local localRef = Nan::New(MidiVirtualEndpointDeviceDefinition::s_constructorTemplate); + return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); + } + + ::Windows::Devices::Midi2::MidiVirtualEndpointDeviceDefinition^ UnwrapMidiVirtualEndpointDeviceDefinition(Local value) { + return MidiVirtualEndpointDeviceDefinition::Unwrap(Nan::To(value).ToLocalChecked())->_instance; + } + + void InitMidiVirtualEndpointDeviceDefinition(Local exports) { + MidiVirtualEndpointDeviceDefinition::Init(exports); + } + + +} } } } + +NAN_MODULE_INIT(init) { + // We ignore failures for now since it probably means that + // the initialization already happened for STA, and that's cool + + CoInitializeEx(nullptr, COINIT_MULTITHREADED); + + /* + if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) { + Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"error in CoInitializeEx()"))); + return; + } + */ + + NodeRT::Windows::Devices::Midi2::InitMidi1ChannelVoiceMessageStatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidi2ChannelVoiceMessageStatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationFiltersEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationSortOrderEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDevicePurposeEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDiscoveryRequestsEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointNativeDataFormatEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockDirectionEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockDiscoveryRequestsEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockMidi10Enum(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlockUIHintEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupTerminalBlockDirectionEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupTerminalBlockProtocolEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageTypeEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiPacketTypeEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiProtocolEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiSendMessageResultsEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceConfigurationResponseStatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitMidiSystemExclusive8StatusEnum(target); + NodeRT::Windows::Devices::Midi2::InitIMidiEndpointConnectionSettings(target); + NodeRT::Windows::Devices::Midi2::InitIMidiEndpointConnectionSource(target); + NodeRT::Windows::Devices::Midi2::InitIMidiEndpointMessageProcessingPlugin(target); + NodeRT::Windows::Devices::Midi2::InitIMidiMessageReceivedEventSource(target); + NodeRT::Windows::Devices::Midi2::InitIMidiServiceMessageProcessingPluginConfiguration(target); + NodeRT::Windows::Devices::Midi2::InitIMidiServiceTransportPluginConfiguration(target); + NodeRT::Windows::Devices::Midi2::InitIMidiUniversalPacket(target); + NodeRT::Windows::Devices::Midi2::InitMidiChannel(target); + NodeRT::Windows::Devices::Midi2::InitMidiChannelEndpointListener(target); + NodeRT::Windows::Devices::Midi2::InitMidiClock(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointConnection(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformation(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationAddedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationRemovedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceInformationUpdatedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiEndpointDeviceWatcher(target); + NodeRT::Windows::Devices::Midi2::InitMidiFunctionBlock(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroup(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupEndpointListener(target); + NodeRT::Windows::Devices::Midi2::InitMidiGroupTerminalBlock(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage128(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage32(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage64(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessage96(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageBuilder(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageConverter(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageReceivedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageTypeEndpointListener(target); + NodeRT::Windows::Devices::Midi2::InitMidiMessageUtility(target); + NodeRT::Windows::Devices::Midi2::InitMidiService(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceConfigurationResponse(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceLoopbackEndpointCreationResult(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceLoopbackEndpointDefinition(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceMessageProcessingPluginInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiServicePingResponse(target); + NodeRT::Windows::Devices::Midi2::InitMidiServicePingResponseSummary(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceSessionConnectionInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceSessionInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiServiceTransportPluginInfo(target); + NodeRT::Windows::Devices::Midi2::InitMidiSession(target); + NodeRT::Windows::Devices::Midi2::InitMidiSessionSettings(target); + NodeRT::Windows::Devices::Midi2::InitMidiStreamConfigurationRequestReceivedEventArgs(target); + NodeRT::Windows::Devices::Midi2::InitMidiStreamConfigurationRequestedSettings(target); + NodeRT::Windows::Devices::Midi2::InitMidiStreamMessageBuilder(target); + NodeRT::Windows::Devices::Midi2::InitMidiUniqueId(target); + NodeRT::Windows::Devices::Midi2::InitMidiVirtualEndpointDevice(target); + NodeRT::Windows::Devices::Midi2::InitMidiVirtualEndpointDeviceDefinition(target); + + + NodeRT::Utils::RegisterNameSpace("Windows.Devices.Midi2", target); +} + + + +NODE_MODULE(binding, init) diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/binding.gyp b/build/electron-projection/projection3_backup/windows.devices.midi2/binding.gyp new file mode 100644 index 000000000..6a1df7646 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/binding.gyp @@ -0,0 +1,82 @@ +{ + "variables": { + "WIN_VER": "v10", + "USE_ADDITIONAL_WINMD": "true" + }, + "includes": ["common.gypi"], + "targets": [{ + "target_name": "binding", + "sources": [], + "include_dirs": [ + " + + + + Debug + x64 + + + Release + x64 + + + + {34BB8FF6-AEB9-6A36-29FA-2760D66F05C8} + Win32Proj + binding + true + x64 + 10.0.22621.0 + + + + DynamicLibrary + + + v143 + + + + + + + + + + $(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\ + true + $(Configuration)\obj\$(ProjectName)\ + false + true + $(SolutionDir)$(Configuration)\ + .node + .node + .node + .node + $(ProjectName) + $(OutDir)\$(ProjectName).node + + + + C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\include\node;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\src;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\config;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\openssl\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\uv\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\zlib;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + /Zc:__cplusplus -std:c++17 /ZW %(AdditionalOptions) + %ProgramFiles(x86)%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/10.0.20348.0;$(VCToolsInstallDir)/lib/x86/store/references;%MIDI_REPO_ROOT%/build/release/api/;%ProgramFiles%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles%/Windows Kits/10/Include/x64/um;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles(x86)%/Windows Kits/10/Include/x64/um + EnableFastChecks + true + OldStyle + 4609;4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings) + Sync + false + true + false + Disabled + NotUsing + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + true + true + false + Level3 + true + + + /LTCG:INCREMENTAL %(AdditionalOptions) + + + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\peteb\\AppData\\Local\\node-gyp\\Cache\\21.1.0\\x64\\node.lib";runtimeobject.lib + /LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions) + node.exe;%(DelayLoadDLLs) + true + true + true + $(OutDir)$(ProjectName).node + true + .node + MachineX64 + + + C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\include\node;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\src;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\config;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\openssl\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\uv\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\zlib;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;V8_ENABLE_CHECKS;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\include\node;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\src;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\config;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\openssl\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\uv\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\zlib;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + /Zc:__cplusplus -std:c++17 /ZW %(AdditionalOptions) + %ProgramFiles(x86)%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles%/Microsoft Visual Studio 14.0/VC/lib/store/references;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/10.0.20348.0;$(VCToolsInstallDir)/lib/x86/store/references;%MIDI_REPO_ROOT%/build/release/api/;%ProgramFiles%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles%/Windows Kits/10/Include/x64/um;%ProgramFiles(x86)%/Windows Kits/10/UnionMetadata/x64;%ProgramFiles(x86)%/Windows Kits/10/Include/x64/um + true + OldStyle + 4609;4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings) + Sync + Speed + true + AnySuitable + true + true + true + Full + NotUsing + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions) + MultiThreadedDLL + false + true + true + false + Level3 + true + + + /LTCG:INCREMENTAL %(AdditionalOptions) + + + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\peteb\\AppData\\Local\\node-gyp\\Cache\\21.1.0\\x64\\node.lib";runtimeobject.lib + /LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions) + node.exe;%(DelayLoadDLLs) + true + true + true + $(OutDir)$(ProjectName).node + true + .node + MachineX64 + + + C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\include\node;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\src;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\config;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\openssl\openssl\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\uv\include;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\zlib;C:\Users\peteb\AppData\Local\node-gyp\Cache\21.1.0\deps\v8\include;..\node_modules\nan;%(AdditionalIncludeDirectories) + NODE_GYP_MODULE_NAME=binding;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;V8_DEPRECATION_WARNINGS;V8_IMMINENT_DEPRECATION_WARNINGS;_GLIBCXX_USE_CXX11_ABI=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + + + + $(IntDir)\_nodert_generated.obj + + + $(IntDir)\NodeRtUtils.obj + + + $(IntDir)\OpaqueWrapper.obj + + + $(IntDir)\CollectionsConverterUtils.obj + + + + + + + diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/build/binding.vcxproj.filters b/build/electron-projection/projection3_backup/windows.devices.midi2/build/binding.vcxproj.filters new file mode 100644 index 000000000..6e089d448 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/build/binding.vcxproj.filters @@ -0,0 +1,67 @@ + + + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + {7B735499-E5DD-1C2B-6C26-70023832A1CF} + + + {E9F714C1-DA89-54E2-60CF-39FEB20BF756} + + + {93C774D4-5E46-33D7-FB89-AC2082D09F63} + + + {F852EB63-437C-846A-220F-8D9ED6DAEC1D} + + + {D51E5808-912B-5C70-4BB7-475D1DBFA067} + + + {741E0E76-39B2-B1AB-9FA1-F1A20B16F295} + + + {56DF7A98-063D-FB9D-485C-089023B4C16A} + + + {77348C0E-2034-7791-74D5-63C077DF5A3B} + + + {8CDEE807-BC53-E450-C8B8-4DEBB66742D4} + + + {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} + + + + + .. + + + .. + + + .. + + + .. + + + C:\Users\peteb\AppData\Roaming\npm\node_modules\node-gyp\src + + + .. + + + diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/build/config.gypi b/build/electron-projection/projection3_backup/windows.devices.midi2/build/config.gypi new file mode 100644 index 000000000..1090c7eaf --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/build/config.gypi @@ -0,0 +1,420 @@ +# Do not edit. File was generated by node-gyp's "configure" step +{ + "target_defaults": { + "cflags": [], + "default_configuration": "Release", + "defines": [], + "include_dirs": [], + "libraries": [], + "msbuild_toolset": "v143", + "msvs_windows_target_platform_version": "10.0.22621.0" + }, + "variables": { + "asan": 0, + "coverage": "false", + "dcheck_always_on": 0, + "debug_nghttp2": "false", + "debug_node": "false", + "enable_lto": "false", + "enable_pgo_generate": "false", + "enable_pgo_use": "false", + "error_on_warn": "false", + "force_dynamic_crt": 0, + "host_arch": "x64", + "icu_data_in": "..\\..\\deps\\icu-tmp\\icudt73l.dat", + "icu_endianness": "l", + "icu_gyp_path": "tools/icu/icu-generic.gyp", + "icu_path": "deps/icu-small", + "icu_small": "false", + "icu_ver_major": "73", + "is_debug": 0, + "libdir": "lib", + "llvm_version": "0.0", + "napi_build_version": "9", + "nasm_version": "2.16", + "node_builtin_shareable_builtins": [ + "deps/cjs-module-lexer/lexer.js", + "deps/cjs-module-lexer/dist/lexer.js", + "deps/undici/undici.js" + ], + "node_byteorder": "little", + "node_debug_lib": "false", + "node_enable_d8": "false", + "node_enable_v8_vtunejit": "false", + "node_fipsinstall": "false", + "node_install_corepack": "true", + "node_install_npm": "true", + "node_library_files": [ + "lib/_http_agent.js", + "lib/_http_client.js", + "lib/_http_common.js", + "lib/_http_incoming.js", + "lib/_http_outgoing.js", + "lib/_http_server.js", + "lib/_stream_duplex.js", + "lib/_stream_passthrough.js", + "lib/_stream_readable.js", + "lib/_stream_transform.js", + "lib/_stream_wrap.js", + "lib/_stream_writable.js", + "lib/_tls_common.js", + "lib/_tls_wrap.js", + "lib/assert.js", + "lib/assert/strict.js", + "lib/async_hooks.js", + "lib/buffer.js", + "lib/child_process.js", + "lib/cluster.js", + "lib/console.js", + "lib/constants.js", + "lib/crypto.js", + "lib/dgram.js", + "lib/diagnostics_channel.js", + "lib/dns.js", + "lib/dns/promises.js", + "lib/domain.js", + "lib/events.js", + "lib/fs.js", + "lib/fs/promises.js", + "lib/http.js", + "lib/http2.js", + "lib/https.js", + "lib/inspector.js", + "lib/inspector/promises.js", + "lib/internal/abort_controller.js", + "lib/internal/assert.js", + "lib/internal/assert/assertion_error.js", + "lib/internal/assert/calltracker.js", + "lib/internal/async_hooks.js", + "lib/internal/blob.js", + "lib/internal/blocklist.js", + "lib/internal/bootstrap/node.js", + "lib/internal/bootstrap/realm.js", + "lib/internal/bootstrap/switches/does_not_own_process_state.js", + "lib/internal/bootstrap/switches/does_own_process_state.js", + "lib/internal/bootstrap/switches/is_main_thread.js", + "lib/internal/bootstrap/switches/is_not_main_thread.js", + "lib/internal/bootstrap/web/exposed-wildcard.js", + "lib/internal/bootstrap/web/exposed-window-or-worker.js", + "lib/internal/buffer.js", + "lib/internal/child_process.js", + "lib/internal/child_process/serialization.js", + "lib/internal/cli_table.js", + "lib/internal/cluster/child.js", + "lib/internal/cluster/primary.js", + "lib/internal/cluster/round_robin_handle.js", + "lib/internal/cluster/shared_handle.js", + "lib/internal/cluster/utils.js", + "lib/internal/cluster/worker.js", + "lib/internal/console/constructor.js", + "lib/internal/console/global.js", + "lib/internal/constants.js", + "lib/internal/crypto/aes.js", + "lib/internal/crypto/certificate.js", + "lib/internal/crypto/cfrg.js", + "lib/internal/crypto/cipher.js", + "lib/internal/crypto/diffiehellman.js", + "lib/internal/crypto/ec.js", + "lib/internal/crypto/hash.js", + "lib/internal/crypto/hashnames.js", + "lib/internal/crypto/hkdf.js", + "lib/internal/crypto/keygen.js", + "lib/internal/crypto/keys.js", + "lib/internal/crypto/mac.js", + "lib/internal/crypto/pbkdf2.js", + "lib/internal/crypto/random.js", + "lib/internal/crypto/rsa.js", + "lib/internal/crypto/scrypt.js", + "lib/internal/crypto/sig.js", + "lib/internal/crypto/util.js", + "lib/internal/crypto/webcrypto.js", + "lib/internal/crypto/webidl.js", + "lib/internal/crypto/x509.js", + "lib/internal/debugger/inspect.js", + "lib/internal/debugger/inspect_client.js", + "lib/internal/debugger/inspect_repl.js", + "lib/internal/dgram.js", + "lib/internal/dns/callback_resolver.js", + "lib/internal/dns/promises.js", + "lib/internal/dns/utils.js", + "lib/internal/encoding.js", + "lib/internal/error_serdes.js", + "lib/internal/errors.js", + "lib/internal/event_target.js", + "lib/internal/events/symbols.js", + "lib/internal/file.js", + "lib/internal/fixed_queue.js", + "lib/internal/freelist.js", + "lib/internal/freeze_intrinsics.js", + "lib/internal/fs/cp/cp-sync.js", + "lib/internal/fs/cp/cp.js", + "lib/internal/fs/dir.js", + "lib/internal/fs/glob.js", + "lib/internal/fs/promises.js", + "lib/internal/fs/read/context.js", + "lib/internal/fs/recursive_watch.js", + "lib/internal/fs/rimraf.js", + "lib/internal/fs/streams.js", + "lib/internal/fs/sync_write_stream.js", + "lib/internal/fs/utils.js", + "lib/internal/fs/watchers.js", + "lib/internal/heap_utils.js", + "lib/internal/histogram.js", + "lib/internal/http.js", + "lib/internal/http2/compat.js", + "lib/internal/http2/core.js", + "lib/internal/http2/util.js", + "lib/internal/idna.js", + "lib/internal/inspector_async_hook.js", + "lib/internal/js_stream_socket.js", + "lib/internal/legacy/processbinding.js", + "lib/internal/linkedlist.js", + "lib/internal/main/check_syntax.js", + "lib/internal/main/embedding.js", + "lib/internal/main/eval_stdin.js", + "lib/internal/main/eval_string.js", + "lib/internal/main/inspect.js", + "lib/internal/main/mksnapshot.js", + "lib/internal/main/print_help.js", + "lib/internal/main/prof_process.js", + "lib/internal/main/repl.js", + "lib/internal/main/run_main_module.js", + "lib/internal/main/test_runner.js", + "lib/internal/main/watch_mode.js", + "lib/internal/main/worker_thread.js", + "lib/internal/mime.js", + "lib/internal/modules/cjs/loader.js", + "lib/internal/modules/esm/assert.js", + "lib/internal/modules/esm/create_dynamic_module.js", + "lib/internal/modules/esm/fetch_module.js", + "lib/internal/modules/esm/formats.js", + "lib/internal/modules/esm/get_format.js", + "lib/internal/modules/esm/handle_process_exit.js", + "lib/internal/modules/esm/hooks.js", + "lib/internal/modules/esm/initialize_import_meta.js", + "lib/internal/modules/esm/load.js", + "lib/internal/modules/esm/loader.js", + "lib/internal/modules/esm/module_job.js", + "lib/internal/modules/esm/module_map.js", + "lib/internal/modules/esm/package_config.js", + "lib/internal/modules/esm/resolve.js", + "lib/internal/modules/esm/shared_constants.js", + "lib/internal/modules/esm/translators.js", + "lib/internal/modules/esm/utils.js", + "lib/internal/modules/esm/worker.js", + "lib/internal/modules/helpers.js", + "lib/internal/modules/package_json_reader.js", + "lib/internal/modules/run_main.js", + "lib/internal/navigator.js", + "lib/internal/net.js", + "lib/internal/options.js", + "lib/internal/per_context/domexception.js", + "lib/internal/per_context/messageport.js", + "lib/internal/per_context/primordials.js", + "lib/internal/perf/event_loop_delay.js", + "lib/internal/perf/event_loop_utilization.js", + "lib/internal/perf/nodetiming.js", + "lib/internal/perf/observe.js", + "lib/internal/perf/performance.js", + "lib/internal/perf/performance_entry.js", + "lib/internal/perf/resource_timing.js", + "lib/internal/perf/timerify.js", + "lib/internal/perf/usertiming.js", + "lib/internal/perf/utils.js", + "lib/internal/policy/manifest.js", + "lib/internal/policy/sri.js", + "lib/internal/priority_queue.js", + "lib/internal/process/esm_loader.js", + "lib/internal/process/execution.js", + "lib/internal/process/per_thread.js", + "lib/internal/process/permission.js", + "lib/internal/process/policy.js", + "lib/internal/process/pre_execution.js", + "lib/internal/process/promises.js", + "lib/internal/process/report.js", + "lib/internal/process/signal.js", + "lib/internal/process/task_queues.js", + "lib/internal/process/warning.js", + "lib/internal/process/worker_thread_only.js", + "lib/internal/promise_hooks.js", + "lib/internal/querystring.js", + "lib/internal/readline/callbacks.js", + "lib/internal/readline/emitKeypressEvents.js", + "lib/internal/readline/interface.js", + "lib/internal/readline/promises.js", + "lib/internal/readline/utils.js", + "lib/internal/repl.js", + "lib/internal/repl/await.js", + "lib/internal/repl/history.js", + "lib/internal/repl/utils.js", + "lib/internal/socket_list.js", + "lib/internal/socketaddress.js", + "lib/internal/source_map/prepare_stack_trace.js", + "lib/internal/source_map/source_map.js", + "lib/internal/source_map/source_map_cache.js", + "lib/internal/stream_base_commons.js", + "lib/internal/streams/add-abort-signal.js", + "lib/internal/streams/buffer_list.js", + "lib/internal/streams/compose.js", + "lib/internal/streams/destroy.js", + "lib/internal/streams/duplex.js", + "lib/internal/streams/duplexify.js", + "lib/internal/streams/end-of-stream.js", + "lib/internal/streams/from.js", + "lib/internal/streams/lazy_transform.js", + "lib/internal/streams/legacy.js", + "lib/internal/streams/operators.js", + "lib/internal/streams/passthrough.js", + "lib/internal/streams/pipeline.js", + "lib/internal/streams/readable.js", + "lib/internal/streams/state.js", + "lib/internal/streams/transform.js", + "lib/internal/streams/utils.js", + "lib/internal/streams/writable.js", + "lib/internal/structured_clone.js", + "lib/internal/test/binding.js", + "lib/internal/test/transfer.js", + "lib/internal/test_runner/coverage.js", + "lib/internal/test_runner/harness.js", + "lib/internal/test_runner/mock/mock.js", + "lib/internal/test_runner/mock/mock_timers.js", + "lib/internal/test_runner/reporter/dot.js", + "lib/internal/test_runner/reporter/junit.js", + "lib/internal/test_runner/reporter/spec.js", + "lib/internal/test_runner/reporter/tap.js", + "lib/internal/test_runner/reporter/v8-serializer.js", + "lib/internal/test_runner/runner.js", + "lib/internal/test_runner/test.js", + "lib/internal/test_runner/tests_stream.js", + "lib/internal/test_runner/utils.js", + "lib/internal/timers.js", + "lib/internal/tls/secure-context.js", + "lib/internal/tls/secure-pair.js", + "lib/internal/trace_events_async_hooks.js", + "lib/internal/tty.js", + "lib/internal/url.js", + "lib/internal/util.js", + "lib/internal/util/colors.js", + "lib/internal/util/comparisons.js", + "lib/internal/util/debuglog.js", + "lib/internal/util/embedding.js", + "lib/internal/util/inspect.js", + "lib/internal/util/inspector.js", + "lib/internal/util/iterable_weak_map.js", + "lib/internal/util/parse_args/parse_args.js", + "lib/internal/util/parse_args/utils.js", + "lib/internal/util/types.js", + "lib/internal/v8/startup_snapshot.js", + "lib/internal/v8_prof_polyfill.js", + "lib/internal/v8_prof_processor.js", + "lib/internal/validators.js", + "lib/internal/vm.js", + "lib/internal/vm/module.js", + "lib/internal/wasm_web_api.js", + "lib/internal/watch_mode/files_watcher.js", + "lib/internal/watchdog.js", + "lib/internal/webidl.js", + "lib/internal/webstreams/adapters.js", + "lib/internal/webstreams/compression.js", + "lib/internal/webstreams/encoding.js", + "lib/internal/webstreams/queuingstrategies.js", + "lib/internal/webstreams/readablestream.js", + "lib/internal/webstreams/transfer.js", + "lib/internal/webstreams/transformstream.js", + "lib/internal/webstreams/util.js", + "lib/internal/webstreams/writablestream.js", + "lib/internal/worker.js", + "lib/internal/worker/io.js", + "lib/internal/worker/js_transferable.js", + "lib/module.js", + "lib/net.js", + "lib/os.js", + "lib/path.js", + "lib/path/posix.js", + "lib/path/win32.js", + "lib/perf_hooks.js", + "lib/process.js", + "lib/punycode.js", + "lib/querystring.js", + "lib/readline.js", + "lib/readline/promises.js", + "lib/repl.js", + "lib/stream.js", + "lib/stream/consumers.js", + "lib/stream/promises.js", + "lib/stream/web.js", + "lib/string_decoder.js", + "lib/sys.js", + "lib/test.js", + "lib/test/reporters.js", + "lib/timers.js", + "lib/timers/promises.js", + "lib/tls.js", + "lib/trace_events.js", + "lib/tty.js", + "lib/url.js", + "lib/util.js", + "lib/util/types.js", + "lib/v8.js", + "lib/vm.js", + "lib/wasi.js", + "lib/worker_threads.js", + "lib/zlib.js" + ], + "node_module_version": 120, + "node_no_browser_globals": "false", + "node_prefix": "\\usr\\local", + "node_release_urlbase": "https://nodejs.org/download/release/", + "node_shared": "false", + "node_shared_brotli": "false", + "node_shared_cares": "false", + "node_shared_http_parser": "false", + "node_shared_libuv": "false", + "node_shared_nghttp2": "false", + "node_shared_nghttp3": "false", + "node_shared_ngtcp2": "false", + "node_shared_openssl": "false", + "node_shared_zlib": "false", + "node_tag": "", + "node_target_type": "executable", + "node_use_bundled_v8": "true", + "node_use_node_code_cache": "true", + "node_use_node_snapshot": "true", + "node_use_openssl": "true", + "node_use_v8_platform": "true", + "node_with_ltcg": "true", + "node_without_node_options": "false", + "node_write_snapshot_as_array_literals": "true", + "openssl_is_fips": "false", + "openssl_quic": "true", + "ossfuzz": "false", + "shlib_suffix": "so.120", + "single_executable_application": "true", + "target_arch": "x64", + "v8_enable_31bit_smis_on_64bit_arch": 0, + "v8_enable_extensible_ro_snapshot": 0, + "v8_enable_gdbjit": 0, + "v8_enable_hugepage": 0, + "v8_enable_i18n_support": 1, + "v8_enable_inspector": 1, + "v8_enable_javascript_promise_hooks": 1, + "v8_enable_lite_mode": 0, + "v8_enable_object_print": 1, + "v8_enable_pointer_compression": 0, + "v8_enable_shared_ro_heap": 1, + "v8_enable_short_builtin_calls": 1, + "v8_enable_webassembly": 1, + "v8_no_strict_aliasing": 1, + "v8_optimized_debug": 1, + "v8_promise_internal_field_count": 1, + "v8_random_seed": 0, + "v8_trace_maps": 0, + "v8_use_siphash": 1, + "want_separate_host_toolset": 0, + "nodedir": "C:\\Users\\peteb\\AppData\\Local\\node-gyp\\Cache\\21.1.0", + "python": "C:\\Users\\peteb\\AppData\\Local\\Programs\\Python\\Python39\\python.exe", + "standalone_static_library": 1, + "msbuild_path": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\MSBuild\\Current\\Bin\\MSBuild.exe", + "msvs_version": "2022" + } +} diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/build/platform.winmd b/build/electron-projection/projection3_backup/windows.devices.midi2/build/platform.winmd new file mode 100644 index 000000000..dd9c3b4df Binary files /dev/null and b/build/electron-projection/projection3_backup/windows.devices.midi2/build/platform.winmd differ diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/common.gypi b/build/electron-projection/projection3_backup/windows.devices.midi2/common.gypi new file mode 100644 index 000000000..ef272e94f --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/common.gypi @@ -0,0 +1,26 @@ +{ + 'variables' : { + 'node_shared': 'true' + }, + 'target_defaults': { + 'default_configuration': 'Release', + 'configurations': { + 'Debug': { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'ExceptionHandling': 1, # /EHsc, + 'RuntimeLibrary': '3', # /MDd + } + } + }, + 'Release': { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'ExceptionHandling': 1, # /EHsc, + 'RuntimeLibrary': '2', # /MD + } + } + } + } + } +} \ No newline at end of file diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.js b/build/electron-projection/projection3_backup/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.js new file mode 100644 index 000000000..d888195b8 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.js @@ -0,0 +1,3030 @@ + +MidiMessageStruct = (function () { + var cls = function MidiMessageStruct() { + this.word0 = new Number(); + this.word1 = new Number(); + this.word2 = new Number(); + this.word3 = new Number(); + }; + return cls; +}) (); +exports.MidiMessageStruct = MidiMessageStruct; + + +_Midi1ChannelVoiceMessageStatus = function () { + this.noteOff = 0; + this.noteOn = 1; + this.polyPressure = 2; + this.controlChange = 3; + this.programChange = 4; + this.channelPressure = 5; + this.pitchBend = 6; +} +exports.Midi1ChannelVoiceMessageStatus = new _Midi1ChannelVoiceMessageStatus(); + +_Midi2ChannelVoiceMessageStatus = function () { + this.registeredPerNoteController = 0; + this.assignablePerNoteController = 1; + this.registeredController = 2; + this.assignableController = 3; + this.relativeRegisteredController = 4; + this.relativeAssignableController = 5; + this.perNotePitchBend = 6; + this.noteOff = 7; + this.noteOn = 8; + this.polyPressure = 9; + this.controlChange = 10; + this.programChange = 11; + this.channelPressure = 12; + this.pitchBend = 13; + this.perNoteManagement = 14; +} +exports.Midi2ChannelVoiceMessageStatus = new _Midi2ChannelVoiceMessageStatus(); + +_MidiEndpointDeviceInformationFilters = function () { + this.includeClientUmpNative = 0; + this.includeClientByteStreamNative = 1; + this.includeVirtualDeviceResponder = 2; + this.includeDiagnosticLoopback = 3; + this.includeDiagnosticPing = 4; + this.allTypicalEndpoints = 5; +} +exports.MidiEndpointDeviceInformationFilters = new _MidiEndpointDeviceInformationFilters(); + +_MidiEndpointDeviceInformationSortOrder = function () { + this.none = 0; + this.name = 1; + this.endpointDeviceId = 2; + this.deviceInstanceId = 3; + this.containerThenName = 4; + this.containerThenEndpointDeviceId = 5; + this.containerThenDeviceInstanceId = 6; + this.transportMnemonicThenName = 7; + this.transportMnemonicThenEndpointDeviceId = 8; + this.transportMnemonicThenDeviceInstanceId = 9; +} +exports.MidiEndpointDeviceInformationSortOrder = new _MidiEndpointDeviceInformationSortOrder(); + +_MidiEndpointDevicePurpose = function () { + this.normalMessageEndpoint = 0; + this.virtualDeviceResponder = 1; + this.inBoxGeneralMidiSynth = 2; + this.diagnosticLoopback = 3; + this.diagnosticPing = 4; +} +exports.MidiEndpointDevicePurpose = new _MidiEndpointDevicePurpose(); + +_MidiEndpointDiscoveryRequests = function () { + this.none = 0; + this.requestEndpointInfo = 1; + this.requestDeviceIdentity = 2; + this.requestEndpointName = 3; + this.requestProductInstanceId = 4; + this.requestStreamConfiguration = 5; +} +exports.MidiEndpointDiscoveryRequests = new _MidiEndpointDiscoveryRequests(); + +_MidiEndpointNativeDataFormat = function () { + this.unknown = 0; + this.byteStream = 1; + this.universalMidiPacket = 2; +} +exports.MidiEndpointNativeDataFormat = new _MidiEndpointNativeDataFormat(); + +_MidiFunctionBlockDirection = function () { + this.undefined = 0; + this.blockInput = 1; + this.blockOutput = 2; + this.bidirectional = 3; +} +exports.MidiFunctionBlockDirection = new _MidiFunctionBlockDirection(); + +_MidiFunctionBlockDiscoveryRequests = function () { + this.none = 0; + this.requestFunctionBlockInfo = 1; + this.requestFunctionBlockName = 2; +} +exports.MidiFunctionBlockDiscoveryRequests = new _MidiFunctionBlockDiscoveryRequests(); + +_MidiFunctionBlockMidi10 = function () { + this.not10 = 0; + this.yesBandwidthUnrestricted = 1; + this.yesBandwidthRestricted = 2; + this.reserved = 3; +} +exports.MidiFunctionBlockMidi10 = new _MidiFunctionBlockMidi10(); + +_MidiFunctionBlockUIHint = function () { + this.unknown = 0; + this.receiver = 1; + this.sender = 2; + this.bidirectional = 3; +} +exports.MidiFunctionBlockUIHint = new _MidiFunctionBlockUIHint(); + +_MidiGroupTerminalBlockDirection = function () { + this.bidirectional = 0; + this.blockInput = 1; + this.blockOutput = 2; +} +exports.MidiGroupTerminalBlockDirection = new _MidiGroupTerminalBlockDirection(); + +_MidiGroupTerminalBlockProtocol = function () { + this.unknown = 0; + this.midi1Message64 = 1; + this.midi1Message64WithJitterReduction = 2; + this.midi1Message128 = 3; + this.midi1Message128WithJitterReduction = 4; + this.midi2 = 5; + this.midi2WithJitterReduction = 6; +} +exports.MidiGroupTerminalBlockProtocol = new _MidiGroupTerminalBlockProtocol(); + +_MidiMessageType = function () { + this.utilityMessage32 = 0; + this.systemCommon32 = 1; + this.midi1ChannelVoice32 = 2; + this.dataMessage64 = 3; + this.midi2ChannelVoice64 = 4; + this.dataMessage128 = 5; + this.futureReserved632 = 6; + this.futureReserved732 = 7; + this.futureReserved864 = 8; + this.futureReserved964 = 9; + this.futureReservedA64 = 10; + this.futureReservedB96 = 11; + this.futureReservedC96 = 12; + this.flexData128 = 13; + this.futureReservedE128 = 14; + this.stream128 = 15; +} +exports.MidiMessageType = new _MidiMessageType(); + +_MidiPacketType = function () { + this.unknownOrInvalid = 0; + this.universalMidiPacket32 = 1; + this.universalMidiPacket64 = 2; + this.universalMidiPacket96 = 3; + this.universalMidiPacket128 = 4; +} +exports.MidiPacketType = new _MidiPacketType(); + +_MidiProtocol = function () { + this.default = 0; + this.midi1 = 1; + this.midi2 = 2; +} +exports.MidiProtocol = new _MidiProtocol(); + +_MidiSendMessageResults = function () { + this.succeeded = 0; + this.failed = 1; + this.bufferFull = 2; + this.endpointConnectionClosedOrInvalid = 3; + this.invalidMessageTypeForWordCount = 4; + this.invalidMessageOther = 5; + this.dataIndexOutOfRange = 6; + this.timestampOutOfRange = 7; + this.messageListPartiallyProcessed = 8; + this.other = 9; +} +exports.MidiSendMessageResults = new _MidiSendMessageResults(); + +_MidiServiceConfigurationResponseStatus = function () { + this.success = 0; + this.errorTargetNotFound = 1; + this.errorJsonNullOrEmpty = 2; + this.errorProcessingJson = 3; + this.errorNotImplemented = 4; + this.errorOther = 5; +} +exports.MidiServiceConfigurationResponseStatus = new _MidiServiceConfigurationResponseStatus(); + +_MidiSystemExclusive8Status = function () { + this.completeMessageInSingleMessagePacket = 0; + this.startMessagePacket = 1; + this.continueMessagePacket = 2; + this.endMessagePacket = 3; +} +exports.MidiSystemExclusive8Status = new _MidiSystemExclusive8Status(); + +IMidiEndpointConnectionSettings = (function () { + var cls = function IMidiEndpointConnectionSettings() { + this.settingsJson = new String(); + }; + + + return cls; +}) (); +exports.IMidiEndpointConnectionSettings = IMidiEndpointConnectionSettings; + +IMidiEndpointConnectionSource = (function () { + var cls = function IMidiEndpointConnectionSource() { + }; + + + return cls; +}) (); +exports.IMidiEndpointConnectionSource = IMidiEndpointConnectionSource; + +IMidiEndpointMessageProcessingPlugin = (function () { + var cls = function IMidiEndpointMessageProcessingPlugin() { + this.id = new String(); + this.isEnabled = new Boolean(); + this.name = new String(); + this.tag = new Object(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + return cls; +}) (); +exports.IMidiEndpointMessageProcessingPlugin = IMidiEndpointMessageProcessingPlugin; + +IMidiMessageReceivedEventSource = (function () { + var cls = function IMidiMessageReceivedEventSource() { + }; + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.IMidiMessageReceivedEventSource = IMidiMessageReceivedEventSource; + +IMidiServiceMessageProcessingPluginConfiguration = (function () { + var cls = function IMidiServiceMessageProcessingPluginConfiguration() { + this.endpointDeviceId = new String(); + this.isFromConfigurationFile = new Boolean(); + this.messageProcessingPluginId = new String(); + this.pluginInstanceId = new String(); + this.settingsJson = new Object(); + }; + + + return cls; +}) (); +exports.IMidiServiceMessageProcessingPluginConfiguration = IMidiServiceMessageProcessingPluginConfiguration; + +IMidiServiceTransportPluginConfiguration = (function () { + var cls = function IMidiServiceTransportPluginConfiguration() { + this.isFromConfigurationFile = new Boolean(); + this.settingsJson = new Object(); + this.transportId = new String(); + }; + + + return cls; +}) (); +exports.IMidiServiceTransportPluginConfiguration = IMidiServiceTransportPluginConfiguration; + +IMidiUniversalPacket = (function () { + var cls = function IMidiUniversalPacket() { + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + this.timestamp = new Number(); + }; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + return cls; +}) (); +exports.IMidiUniversalPacket = IMidiUniversalPacket; + +MidiChannel = (function () { + var cls = function MidiChannel() { + this.index = new Number(); + this.numberForDisplay = new Number(); + }; + +var cls = function MidiChannel(index) { + this.index = new Number(); + this.numberForDisplay = new Number(); +}; + + + cls.isValidChannelIndex = function isValidChannelIndex(index) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.labelFull = new String(); + cls.labelShort = new String(); + return cls; +}) (); +exports.MidiChannel = MidiChannel; + +MidiChannelEndpointListener = (function () { + var cls = function MidiChannelEndpointListener() { + this.preventFiringMainMessageReceivedEvent = new Boolean(); + this.preventCallingFurtherListeners = new Boolean(); + this.includeGroup = new MidiGroup(); + this.includeChannels = new Object(); + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiChannelEndpointListener = MidiChannelEndpointListener; + +MidiClock = (function () { + var cls = function MidiClock() { + }; + + + cls.convertTimestampToMicroseconds = function convertTimestampToMicroseconds(timestampValue) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.convertTimestampToMilliseconds = function convertTimestampToMilliseconds(timestampValue) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.convertTimestampToSeconds = function convertTimestampToSeconds(timestampValue) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampByTicks = function offsetTimestampByTicks(timestampValue, offsetTicks) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampByMicroseconds = function offsetTimestampByMicroseconds(timestampValue, offsetMicroseconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampByMilliseconds = function offsetTimestampByMilliseconds(timestampValue, offsetMilliseconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.offsetTimestampBySeconds = function offsetTimestampBySeconds(timestampValue, offsetSeconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.now = new Number(); + cls.timestampConstantSendImmediately = new Number(); + cls.timestampFrequency = new Number(); + return cls; +}) (); +exports.MidiClock = MidiClock; + +MidiEndpointConnection = (function () { + var cls = function MidiEndpointConnection() { + this.tag = new Object(); + this.connectionId = new String(); + this.endpointDeviceId = new String(); + this.isOpen = new Boolean(); + this.messageProcessingPlugins = new Object(); + this.settings = new IMidiEndpointConnectionSettings(); + }; + + + cls.prototype.open = function open() { + /// + /// Function summary. + /// + /// + return new Boolean(); + } + + + cls.prototype.addMessageProcessingPlugin = function addMessageProcessingPlugin(plugin) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.removeMessageProcessingPlugin = function removeMessageProcessingPlugin(id) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.sendSingleMessagePacket = function sendSingleMessagePacket(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageStruct = function sendSingleMessageStruct(timestamp, wordCount, message) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageWordArray = function sendSingleMessageWordArray(timestamp, startIndex, wordCount, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + +cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0, word1) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + +cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0, word1, word2) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + +cls.prototype.sendSingleMessageWords = function sendSingleMessageWords(timestamp, word0, word1, word2, word3) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendSingleMessageBuffer = function sendSingleMessageBuffer(timestamp, byteOffset, byteCount, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesWordList = function sendMultipleMessagesWordList(timestamp, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesWordArray = function sendMultipleMessagesWordArray(timestamp, startIndex, wordCount, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesPacketList = function sendMultipleMessagesPacketList(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesStructList = function sendMultipleMessagesStructList(timestamp, messages) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesStructArray = function sendMultipleMessagesStructArray(timestamp, startIndex, messageCount, messages) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.prototype.sendMultipleMessagesBuffer = function sendMultipleMessagesBuffer(timestamp, byteOffset, byteCount, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiSendMessageResults(); + } + + + cls.getDeviceSelector = function getDeviceSelector() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + cls.sendMessageSucceeded = function sendMessageSucceeded(sendResult) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.sendMessageFailed = function sendMessageFailed(sendResult) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiEndpointConnection = MidiEndpointConnection; + +MidiEndpointDeviceInformation = (function () { + var cls = function MidiEndpointDeviceInformation() { + this.configuredProtocol = new MidiProtocol(); + this.configuredToReceiveJRTimestamps = new Boolean(); + this.configuredToSendJRTimestamps = new Boolean(); + this.containerId = new String(); + this.deviceIdentityDeviceFamilyLsb = new Number(); + this.deviceIdentityDeviceFamilyModelNumberLsb = new Number(); + this.deviceIdentityDeviceFamilyModelNumberMsb = new Number(); + this.deviceIdentityDeviceFamilyMsb = new Number(); + this.deviceIdentityLastUpdateTime = new Date(); + this.deviceIdentitySoftwareRevisionLevel = new Array(); + this.deviceIdentitySystemExclusiveId = new Array(); + this.deviceInstanceId = new String(); + this.endpointConfigurationLastUpdateTime = new Date(); + this.endpointInformationLastUpdateTime = new Date(); + this.endpointPurpose = new MidiEndpointDevicePurpose(); + this.endpointSuppliedName = new String(); + this.endpointSuppliedNameLastUpdateTime = new Date(); + this.functionBlockCount = new Number(); + this.functionBlocks = new Object(); + this.functionBlocksLastUpdateTime = new Date(); + this.groupTerminalBlocks = new Object(); + this.hasStaticFunctionBlocks = new Boolean(); + this.id = new String(); + this.manufacturerName = new String(); + this.name = new String(); + this.nativeDataFormat = new MidiEndpointNativeDataFormat(); + this.productInstanceId = new String(); + this.productInstanceIdLastUpdateTime = new Date(); + this.properties = new Object(); + this.recommendedCCAutomationIntervalMS = new Number(); + this.requiresNoteOffTranslation = new Boolean(); + this.specificationVersionMajor = new Number(); + this.specificationVersionMinor = new Number(); + this.supportsMidi10Protocol = new Boolean(); + this.supportsMidi20Protocol = new Boolean(); + this.supportsMultiClient = new Boolean(); + this.supportsReceivingJRTimestamps = new Boolean(); + this.supportsSendingJRTimestamps = new Boolean(); + this.transportId = new String(); + this.transportMnemonic = new String(); + this.transportSuppliedDescription = new String(); + this.transportSuppliedName = new String(); + this.transportSuppliedProductId = new Number(); + this.transportSuppliedSerialNumber = new String(); + this.transportSuppliedVendorId = new Number(); + this.userSuppliedDescription = new String(); + this.userSuppliedLargeImagePath = new String(); + this.userSuppliedName = new String(); + this.userSuppliedSmallImagePath = new String(); + }; + + + cls.prototype.updateFromDeviceInformation = function updateFromDeviceInformation(deviceInformation) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.updateFromDeviceInformationUpdate = function updateFromDeviceInformationUpdate(deviceInformationUpdate) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.getParentDeviceInformation = function getParentDeviceInformation() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.getContainerInformation = function getContainerInformation() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.createFromId = function createFromId(id) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointDeviceInformation(); + } + + + cls.findAll = function findAll() { + /// + /// Function summary. + /// + /// + return new Object(); + } + +cls.findAll = function findAll(sortOrder) { + /// + /// Function summary. + /// A param. + /// + /// + return new Object(); + } + +cls.findAll = function findAll(sortOrder, endpointFilters) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.getAdditionalPropertiesList = function getAdditionalPropertiesList() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.deviceMatchesFilter = function deviceMatchesFilter(deviceInformation, endpointFilters) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.diagnosticsLoopbackAEndpointId = new String(); + cls.diagnosticsLoopbackBEndpointId = new String(); + cls.endpointInterfaceClass = new String(); + return cls; +}) (); +exports.MidiEndpointDeviceInformation = MidiEndpointDeviceInformation; + +MidiEndpointDeviceInformationAddedEventArgs = (function () { + var cls = function MidiEndpointDeviceInformationAddedEventArgs() { + this.addedDevice = new MidiEndpointDeviceInformation(); + }; + + + return cls; +}) (); +exports.MidiEndpointDeviceInformationAddedEventArgs = MidiEndpointDeviceInformationAddedEventArgs; + +MidiEndpointDeviceInformationRemovedEventArgs = (function () { + var cls = function MidiEndpointDeviceInformationRemovedEventArgs() { + this.deviceInformationUpdate = new Object(); + this.id = new String(); + }; + + + return cls; +}) (); +exports.MidiEndpointDeviceInformationRemovedEventArgs = MidiEndpointDeviceInformationRemovedEventArgs; + +MidiEndpointDeviceInformationUpdatedEventArgs = (function () { + var cls = function MidiEndpointDeviceInformationUpdatedEventArgs() { + this.deviceInformationUpdate = new Object(); + this.id = new String(); + this.updatedAdditionalCapabilities = new Boolean(); + this.updatedDeviceIdentity = new Boolean(); + this.updatedEndpointInformation = new Boolean(); + this.updatedFunctionBlocks = new Boolean(); + this.updatedName = new Boolean(); + this.updatedStreamConfiguration = new Boolean(); + this.updatedUserMetadata = new Boolean(); + }; + + + return cls; +}) (); +exports.MidiEndpointDeviceInformationUpdatedEventArgs = MidiEndpointDeviceInformationUpdatedEventArgs; + +MidiEndpointDeviceWatcher = (function () { + var cls = function MidiEndpointDeviceWatcher() { + this.enumeratedEndpointDevices = new Object(); + this.status = new Number(); + }; + + + cls.prototype.start = function start() { + /// + /// Function summary. + /// + } + + + cls.prototype.stop = function stop() { + /// + /// Function summary. + /// + } + + + cls.createWatcher = function createWatcher(endpointFilters) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointDeviceWatcher(); + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiEndpointDeviceWatcher = MidiEndpointDeviceWatcher; + +MidiFunctionBlock = (function () { + var cls = function MidiFunctionBlock() { + this.uIHint = new MidiFunctionBlockUIHint(); + this.number = new Number(); + this.name = new String(); + this.midiCIMessageVersionFormat = new Number(); + this.midi10Connection = new MidiFunctionBlockMidi10(); + this.maxSystemExclusive8Streams = new Number(); + this.isActive = new Boolean(); + this.groupCount = new Number(); + this.firstGroupIndex = new Number(); + this.direction = new MidiFunctionBlockDirection(); + this.isReadOnly = new Boolean(); + }; + + + cls.prototype.includesGroup = function includesGroup(group) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + return cls; +}) (); +exports.MidiFunctionBlock = MidiFunctionBlock; + +MidiGroup = (function () { + var cls = function MidiGroup() { + this.index = new Number(); + this.numberForDisplay = new Number(); + }; + +var cls = function MidiGroup(index) { + this.index = new Number(); + this.numberForDisplay = new Number(); +}; + + + cls.isValidGroupIndex = function isValidGroupIndex(index) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.labelFull = new String(); + cls.labelShort = new String(); + return cls; +}) (); +exports.MidiGroup = MidiGroup; + +MidiGroupEndpointListener = (function () { + var cls = function MidiGroupEndpointListener() { + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + this.preventFiringMainMessageReceivedEvent = new Boolean(); + this.preventCallingFurtherListeners = new Boolean(); + this.includeGroups = new Object(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiGroupEndpointListener = MidiGroupEndpointListener; + +MidiGroupTerminalBlock = (function () { + var cls = function MidiGroupTerminalBlock() { + this.calculatedMaxDeviceInputBandwidthBitsPerSecond = new Number(); + this.calculatedMaxDeviceOutputBandwidthBitsPerSecond = new Number(); + this.direction = new MidiGroupTerminalBlockDirection(); + this.firstGroupIndex = new Number(); + this.groupCount = new Number(); + this.maxDeviceInputBandwidthIn4KBitsPerSecondUnits = new Number(); + this.maxDeviceOutputBandwidthIn4KBitsPerSecondUnits = new Number(); + this.name = new String(); + this.number = new Number(); + this.protocol = new MidiGroupTerminalBlockProtocol(); + }; + + + cls.prototype.includesGroup = function includesGroup(group) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.asEquivalentFunctionBlock = function asEquivalentFunctionBlock() { + /// + /// Function summary. + /// + /// + return new MidiFunctionBlock(); + } + + + return cls; +}) (); +exports.MidiGroupTerminalBlock = MidiGroupTerminalBlock; + +MidiMessage128 = (function () { + var cls = function MidiMessage128() { + this.word3 = new Number(); + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage128(timestamp, word0, word1, word2, word3) { + this.word3 = new Number(); + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + +var cls = function MidiMessage128(timestamp, words) { + this.word3 = new Number(); + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage128 = MidiMessage128; + +MidiMessage32 = (function () { + var cls = function MidiMessage32() { + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage32(timestamp, word0) { + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage32 = MidiMessage32; + +MidiMessage64 = (function () { + var cls = function MidiMessage64() { + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage64(timestamp, word0, word1) { + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + +var cls = function MidiMessage64(timestamp, words) { + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage64 = MidiMessage64; + +MidiMessage96 = (function () { + var cls = function MidiMessage96() { + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + }; + +var cls = function MidiMessage96(timestamp, word0, word1, word2) { + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + +var cls = function MidiMessage96(timestamp, words) { + this.word2 = new Number(); + this.word1 = new Number(); + this.word0 = new Number(); + this.timestamp = new Number(); + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); +}; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getAllWords = function getAllWords() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.prototype.appendAllMessageWordsToList = function appendAllMessageWordsToList(targetList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.toString = function toString() { + /// + /// Function summary. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiMessage96 = MidiMessage96; + +MidiMessageBuilder = (function () { + var cls = function MidiMessageBuilder() { + }; + + + cls.buildUtilityMessage = function buildUtilityMessage(timestamp, status, dataOrReserved) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.buildSystemMessage = function buildSystemMessage(timestamp, group, status, midi1Byte2, midi1Byte3) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.buildMidi1ChannelVoiceMessage = function buildMidi1ChannelVoiceMessage(timestamp, group, status, channel, byte3, byte4) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.buildSystemExclusive7Message = function buildSystemExclusive7Message(timestamp, group, status, numberOfBytes, dataByte0, dataByte1, dataByte2, dataByte3, dataByte4, dataByte5) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage64(); + } + + + cls.buildMidi2ChannelVoiceMessage = function buildMidi2ChannelVoiceMessage(timestamp, group, status, channel, index, data) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage64(); + } + + + cls.buildSystemExclusive8Message = function buildSystemExclusive8Message(timestamp, group, status, numberOfValidDataBytesThisMessage, streamId, dataByte00, dataByte01, dataByte02, dataByte03, dataByte04, dataByte05, dataByte06, dataByte07, dataByte08, dataByte09, dataByte10, dataByte11, dataByte12) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildMixedDataSetChunkHeaderMessage = function buildMixedDataSetChunkHeaderMessage(timestamp, group, mdsId, numberValidDataBytesInThisChunk, numberChunksInMixedDataSet, numberOfThisChunk, manufacturerId, deviceId, subId1, subId2) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildMixedDataSetChunkDataMessage = function buildMixedDataSetChunkDataMessage(timestamp, group, mdsId, dataByte00, dataByte01, dataByte02, dataByte03, dataByte04, dataByte05, dataByte06, dataByte07, dataByte08, dataByte09, dataByte10, dataByte11, dataByte12, dataByte13) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildFlexDataMessage = function buildFlexDataMessage(timestamp, group, form, address, channel, statusBank, status, word1Data, word2Data, word3Data) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + cls.buildStreamMessage = function buildStreamMessage(timestamp, form, status, word0RemainingData, word1Data, word2Data, word3Data) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage128(); + } + + + return cls; +}) (); +exports.MidiMessageBuilder = MidiMessageBuilder; + +MidiMessageConverter = (function () { + var cls = function MidiMessageConverter() { + }; + + + cls.convertMidi1Message = function convertMidi1Message(timestamp, group, statusByte) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + +cls.convertMidi1Message = function convertMidi1Message(timestamp, group, statusByte, dataByte1) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + +cls.convertMidi1Message = function convertMidi1Message(timestamp, group, statusByte, dataByte1, dataByte2) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ChannelPressureMessage = function convertMidi1ChannelPressureMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1NoteOffMessage = function convertMidi1NoteOffMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1NoteOnMessage = function convertMidi1NoteOnMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1PitchBendChangeMessage = function convertMidi1PitchBendChangeMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1PolyphonicKeyPressureMessage = function convertMidi1PolyphonicKeyPressureMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ProgramChangeMessage = function convertMidi1ProgramChangeMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1TimeCodeMessage = function convertMidi1TimeCodeMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1SongPositionPointerMessage = function convertMidi1SongPositionPointerMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1SongSelectMessage = function convertMidi1SongSelectMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1TuneRequestMessage = function convertMidi1TuneRequestMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1TimingClockMessage = function convertMidi1TimingClockMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1StartMessage = function convertMidi1StartMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ContinueMessage = function convertMidi1ContinueMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1StopMessage = function convertMidi1StopMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1ActiveSensingMessage = function convertMidi1ActiveSensingMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + cls.convertMidi1SystemResetMessage = function convertMidi1SystemResetMessage(timestamp, group, originalMessage) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiMessage32(); + } + + + return cls; +}) (); +exports.MidiMessageConverter = MidiMessageConverter; + +MidiMessageReceivedEventArgs = (function () { + var cls = function MidiMessageReceivedEventArgs() { + this.messageType = new MidiMessageType(); + this.packetType = new MidiPacketType(); + this.timestamp = new Number(); + }; + + + cls.prototype.peekFirstWord = function peekFirstWord() { + /// + /// Function summary. + /// + /// + return new Number(); + } + + + cls.prototype.getMessagePacket = function getMessagePacket() { + /// + /// Function summary. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.prototype.fillWords = function fillWords(word0, word1, word2, word3) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillMessageStruct = function fillMessageStruct(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.fillMessage32 = function fillMessage32(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillMessage64 = function fillMessage64(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillMessage96 = function fillMessage96(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillMessage128 = function fillMessage128(message) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.fillWordArray = function () { +} + + cls.prototype.fillByteArray = function () { +} + + cls.prototype.fillBuffer = function fillBuffer(byteOffset, buffer) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.prototype.appendWordsToList = function appendWordsToList(wordList) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + return cls; +}) (); +exports.MidiMessageReceivedEventArgs = MidiMessageReceivedEventArgs; + +MidiMessageTypeEndpointListener = (function () { + var cls = function MidiMessageTypeEndpointListener() { + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + this.preventFiringMainMessageReceivedEvent = new Boolean(); + this.preventCallingFurtherListeners = new Boolean(); + this.includeMessageTypes = new Object(); + }; + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiMessageTypeEndpointListener = MidiMessageTypeEndpointListener; + +MidiMessageUtility = (function () { + var cls = function MidiMessageUtility() { + }; + + + cls.validateMessage32MessageType = function validateMessage32MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.validateMessage64MessageType = function validateMessage64MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.validateMessage96MessageType = function validateMessage96MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.validateMessage128MessageType = function validateMessage128MessageType(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.getMessageTypeFromMessageFirstWord = function getMessageTypeFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiMessageType(); + } + + + cls.getPacketTypeFromMessageFirstWord = function getPacketTypeFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiPacketType(); + } + + + cls.messageTypeHasGroupField = function messageTypeHasGroupField(messageType) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.replaceGroupInMessageFirstWord = function replaceGroupInMessageFirstWord(word0, newGroup) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.getGroupFromMessageFirstWord = function getGroupFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiGroup(); + } + + + cls.getStatusFromUtilityMessage = function getStatusFromUtilityMessage(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromMidi1ChannelVoiceMessage = function getStatusFromMidi1ChannelVoiceMessage(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Midi1ChannelVoiceMessageStatus(); + } + + + cls.getStatusFromMidi2ChannelVoiceMessageFirstWord = function getStatusFromMidi2ChannelVoiceMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Midi2ChannelVoiceMessageStatus(); + } + + + cls.getStatusBankFromFlexDataMessageFirstWord = function getStatusBankFromFlexDataMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromFlexDataMessageFirstWord = function getStatusFromFlexDataMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromSystemCommonMessage = function getStatusFromSystemCommonMessage(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromDataMessage64FirstWord = function getStatusFromDataMessage64FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getNumberOfBytesFromDataMessage64FirstWord = function getNumberOfBytesFromDataMessage64FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromDataMessage128FirstWord = function getStatusFromDataMessage128FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getNumberOfBytesFromDataMessage128FirstWord = function getNumberOfBytesFromDataMessage128FirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.messageTypeHasChannelField = function messageTypeHasChannelField(messageType) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.replaceChannelInMessageFirstWord = function replaceChannelInMessageFirstWord(word0, newChannel) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Number(); + } + + + cls.getChannelFromMessageFirstWord = function getChannelFromMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiChannel(); + } + + + cls.getFormFromStreamMessageFirstWord = function getFormFromStreamMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getStatusFromStreamMessageFirstWord = function getStatusFromStreamMessageFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new Number(); + } + + + cls.getMessageFriendlyNameFromFirstWord = function getMessageFriendlyNameFromFirstWord(word0) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + cls.getPacketListFromWordList = function getPacketListFromWordList(timestamp, words) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.getWordListFromPacketList = function getWordListFromPacketList(words) { + /// + /// Function summary. + /// A param. + /// + /// + return new Object(); + } + + + return cls; +}) (); +exports.MidiMessageUtility = MidiMessageUtility; + +MidiService = (function () { + var cls = function MidiService() { + }; + + + cls.pingService = function pingService(pingCount) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiServicePingResponseSummary(); + } + +cls.pingService = function pingService(pingCount, timeoutMilliseconds) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiServicePingResponseSummary(); + } + + + cls.getInstalledTransportPlugins = function getInstalledTransportPlugins() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.getInstalledMessageProcessingPlugins = function getInstalledMessageProcessingPlugins() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.getActiveSessions = function getActiveSessions() { + /// + /// Function summary. + /// + /// + return new Object(); + } + + + cls.createTemporaryLoopbackEndpoints = function createTemporaryLoopbackEndpoints(associationId, endpointDefinitionA, endpointDefinitionB) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new MidiServiceLoopbackEndpointCreationResult(); + } + + + cls.removeTemporaryLoopbackEndpoints = function removeTemporaryLoopbackEndpoints(associationId) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.updateTransportPluginConfiguration = function updateTransportPluginConfiguration(configurationUpdate) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiServiceConfigurationResponse(); + } + + + cls.updateProcessingPluginConfiguration = function updateProcessingPluginConfiguration(configurationUpdate) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiServiceConfigurationResponse(); + } + + + return cls; +}) (); +exports.MidiService = MidiService; + +MidiServiceConfigurationResponse = (function () { + var cls = function MidiServiceConfigurationResponse() { + this.responseJson = new String(); + this.status = new MidiServiceConfigurationResponseStatus(); + }; + + + return cls; +}) (); +exports.MidiServiceConfigurationResponse = MidiServiceConfigurationResponse; + +MidiServiceLoopbackEndpointCreationResult = (function () { + var cls = function MidiServiceLoopbackEndpointCreationResult() { + this.associationId = new String(); + this.endpointDeviceIdA = new String(); + this.endpointDeviceIdB = new String(); + this.success = new Boolean(); + }; + + + return cls; +}) (); +exports.MidiServiceLoopbackEndpointCreationResult = MidiServiceLoopbackEndpointCreationResult; + +MidiServiceLoopbackEndpointDefinition = (function () { + var cls = function MidiServiceLoopbackEndpointDefinition() { + this.uniqueId = new String(); + this.name = new String(); + this.description = new String(); + }; + + + return cls; +}) (); +exports.MidiServiceLoopbackEndpointDefinition = MidiServiceLoopbackEndpointDefinition; + +MidiServiceMessageProcessingPluginInfo = (function () { + var cls = function MidiServiceMessageProcessingPluginInfo() { + this.author = new String(); + this.clientConfigurationAssemblyName = new String(); + this.description = new String(); + this.id = new String(); + this.isClientConfigurable = new Boolean(); + this.isSystemManaged = new Boolean(); + this.name = new String(); + this.smallImagePath = new String(); + this.supportsMultipleInstancesPerDevice = new Boolean(); + this.version = new String(); + }; + + + return cls; +}) (); +exports.MidiServiceMessageProcessingPluginInfo = MidiServiceMessageProcessingPluginInfo; + +MidiServicePingResponse = (function () { + var cls = function MidiServicePingResponse() { + this.clientDeltaTimestamp = new Number(); + this.clientReceiveMidiTimestamp = new Number(); + this.clientSendMidiTimestamp = new Number(); + this.index = new Number(); + this.serviceReportedMidiTimestamp = new Number(); + this.sourceId = new Number(); + }; + + + return cls; +}) (); +exports.MidiServicePingResponse = MidiServicePingResponse; + +MidiServicePingResponseSummary = (function () { + var cls = function MidiServicePingResponseSummary() { + this.averagePingRoundTripMidiClock = new Number(); + this.failureReason = new String(); + this.responses = new Object(); + this.success = new Boolean(); + this.totalPingRoundTripMidiClock = new Number(); + }; + + + return cls; +}) (); +exports.MidiServicePingResponseSummary = MidiServicePingResponseSummary; + +MidiServiceSessionConnectionInfo = (function () { + var cls = function MidiServiceSessionConnectionInfo() { + this.earliestConnectionTime = new Date(); + this.endpointDeviceId = new String(); + this.instanceCount = new Number(); + }; + + + return cls; +}) (); +exports.MidiServiceSessionConnectionInfo = MidiServiceSessionConnectionInfo; + +MidiServiceSessionInfo = (function () { + var cls = function MidiServiceSessionInfo() { + this.connections = new Object(); + this.processId = new Number(); + this.processName = new String(); + this.sessionId = new String(); + this.sessionName = new String(); + this.startTime = new Date(); + }; + + + return cls; +}) (); +exports.MidiServiceSessionInfo = MidiServiceSessionInfo; + +MidiServiceTransportPluginInfo = (function () { + var cls = function MidiServiceTransportPluginInfo() { + this.author = new String(); + this.clientConfigurationAssemblyName = new String(); + this.description = new String(); + this.id = new String(); + this.isClientConfigurable = new Boolean(); + this.isRuntimeCreatableByApps = new Boolean(); + this.isRuntimeCreatableBySettings = new Boolean(); + this.isSystemManaged = new Boolean(); + this.mnemonic = new String(); + this.name = new String(); + this.smallImagePath = new String(); + this.version = new String(); + }; + + + return cls; +}) (); +exports.MidiServiceTransportPluginInfo = MidiServiceTransportPluginInfo; + +MidiSession = (function () { + var cls = function MidiSession() { + this.connections = new Object(); + this.id = new String(); + this.isOpen = new Boolean(); + this.name = new String(); + this.settings = new MidiSessionSettings(); + }; + + + cls.prototype.createEndpointConnection = function createEndpointConnection(endpointDeviceId) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointConnection(); + } + +cls.prototype.createEndpointConnection = function createEndpointConnection(endpointDeviceId, settings) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiEndpointConnection(); + } + + + cls.prototype.createVirtualDeviceAndConnection = function createVirtualDeviceAndConnection(deviceDefinition) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiEndpointConnection(); + } + + + cls.prototype.disconnectEndpointConnection = function disconnectEndpointConnection(endpointConnectionId) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.updateName = function updateName(newName) { + /// + /// Function summary. + /// A param. + /// + /// + return new Boolean(); + } + + + cls.prototype.close = function close() { +} + + + cls.createSession = function createSession(sessionName) { + /// + /// Function summary. + /// A param. + /// + /// + return new MidiSession(); + } + +cls.createSession = function createSession(sessionName, settings) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new MidiSession(); + } + + + return cls; +}) (); +exports.MidiSession = MidiSession; + +MidiSessionSettings = (function () { + var cls = function MidiSessionSettings() { + this.useMmcssThreads = new Boolean(); + }; + + + return cls; +}) (); +exports.MidiSessionSettings = MidiSessionSettings; + +MidiStreamConfigurationRequestReceivedEventArgs = (function () { + var cls = function MidiStreamConfigurationRequestReceivedEventArgs() { + this.preferredMidiProtocol = new MidiProtocol(); + this.requestEndpointReceiveJitterReductionTimestamps = new Boolean(); + this.requestEndpointTransmitJitterReductionTimestamps = new Boolean(); + this.timestamp = new Number(); + }; + + + return cls; +}) (); +exports.MidiStreamConfigurationRequestReceivedEventArgs = MidiStreamConfigurationRequestReceivedEventArgs; + +MidiStreamConfigurationRequestedSettings = (function () { + var cls = function MidiStreamConfigurationRequestedSettings() { + this.specificationVersionMinor = new Number(); + this.specificationVersionMajor = new Number(); + this.requestEndpointTransmitJitterReductionTimestamps = new Boolean(); + this.requestEndpointReceiveJitterReductionTimestamps = new Boolean(); + this.preferredMidiProtocol = new MidiProtocol(); + }; + + + return cls; +}) (); +exports.MidiStreamConfigurationRequestedSettings = MidiStreamConfigurationRequestedSettings; + +MidiStreamMessageBuilder = (function () { + var cls = function MidiStreamMessageBuilder() { + }; + + + cls.buildEndpointDiscoveryMessage = function buildEndpointDiscoveryMessage(timestamp, umpVersionMajor, umpVersionMinor, requestFlags) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildEndpointInfoNotificationMessage = function buildEndpointInfoNotificationMessage(timestamp, umpVersionMajor, umpVersionMinor, hasStaticFunctionBlocks, numberOfFunctionBlocks, supportsMidi20Protocol, supportsMidi10Protocol, supportsReceivingJitterReductionTimestamps, supportsSendingJitterReductionTimestamps) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildDeviceIdentityNotificationMessage = function buildDeviceIdentityNotificationMessage(timestamp, deviceManufacturerSysExIdByte1, deviceManufacturerSysExIdByte2, deviceManufacturerSysExIdByte3, deviceFamilyLsb, deviceFamilyMsb, deviceFamilyModelNumberLsb, deviceFamilyModelNumberMsb, softwareRevisionLevelByte1, softwareRevisionLevelByte2, softwareRevisionLevelByte3, softwareRevisionLevelByte4) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildEndpointNameNotificationMessages = function buildEndpointNameNotificationMessages(timestamp, name) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.buildProductInstanceIdNotificationMessages = function buildProductInstanceIdNotificationMessages(timestamp, productInstanceId) { + /// + /// Function summary. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.parseEndpointNameNotificationMessages = function parseEndpointNameNotificationMessages(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + cls.parseProductInstanceIdNotificationMessages = function parseProductInstanceIdNotificationMessages(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + cls.buildStreamConfigurationRequestMessage = function buildStreamConfigurationRequestMessage(timestamp, protocol, expectToReceiveJRTimestamps, requestToSendJRTimestamps) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildStreamConfigurationNotificationMessage = function buildStreamConfigurationNotificationMessage(timestamp, protocol, confirmationWillReceiveJRTimestamps, confirmationSendJRTimestamps) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildFunctionBlockDiscoveryMessage = function buildFunctionBlockDiscoveryMessage(timestamp, functionBlockNumber, requestFlags) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildFunctionBlockInfoNotificationMessage = function buildFunctionBlockInfoNotificationMessage(timestamp, active, functionBlockNumber, uiHint, midi10, direction, firstGroup, numberOfGroups, midiCIVersionFormat, maxNumberSysEx8Streams) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// A param. + /// + /// + return new IMidiUniversalPacket(); + } + + + cls.buildFunctionBlockNameNotificationMessages = function buildFunctionBlockNameNotificationMessages(timestamp, functionBlockNumber, name) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + /// + return new Object(); + } + + + cls.parseFunctionBlockNameNotificationMessages = function parseFunctionBlockNameNotificationMessages(messages) { + /// + /// Function summary. + /// A param. + /// + /// + return new String(); + } + + + return cls; +}) (); +exports.MidiStreamMessageBuilder = MidiStreamMessageBuilder; + +MidiUniqueId = (function () { + var cls = function MidiUniqueId() { + this.byte4 = new Number(); + this.byte3 = new Number(); + this.byte2 = new Number(); + this.byte1 = new Number(); + this.asCombined28BitValue = new Number(); + this.isBroadcast = new Boolean(); + this.isReserved = new Boolean(); + }; + +var cls = function MidiUniqueId(combined28BitValue) { + this.byte4 = new Number(); + this.byte3 = new Number(); + this.byte2 = new Number(); + this.byte1 = new Number(); + this.asCombined28BitValue = new Number(); + this.isBroadcast = new Boolean(); + this.isReserved = new Boolean(); +}; + +var cls = function MidiUniqueId(sevenBitByte1, sevenBitByte2, sevenBitByte3, sevenBitByte4) { + this.byte4 = new Number(); + this.byte3 = new Number(); + this.byte2 = new Number(); + this.byte1 = new Number(); + this.asCombined28BitValue = new Number(); + this.isBroadcast = new Boolean(); + this.isReserved = new Boolean(); +}; + + + cls.createBroadcast = function createBroadcast() { + /// + /// Function summary. + /// + /// + return new MidiUniqueId(); + } + + + cls.createRandom = function createRandom() { + /// + /// Function summary. + /// + /// + return new MidiUniqueId(); + } + + + cls.labelFull = new String(); + cls.labelShort = new String(); + return cls; +}) (); +exports.MidiUniqueId = MidiUniqueId; + +MidiVirtualEndpointDevice = (function () { + var cls = function MidiVirtualEndpointDevice() { + this.tag = new Object(); + this.name = new String(); + this.isEnabled = new Boolean(); + this.id = new String(); + this.suppressHandledMessages = new Boolean(); + this.deviceDefinition = new MidiVirtualEndpointDeviceDefinition(); + this.functionBlocks = new Object(); + }; + + + cls.prototype.updateFunctionBlock = function updateFunctionBlock(block) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.updateEndpointName = function updateEndpointName(name) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.initialize = function initialize(endpointConnection) { + /// + /// Function summary. + /// A param. + /// + } + + + cls.prototype.onEndpointConnectionOpened = function onEndpointConnectionOpened() { + /// + /// Function summary. + /// + } + + + cls.prototype.processIncomingMessage = function processIncomingMessage(args, skipFurtherListeners, skipMainMessageReceivedEvent) { + /// + /// Function summary. + /// A param. + /// A param. + /// A param. + /// + } + + + cls.prototype.cleanup = function cleanup() { + /// + /// Function summary. + /// + } + + + cls.prototype.addListener = function addListener(eventName, callback){} + cls.prototype.removeListener = function removeListener(eventName, callback){} + cls.prototype.on = function on(eventName, callback){} + cls.prototype.off = function off(eventName, callback){} + return cls; +}) (); +exports.MidiVirtualEndpointDevice = MidiVirtualEndpointDevice; + +MidiVirtualEndpointDeviceDefinition = (function () { + var cls = function MidiVirtualEndpointDeviceDefinition() { + this.transportSuppliedDescription = new String(); + this.supportsSendingJRTimestamps = new Boolean(); + this.supportsReceivingJRTimestamps = new Boolean(); + this.supportsMidi2ProtocolMessages = new Boolean(); + this.supportsMidi1ProtocolMessages = new Boolean(); + this.endpointProductInstanceId = new String(); + this.endpointName = new String(); + this.deviceFamilyMsb = new Number(); + this.deviceFamilyModelMsb = new Number(); + this.deviceFamilyModelLsb = new Number(); + this.deviceFamilyLsb = new Number(); + this.areFunctionBlocksStatic = new Boolean(); + this.deviceManufacturerSystemExclusiveId = new Object(); + this.functionBlocks = new Object(); + this.softwareRevisionLevel = new Object(); + }; + + + return cls; +}) (); +exports.MidiVirtualEndpointDeviceDefinition = MidiVirtualEndpointDeviceDefinition; + diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.ts b/build/electron-projection/projection3_backup/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.ts new file mode 100644 index 000000000..a2404bfee --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/lib/NodeRT_Windows_Devices_Midi2.d.ts @@ -0,0 +1,1262 @@ +declare module "windows.devices.midi2" { + export class MidiMessageStruct { + word0: Number; + word1: Number; + word2: Number; + word3: Number; + constructor(); + } + + export enum Midi1ChannelVoiceMessageStatus { + noteOff, + noteOn, + polyPressure, + controlChange, + programChange, + channelPressure, + pitchBend, + } + + export enum Midi2ChannelVoiceMessageStatus { + registeredPerNoteController, + assignablePerNoteController, + registeredController, + assignableController, + relativeRegisteredController, + relativeAssignableController, + perNotePitchBend, + noteOff, + noteOn, + polyPressure, + controlChange, + programChange, + channelPressure, + pitchBend, + perNoteManagement, + } + + export enum MidiEndpointDeviceInformationFilters { + includeClientUmpNative, + includeClientByteStreamNative, + includeVirtualDeviceResponder, + includeDiagnosticLoopback, + includeDiagnosticPing, + allTypicalEndpoints, + } + + export enum MidiEndpointDeviceInformationSortOrder { + none, + name, + endpointDeviceId, + deviceInstanceId, + containerThenName, + containerThenEndpointDeviceId, + containerThenDeviceInstanceId, + transportMnemonicThenName, + transportMnemonicThenEndpointDeviceId, + transportMnemonicThenDeviceInstanceId, + } + + export enum MidiEndpointDevicePurpose { + normalMessageEndpoint, + virtualDeviceResponder, + inBoxGeneralMidiSynth, + diagnosticLoopback, + diagnosticPing, + } + + export enum MidiEndpointDiscoveryRequests { + none, + requestEndpointInfo, + requestDeviceIdentity, + requestEndpointName, + requestProductInstanceId, + requestStreamConfiguration, + } + + export enum MidiEndpointNativeDataFormat { + unknown, + byteStream, + universalMidiPacket, + } + + export enum MidiFunctionBlockDirection { + undefined, + blockInput, + blockOutput, + bidirectional, + } + + export enum MidiFunctionBlockDiscoveryRequests { + none, + requestFunctionBlockInfo, + requestFunctionBlockName, + } + + export enum MidiFunctionBlockMidi10 { + not10, + yesBandwidthUnrestricted, + yesBandwidthRestricted, + reserved, + } + + export enum MidiFunctionBlockUIHint { + unknown, + receiver, + sender, + bidirectional, + } + + export enum MidiGroupTerminalBlockDirection { + bidirectional, + blockInput, + blockOutput, + } + + export enum MidiGroupTerminalBlockProtocol { + unknown, + midi1Message64, + midi1Message64WithJitterReduction, + midi1Message128, + midi1Message128WithJitterReduction, + midi2, + midi2WithJitterReduction, + } + + export enum MidiMessageType { + utilityMessage32, + systemCommon32, + midi1ChannelVoice32, + dataMessage64, + midi2ChannelVoice64, + dataMessage128, + futureReserved632, + futureReserved732, + futureReserved864, + futureReserved964, + futureReservedA64, + futureReservedB96, + futureReservedC96, + flexData128, + futureReservedE128, + stream128, + } + + export enum MidiPacketType { + unknownOrInvalid, + universalMidiPacket32, + universalMidiPacket64, + universalMidiPacket96, + universalMidiPacket128, + } + + export enum MidiProtocol { + default, + midi1, + midi2, + } + + export enum MidiSendMessageResults { + succeeded, + failed, + bufferFull, + endpointConnectionClosedOrInvalid, + invalidMessageTypeForWordCount, + invalidMessageOther, + dataIndexOutOfRange, + timestampOutOfRange, + messageListPartiallyProcessed, + other, + } + + export enum MidiServiceConfigurationResponseStatus { + success, + errorTargetNotFound, + errorJsonNullOrEmpty, + errorProcessingJson, + errorNotImplemented, + errorOther, + } + + export enum MidiSystemExclusive8Status { + completeMessageInSingleMessagePacket, + startMessagePacket, + continueMessagePacket, + endMessagePacket, + } + + export class IMidiEndpointConnectionSettings { + settingsJson: String; + constructor(); + + } + + export class IMidiEndpointConnectionSource { + constructor(); + + } + + export class IMidiEndpointMessageProcessingPlugin { + id: String; + isEnabled: Boolean; + name: String; + tag: Object; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + } + + export class IMidiMessageReceivedEventSource { + constructor(); + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class IMidiServiceMessageProcessingPluginConfiguration { + endpointDeviceId: String; + isFromConfigurationFile: Boolean; + messageProcessingPluginId: String; + pluginInstanceId: String; + settingsJson: Object; + constructor(); + + } + + export class IMidiServiceTransportPluginConfiguration { + isFromConfigurationFile: Boolean; + settingsJson: Object; + transportId: String; + constructor(); + + } + + export class IMidiUniversalPacket { + messageType: MidiMessageType; + packetType: MidiPacketType; + timestamp: Number; + constructor(); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + } + + export class MidiChannel { + static labelFull: String; + static labelShort: String; + index: Number; + numberForDisplay: Number; + constructor(); + constructor(index: Number); + + static isValidChannelIndex(index: Number): Boolean; + + + } + + export class MidiChannelEndpointListener { + preventFiringMainMessageReceivedEvent: Boolean; + preventCallingFurtherListeners: Boolean; + includeGroup: MidiGroup; + includeChannels: Object; + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiClock { + static now: Number; + static timestampConstantSendImmediately: Number; + static timestampFrequency: Number; + constructor(); + + static convertTimestampToMicroseconds(timestampValue: Number): Number; + + + static convertTimestampToMilliseconds(timestampValue: Number): Number; + + + static convertTimestampToSeconds(timestampValue: Number): Number; + + + static offsetTimestampByTicks(timestampValue: Number, offsetTicks: Number): Number; + + + static offsetTimestampByMicroseconds(timestampValue: Number, offsetMicroseconds: Number): Number; + + + static offsetTimestampByMilliseconds(timestampValue: Number, offsetMilliseconds: Number): Number; + + + static offsetTimestampBySeconds(timestampValue: Number, offsetSeconds: Number): Number; + + + } + + export class MidiEndpointConnection { + tag: Object; + connectionId: String; + endpointDeviceId: String; + isOpen: Boolean; + messageProcessingPlugins: Object; + settings: IMidiEndpointConnectionSettings; + constructor(); + + static getDeviceSelector(): String; + + + static sendMessageSucceeded(sendResult: MidiSendMessageResults): Boolean; + + + static sendMessageFailed(sendResult: MidiSendMessageResults): Boolean; + + + open(): Boolean; + + addMessageProcessingPlugin(plugin: IMidiEndpointMessageProcessingPlugin): void; + + removeMessageProcessingPlugin(id: String): void; + + sendSingleMessagePacket(message: IMidiUniversalPacket): MidiSendMessageResults; + + sendSingleMessageStruct(timestamp: Number, wordCount: Number, message: MidiMessageStruct): MidiSendMessageResults; + + sendSingleMessageWordArray(timestamp: Number, startIndex: Number, wordCount: Number, words: Array): MidiSendMessageResults; + + sendSingleMessageWords(timestamp: Number, word0: Number): MidiSendMessageResults; + sendSingleMessageWords(timestamp: Number, word0: Number, word1: Number): MidiSendMessageResults; + sendSingleMessageWords(timestamp: Number, word0: Number, word1: Number, word2: Number): MidiSendMessageResults; + sendSingleMessageWords(timestamp: Number, word0: Number, word1: Number, word2: Number, word3: Number): MidiSendMessageResults; + + sendSingleMessageBuffer(timestamp: Number, byteOffset: Number, byteCount: Number, buffer: Object): MidiSendMessageResults; + + sendMultipleMessagesWordList(timestamp: Number, words: Object): MidiSendMessageResults; + + sendMultipleMessagesWordArray(timestamp: Number, startIndex: Number, wordCount: Number, words: Array): MidiSendMessageResults; + + sendMultipleMessagesPacketList(messages: Object): MidiSendMessageResults; + + sendMultipleMessagesStructList(timestamp: Number, messages: Object): MidiSendMessageResults; + + sendMultipleMessagesStructArray(timestamp: Number, startIndex: Number, messageCount: Number, messages: Array): MidiSendMessageResults; + + sendMultipleMessagesBuffer(timestamp: Number, byteOffset: Number, byteCount: Number, buffer: Object): MidiSendMessageResults; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiEndpointDeviceInformation { + static diagnosticsLoopbackAEndpointId: String; + static diagnosticsLoopbackBEndpointId: String; + static endpointInterfaceClass: String; + configuredProtocol: MidiProtocol; + configuredToReceiveJRTimestamps: Boolean; + configuredToSendJRTimestamps: Boolean; + containerId: String; + deviceIdentityDeviceFamilyLsb: Number; + deviceIdentityDeviceFamilyModelNumberLsb: Number; + deviceIdentityDeviceFamilyModelNumberMsb: Number; + deviceIdentityDeviceFamilyMsb: Number; + deviceIdentityLastUpdateTime: Date; + deviceIdentitySoftwareRevisionLevel: Array; + deviceIdentitySystemExclusiveId: Array; + deviceInstanceId: String; + endpointConfigurationLastUpdateTime: Date; + endpointInformationLastUpdateTime: Date; + endpointPurpose: MidiEndpointDevicePurpose; + endpointSuppliedName: String; + endpointSuppliedNameLastUpdateTime: Date; + functionBlockCount: Number; + functionBlocks: Object; + functionBlocksLastUpdateTime: Date; + groupTerminalBlocks: Object; + hasStaticFunctionBlocks: Boolean; + id: String; + manufacturerName: String; + name: String; + nativeDataFormat: MidiEndpointNativeDataFormat; + productInstanceId: String; + productInstanceIdLastUpdateTime: Date; + properties: Object; + recommendedCCAutomationIntervalMS: Number; + requiresNoteOffTranslation: Boolean; + specificationVersionMajor: Number; + specificationVersionMinor: Number; + supportsMidi10Protocol: Boolean; + supportsMidi20Protocol: Boolean; + supportsMultiClient: Boolean; + supportsReceivingJRTimestamps: Boolean; + supportsSendingJRTimestamps: Boolean; + transportId: String; + transportMnemonic: String; + transportSuppliedDescription: String; + transportSuppliedName: String; + transportSuppliedProductId: Number; + transportSuppliedSerialNumber: String; + transportSuppliedVendorId: Number; + userSuppliedDescription: String; + userSuppliedLargeImagePath: String; + userSuppliedName: String; + userSuppliedSmallImagePath: String; + constructor(); + + static createFromId(id: String): MidiEndpointDeviceInformation; + + + static findAll(): Object; + static findAll(sortOrder: MidiEndpointDeviceInformationSortOrder): Object; + static findAll(sortOrder: MidiEndpointDeviceInformationSortOrder, endpointFilters: MidiEndpointDeviceInformationFilters): Object; + + + static getAdditionalPropertiesList(): Object; + + + static deviceMatchesFilter(deviceInformation: MidiEndpointDeviceInformation, endpointFilters: MidiEndpointDeviceInformationFilters): Boolean; + + + updateFromDeviceInformation(deviceInformation: Object): Boolean; + + updateFromDeviceInformationUpdate(deviceInformationUpdate: Object): Boolean; + + getParentDeviceInformation(): Object; + + getContainerInformation(): Object; + + } + + export class MidiEndpointDeviceInformationAddedEventArgs { + addedDevice: MidiEndpointDeviceInformation; + constructor(); + + } + + export class MidiEndpointDeviceInformationRemovedEventArgs { + deviceInformationUpdate: Object; + id: String; + constructor(); + + } + + export class MidiEndpointDeviceInformationUpdatedEventArgs { + deviceInformationUpdate: Object; + id: String; + updatedAdditionalCapabilities: Boolean; + updatedDeviceIdentity: Boolean; + updatedEndpointInformation: Boolean; + updatedFunctionBlocks: Boolean; + updatedName: Boolean; + updatedStreamConfiguration: Boolean; + updatedUserMetadata: Boolean; + constructor(); + + } + + export class MidiEndpointDeviceWatcher { + enumeratedEndpointDevices: Object; + status: Number; + constructor(); + + static createWatcher(endpointFilters: MidiEndpointDeviceInformationFilters): MidiEndpointDeviceWatcher; + + + start(): void; + + stop(): void; + + addListener(type: "Added", listener: (ev: Event) => void): void ; + removeListener(type: "Added", listener: (ev: Event) => void): void ; + on(type: "Added", listener: (ev: Event) => void): void ; + off(type: "Added", listener: (ev: Event) => void): void ; + + addListener(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + removeListener(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + on(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + off(type: "EnumerationCompleted", listener: (ev: Event) => void): void ; + + addListener(type: "Removed", listener: (ev: Event) => void): void ; + removeListener(type: "Removed", listener: (ev: Event) => void): void ; + on(type: "Removed", listener: (ev: Event) => void): void ; + off(type: "Removed", listener: (ev: Event) => void): void ; + + addListener(type: "Stopped", listener: (ev: Event) => void): void ; + removeListener(type: "Stopped", listener: (ev: Event) => void): void ; + on(type: "Stopped", listener: (ev: Event) => void): void ; + off(type: "Stopped", listener: (ev: Event) => void): void ; + + addListener(type: "Updated", listener: (ev: Event) => void): void ; + removeListener(type: "Updated", listener: (ev: Event) => void): void ; + on(type: "Updated", listener: (ev: Event) => void): void ; + off(type: "Updated", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiFunctionBlock { + uIHint: MidiFunctionBlockUIHint; + number: Number; + name: String; + midiCIMessageVersionFormat: Number; + midi10Connection: MidiFunctionBlockMidi10; + maxSystemExclusive8Streams: Number; + isActive: Boolean; + groupCount: Number; + firstGroupIndex: Number; + direction: MidiFunctionBlockDirection; + isReadOnly: Boolean; + constructor(); + + includesGroup(group: MidiGroup): Boolean; + + } + + export class MidiGroup { + static labelFull: String; + static labelShort: String; + index: Number; + numberForDisplay: Number; + constructor(); + constructor(index: Number); + + static isValidGroupIndex(index: Number): Boolean; + + + } + + export class MidiGroupEndpointListener { + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + preventFiringMainMessageReceivedEvent: Boolean; + preventCallingFurtherListeners: Boolean; + includeGroups: Object; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiGroupTerminalBlock { + calculatedMaxDeviceInputBandwidthBitsPerSecond: Number; + calculatedMaxDeviceOutputBandwidthBitsPerSecond: Number; + direction: MidiGroupTerminalBlockDirection; + firstGroupIndex: Number; + groupCount: Number; + maxDeviceInputBandwidthIn4KBitsPerSecondUnits: Number; + maxDeviceOutputBandwidthIn4KBitsPerSecondUnits: Number; + name: String; + number: Number; + protocol: MidiGroupTerminalBlockProtocol; + constructor(); + + includesGroup(group: MidiGroup): Boolean; + + asEquivalentFunctionBlock(): MidiFunctionBlock; + + } + + export class MidiMessage128 { + word3: Number; + word2: Number; + word1: Number; + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number, word1: Number, word2: Number, word3: Number); + constructor(timestamp: Number, words: Array); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessage32 { + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessage64 { + word1: Number; + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number, word1: Number); + constructor(timestamp: Number, words: Array); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessage96 { + word2: Number; + word1: Number; + word0: Number; + timestamp: Number; + messageType: MidiMessageType; + packetType: MidiPacketType; + constructor(); + constructor(timestamp: Number, word0: Number, word1: Number, word2: Number); + constructor(timestamp: Number, words: Array); + + peekFirstWord(): Number; + + getAllWords(): Object; + + appendAllMessageWordsToList(targetList: Object): Number; + + fillBuffer(byteOffset: Number, buffer: Object): Number; + + toString(): String; + + } + + export class MidiMessageBuilder { + constructor(); + + static buildUtilityMessage(timestamp: Number, status: Number, dataOrReserved: Number): MidiMessage32; + + + static buildSystemMessage(timestamp: Number, group: MidiGroup, status: Number, midi1Byte2: Number, midi1Byte3: Number): MidiMessage32; + + + static buildMidi1ChannelVoiceMessage(timestamp: Number, group: MidiGroup, status: Midi1ChannelVoiceMessageStatus, channel: MidiChannel, byte3: Number, byte4: Number): MidiMessage32; + + + static buildSystemExclusive7Message(timestamp: Number, group: MidiGroup, status: Number, numberOfBytes: Number, dataByte0: Number, dataByte1: Number, dataByte2: Number, dataByte3: Number, dataByte4: Number, dataByte5: Number): MidiMessage64; + + + static buildMidi2ChannelVoiceMessage(timestamp: Number, group: MidiGroup, status: Midi2ChannelVoiceMessageStatus, channel: MidiChannel, index: Number, data: Number): MidiMessage64; + + + static buildSystemExclusive8Message(timestamp: Number, group: MidiGroup, status: MidiSystemExclusive8Status, numberOfValidDataBytesThisMessage: Number, streamId: Number, dataByte00: Number, dataByte01: Number, dataByte02: Number, dataByte03: Number, dataByte04: Number, dataByte05: Number, dataByte06: Number, dataByte07: Number, dataByte08: Number, dataByte09: Number, dataByte10: Number, dataByte11: Number, dataByte12: Number): MidiMessage128; + + + static buildMixedDataSetChunkHeaderMessage(timestamp: Number, group: MidiGroup, mdsId: Number, numberValidDataBytesInThisChunk: Number, numberChunksInMixedDataSet: Number, numberOfThisChunk: Number, manufacturerId: Number, deviceId: Number, subId1: Number, subId2: Number): MidiMessage128; + + + static buildMixedDataSetChunkDataMessage(timestamp: Number, group: MidiGroup, mdsId: Number, dataByte00: Number, dataByte01: Number, dataByte02: Number, dataByte03: Number, dataByte04: Number, dataByte05: Number, dataByte06: Number, dataByte07: Number, dataByte08: Number, dataByte09: Number, dataByte10: Number, dataByte11: Number, dataByte12: Number, dataByte13: Number): MidiMessage128; + + + static buildFlexDataMessage(timestamp: Number, group: MidiGroup, form: Number, address: Number, channel: MidiChannel, statusBank: Number, status: Number, word1Data: Number, word2Data: Number, word3Data: Number): MidiMessage128; + + + static buildStreamMessage(timestamp: Number, form: Number, status: Number, word0RemainingData: Number, word1Data: Number, word2Data: Number, word3Data: Number): MidiMessage128; + + + } + + export class MidiMessageConverter { + constructor(); + + static convertMidi1Message(timestamp: Number, group: MidiGroup, statusByte: Number): MidiMessage32; + static convertMidi1Message(timestamp: Number, group: MidiGroup, statusByte: Number, dataByte1: Number): MidiMessage32; + static convertMidi1Message(timestamp: Number, group: MidiGroup, statusByte: Number, dataByte1: Number, dataByte2: Number): MidiMessage32; + + + static convertMidi1ChannelPressureMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1NoteOffMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1NoteOnMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1PitchBendChangeMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1PolyphonicKeyPressureMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1ProgramChangeMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1TimeCodeMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1SongPositionPointerMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1SongSelectMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1TuneRequestMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1TimingClockMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1StartMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1ContinueMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1StopMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1ActiveSensingMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + static convertMidi1SystemResetMessage(timestamp: Number, group: MidiGroup, originalMessage: Object): MidiMessage32; + + + } + + export class MidiMessageReceivedEventArgs { + messageType: MidiMessageType; + packetType: MidiPacketType; + timestamp: Number; + constructor(); + + peekFirstWord(): Number; + + getMessagePacket(): IMidiUniversalPacket; + + fillWords(word0: Number, word1: Number, word2: Number, word3: Number): Number; + + fillMessageStruct(message: MidiMessageStruct): Number; + + fillMessage32(message: MidiMessage32): Boolean; + + fillMessage64(message: MidiMessage64): Boolean; + + fillMessage96(message: MidiMessage96): Boolean; + + fillMessage128(message: MidiMessage128): Boolean; + + fillWordArray(); + fillByteArray(); + fillBuffer(byteOffset: Number, buffer: Object): Number; + + appendWordsToList(wordList: Object): Number; + + } + + export class MidiMessageTypeEndpointListener { + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + preventFiringMainMessageReceivedEvent: Boolean; + preventCallingFurtherListeners: Boolean; + includeMessageTypes: Object; + constructor(); + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + removeListener(type: "MessageReceived", listener: (ev: Event) => void): void ; + on(type: "MessageReceived", listener: (ev: Event) => void): void ; + off(type: "MessageReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiMessageUtility { + constructor(); + + static validateMessage32MessageType(word0: Number): Boolean; + + + static validateMessage64MessageType(word0: Number): Boolean; + + + static validateMessage96MessageType(word0: Number): Boolean; + + + static validateMessage128MessageType(word0: Number): Boolean; + + + static getMessageTypeFromMessageFirstWord(word0: Number): MidiMessageType; + + + static getPacketTypeFromMessageFirstWord(word0: Number): MidiPacketType; + + + static messageTypeHasGroupField(messageType: MidiMessageType): Boolean; + + + static replaceGroupInMessageFirstWord(word0: Number, newGroup: MidiGroup): Number; + + + static getGroupFromMessageFirstWord(word0: Number): MidiGroup; + + + static getStatusFromUtilityMessage(word0: Number): Number; + + + static getStatusFromMidi1ChannelVoiceMessage(word0: Number): Midi1ChannelVoiceMessageStatus; + + + static getStatusFromMidi2ChannelVoiceMessageFirstWord(word0: Number): Midi2ChannelVoiceMessageStatus; + + + static getStatusBankFromFlexDataMessageFirstWord(word0: Number): Number; + + + static getStatusFromFlexDataMessageFirstWord(word0: Number): Number; + + + static getStatusFromSystemCommonMessage(word0: Number): Number; + + + static getStatusFromDataMessage64FirstWord(word0: Number): Number; + + + static getNumberOfBytesFromDataMessage64FirstWord(word0: Number): Number; + + + static getStatusFromDataMessage128FirstWord(word0: Number): Number; + + + static getNumberOfBytesFromDataMessage128FirstWord(word0: Number): Number; + + + static messageTypeHasChannelField(messageType: MidiMessageType): Boolean; + + + static replaceChannelInMessageFirstWord(word0: Number, newChannel: MidiChannel): Number; + + + static getChannelFromMessageFirstWord(word0: Number): MidiChannel; + + + static getFormFromStreamMessageFirstWord(word0: Number): Number; + + + static getStatusFromStreamMessageFirstWord(word0: Number): Number; + + + static getMessageFriendlyNameFromFirstWord(word0: Number): String; + + + static getPacketListFromWordList(timestamp: Number, words: Object): Object; + + + static getWordListFromPacketList(words: Object): Object; + + + } + + export class MidiService { + constructor(); + + static pingService(pingCount: Number): MidiServicePingResponseSummary; + static pingService(pingCount: Number, timeoutMilliseconds: Number): MidiServicePingResponseSummary; + + + static getInstalledTransportPlugins(): Object; + + + static getInstalledMessageProcessingPlugins(): Object; + + + static getActiveSessions(): Object; + + + static createTemporaryLoopbackEndpoints(associationId: String, endpointDefinitionA: MidiServiceLoopbackEndpointDefinition, endpointDefinitionB: MidiServiceLoopbackEndpointDefinition): MidiServiceLoopbackEndpointCreationResult; + + + static removeTemporaryLoopbackEndpoints(associationId: String): Boolean; + + + static updateTransportPluginConfiguration(configurationUpdate: IMidiServiceTransportPluginConfiguration): MidiServiceConfigurationResponse; + + + static updateProcessingPluginConfiguration(configurationUpdate: IMidiServiceMessageProcessingPluginConfiguration): MidiServiceConfigurationResponse; + + + } + + export class MidiServiceConfigurationResponse { + responseJson: String; + status: MidiServiceConfigurationResponseStatus; + constructor(); + + } + + export class MidiServiceLoopbackEndpointCreationResult { + associationId: String; + endpointDeviceIdA: String; + endpointDeviceIdB: String; + success: Boolean; + constructor(); + + } + + export class MidiServiceLoopbackEndpointDefinition { + uniqueId: String; + name: String; + description: String; + constructor(); + + } + + export class MidiServiceMessageProcessingPluginInfo { + author: String; + clientConfigurationAssemblyName: String; + description: String; + id: String; + isClientConfigurable: Boolean; + isSystemManaged: Boolean; + name: String; + smallImagePath: String; + supportsMultipleInstancesPerDevice: Boolean; + version: String; + constructor(); + + } + + export class MidiServicePingResponse { + clientDeltaTimestamp: Number; + clientReceiveMidiTimestamp: Number; + clientSendMidiTimestamp: Number; + index: Number; + serviceReportedMidiTimestamp: Number; + sourceId: Number; + constructor(); + + } + + export class MidiServicePingResponseSummary { + averagePingRoundTripMidiClock: Number; + failureReason: String; + responses: Object; + success: Boolean; + totalPingRoundTripMidiClock: Number; + constructor(); + + } + + export class MidiServiceSessionConnectionInfo { + earliestConnectionTime: Date; + endpointDeviceId: String; + instanceCount: Number; + constructor(); + + } + + export class MidiServiceSessionInfo { + connections: Object; + processId: Number; + processName: String; + sessionId: String; + sessionName: String; + startTime: Date; + constructor(); + + } + + export class MidiServiceTransportPluginInfo { + author: String; + clientConfigurationAssemblyName: String; + description: String; + id: String; + isClientConfigurable: Boolean; + isRuntimeCreatableByApps: Boolean; + isRuntimeCreatableBySettings: Boolean; + isSystemManaged: Boolean; + mnemonic: String; + name: String; + smallImagePath: String; + version: String; + constructor(); + + } + + export class MidiSession { + connections: Object; + id: String; + isOpen: Boolean; + name: String; + settings: MidiSessionSettings; + constructor(); + + static createSession(sessionName: String): MidiSession; + static createSession(sessionName: String, settings: MidiSessionSettings): MidiSession; + + + createEndpointConnection(endpointDeviceId: String): MidiEndpointConnection; + createEndpointConnection(endpointDeviceId: String, settings: IMidiEndpointConnectionSettings): MidiEndpointConnection; + + createVirtualDeviceAndConnection(deviceDefinition: MidiVirtualEndpointDeviceDefinition): MidiEndpointConnection; + + disconnectEndpointConnection(endpointConnectionId: String): void; + + updateName(newName: String): Boolean; + + close(): void; + } + + export class MidiSessionSettings { + useMmcssThreads: Boolean; + constructor(); + + } + + export class MidiStreamConfigurationRequestReceivedEventArgs { + preferredMidiProtocol: MidiProtocol; + requestEndpointReceiveJitterReductionTimestamps: Boolean; + requestEndpointTransmitJitterReductionTimestamps: Boolean; + timestamp: Number; + constructor(); + + } + + export class MidiStreamConfigurationRequestedSettings { + specificationVersionMinor: Number; + specificationVersionMajor: Number; + requestEndpointTransmitJitterReductionTimestamps: Boolean; + requestEndpointReceiveJitterReductionTimestamps: Boolean; + preferredMidiProtocol: MidiProtocol; + constructor(); + + } + + export class MidiStreamMessageBuilder { + constructor(); + + static buildEndpointDiscoveryMessage(timestamp: Number, umpVersionMajor: Number, umpVersionMinor: Number, requestFlags: MidiEndpointDiscoveryRequests): IMidiUniversalPacket; + + + static buildEndpointInfoNotificationMessage(timestamp: Number, umpVersionMajor: Number, umpVersionMinor: Number, hasStaticFunctionBlocks: Boolean, numberOfFunctionBlocks: Number, supportsMidi20Protocol: Boolean, supportsMidi10Protocol: Boolean, supportsReceivingJitterReductionTimestamps: Boolean, supportsSendingJitterReductionTimestamps: Boolean): IMidiUniversalPacket; + + + static buildDeviceIdentityNotificationMessage(timestamp: Number, deviceManufacturerSysExIdByte1: Number, deviceManufacturerSysExIdByte2: Number, deviceManufacturerSysExIdByte3: Number, deviceFamilyLsb: Number, deviceFamilyMsb: Number, deviceFamilyModelNumberLsb: Number, deviceFamilyModelNumberMsb: Number, softwareRevisionLevelByte1: Number, softwareRevisionLevelByte2: Number, softwareRevisionLevelByte3: Number, softwareRevisionLevelByte4: Number): IMidiUniversalPacket; + + + static buildEndpointNameNotificationMessages(timestamp: Number, name: String): Object; + + + static buildProductInstanceIdNotificationMessages(timestamp: Number, productInstanceId: String): Object; + + + static parseEndpointNameNotificationMessages(messages: Object): String; + + + static parseProductInstanceIdNotificationMessages(messages: Object): String; + + + static buildStreamConfigurationRequestMessage(timestamp: Number, protocol: Number, expectToReceiveJRTimestamps: Boolean, requestToSendJRTimestamps: Boolean): IMidiUniversalPacket; + + + static buildStreamConfigurationNotificationMessage(timestamp: Number, protocol: Number, confirmationWillReceiveJRTimestamps: Boolean, confirmationSendJRTimestamps: Boolean): IMidiUniversalPacket; + + + static buildFunctionBlockDiscoveryMessage(timestamp: Number, functionBlockNumber: Number, requestFlags: MidiFunctionBlockDiscoveryRequests): IMidiUniversalPacket; + + + static buildFunctionBlockInfoNotificationMessage(timestamp: Number, active: Boolean, functionBlockNumber: Number, uiHint: MidiFunctionBlockUIHint, midi10: MidiFunctionBlockMidi10, direction: MidiFunctionBlockDirection, firstGroup: Number, numberOfGroups: Number, midiCIVersionFormat: Number, maxNumberSysEx8Streams: Number): IMidiUniversalPacket; + + + static buildFunctionBlockNameNotificationMessages(timestamp: Number, functionBlockNumber: Number, name: String): Object; + + + static parseFunctionBlockNameNotificationMessages(messages: Object): String; + + + } + + export class MidiUniqueId { + static labelFull: String; + static labelShort: String; + byte4: Number; + byte3: Number; + byte2: Number; + byte1: Number; + asCombined28BitValue: Number; + isBroadcast: Boolean; + isReserved: Boolean; + constructor(); + constructor(combined28BitValue: Number); + constructor(sevenBitByte1: Number, sevenBitByte2: Number, sevenBitByte3: Number, sevenBitByte4: Number); + + static createBroadcast(): MidiUniqueId; + + + static createRandom(): MidiUniqueId; + + + } + + export class MidiVirtualEndpointDevice { + tag: Object; + name: String; + isEnabled: Boolean; + id: String; + suppressHandledMessages: Boolean; + deviceDefinition: MidiVirtualEndpointDeviceDefinition; + functionBlocks: Object; + constructor(); + + updateFunctionBlock(block: MidiFunctionBlock): void; + + updateEndpointName(name: String): void; + + initialize(endpointConnection: IMidiEndpointConnectionSource): void; + + onEndpointConnectionOpened(): void; + + processIncomingMessage(args: MidiMessageReceivedEventArgs, skipFurtherListeners: Boolean, skipMainMessageReceivedEvent: Boolean): void; + + cleanup(): void; + + addListener(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + removeListener(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + on(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + off(type: "StreamConfigurationRequestReceived", listener: (ev: Event) => void): void ; + + addListener(type: string, listener: (ev: Event) => void): void ; + removeListener(type: string, listener: (ev: Event) => void): void ; + on(type: string, listener: (ev: Event) => void): void ; + off(type: string, listener: (ev: Event) => void): void ; + + + } + + export class MidiVirtualEndpointDeviceDefinition { + transportSuppliedDescription: String; + supportsSendingJRTimestamps: Boolean; + supportsReceivingJRTimestamps: Boolean; + supportsMidi2ProtocolMessages: Boolean; + supportsMidi1ProtocolMessages: Boolean; + endpointProductInstanceId: String; + endpointName: String; + deviceFamilyMsb: Number; + deviceFamilyModelMsb: Number; + deviceFamilyModelLsb: Number; + deviceFamilyLsb: Number; + areFunctionBlocksStatic: Boolean; + deviceManufacturerSystemExclusiveId: Object; + functionBlocks: Object; + softwareRevisionLevel: Object; + constructor(); + + } + +} + + + diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/lib/main.js b/build/electron-projection/projection3_backup/windows.devices.midi2/lib/main.js new file mode 100644 index 000000000..ed1f5c4e9 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/lib/main.js @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation, Nadav Bar, and Felix Rieseberg +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing permissions +// and limitations under the License. + +const path = require('path'); +const fs = require('fs'); + +const npmScope = ''; + +// This little trick makes Node.js Tools for VS load IntelliSense for the module +if (fs.existsSync(path.join(__dirname, 'NodeRT_Windows_Devices_Midi2.d.js)'))) { + module.exports = require('./NodeRT_Windows_Devices_Midi2.d.js'); +} else { + module.exports = require('../build/Release/binding.node'); +} + +var externalReferencedNamespaces = ['Windows.Data.Json', 'Windows.Foundation', 'Windows.Devices.Enumeration', 'Windows.Devices.Midi']; + +if (externalReferencedNamespaces.length > 0) { + var namespaceRegistry = global.__winRtNamespaces__; + + if (!namespaceRegistry) { + namespaceRegistry = {}; + + Object.defineProperty(global, '__winRtNamespaces__', { + configurable: true, + writable: false, + enumerable: false, + value: namespaceRegistry + }); + } + + function requireNamespace(namespace) { + var moduleName = namespace.toLowerCase(); + + if (npmScope) { + moduleName = '@' + npmScope + '/' + moduleName; + } + + var m = require(moduleName); + delete namespaceRegistry[namespace]; + namespaceRegistry[namespace] = m; + return m; + } + + for (var i in externalReferencedNamespaces) { + var ns = externalReferencedNamespaces[i]; + + if (!namespaceRegistry.hasOwnProperty(ns)) { + Object.defineProperty(namespaceRegistry, ns, { + configurable: true, + enumerable: true, + get: requireNamespace.bind(null, ns) + }); + } + } +} diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/node-async.h b/build/electron-projection/projection3_backup/windows.devices.midi2/node-async.h new file mode 100644 index 000000000..1b57fd458 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/node-async.h @@ -0,0 +1,379 @@ +// Copyright (c) The NodeRT Contributors +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the ""License""); you may +// not use this file except in compliance with the License. You may obtain a +// copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY +// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +// MERCHANTABLITY OR NON-INFRINGEMENT. +// +// See the Apache Version 2.0 License for specific language governing +// permissions and limitations under the License. + +#pragma once + +#include +#include "nan.h" + +#include +#include +#include + +#if NAUV_UVVERSION < 0x000b17 +#define NODEASYNC_ASYNC_WORK_CB(func) \ + static void __cdecl func(uv_async_t* handle, int) +#define NODEASYNC_IDLE_WORK_CB(func) \ + static void __cdecl func(uv_idle_t* handle, int) +#else +#define NODEASYNC_ASYNC_WORK_CB(func) \ + static void __cdecl func(uv_async_t* handle) +#define NODEASYNC_IDLE_WORK_CB(func) static void __cdecl func(uv_idle_t* handle) +#endif + +namespace NodeUtils { +using Nan::EscapableHandleScope; +using Nan::GetCurrentContext; +using Nan::HandleScope; +using Nan::New; +using Nan::Null; +using Nan::Persistent; +using Nan::Undefined; +using v8::Exception; +using v8::Function; +using v8::Integer; +using v8::Local; +using v8::Object; +using v8::String; +using v8::Value; + +typedef std::function*)> InvokeCallbackDelegate; + +class Async { + public: + template + struct Baton { + int error_code; + std::wstring error_message; + + // Custom data + std::shared_ptr data; + std::shared_ptr result; + std::shared_ptr> callback_args; + unsigned callback_args_size; + + Baton() { callback_args_size = 0; } + + void setCallbackArgs(Local* argv, int argc) { + HandleScope scope; + + callback_info.reset(new Persistent[argc], + [](Persistent* ptr) { delete[] ptr; }); + + callback_args_size = 0; + + for (int i = 0; i < argc; i++) { + // callback_info.get()[i] = argv[i]; + callback_info.get()[i].Reset(argv[i]); + } + } + + virtual ~Baton() { + for (int i = 0; i < callback_args_size; i++) { + callback_info.get()[i].Reset(); + } + } + + private: + uv_work_t request; + std::function doWork; + std::function afterWork; + Nan::Persistent callbackData; + + friend Async; + }; + + private: + class TokenData { + public: + static uv_async_t* NewAsyncToken() { + uv_async_t* asyncHandle = new uv_async_t; + uv_async_init(uv_default_loop(), asyncHandle, AsyncCb); + SetHandleData(asyncHandle->data); + + return asyncHandle; + } + + static uv_async_t* NewAsyncToken(Local callback, + Local receiver) { + uv_async_t* asyncHandle = NewAsyncToken(); + SetHandleCallbackData(asyncHandle->data, callback, receiver); + + return asyncHandle; + } + + static uv_idle_t* NewIdleToken() { + uv_idle_t* idleHandle = new uv_idle_t; + uv_idle_init(uv_default_loop(), idleHandle); + + SetHandleData(idleHandle->data); + return idleHandle; + } + + static uv_idle_t* NewIdleToken(Local callback, + Local receiver) { + uv_idle_t* idleHandle = NewIdleToken(); + SetHandleCallbackData(idleHandle->data, callback, receiver); + + return idleHandle; + } + + virtual ~TokenData() { callbackData.Reset(); } + + private: + static void SetHandleData(void*& handleData) { + handleData = new TokenData(); + } + + static void SetHandleCallbackData(void* handleData, + Local callback, + Local receiver) { + TokenData* Token = static_cast(handleData); + Token->callbackData.Reset(CreateCallbackData(callback, receiver)); + } + + TokenData() {} + + Persistent callbackData; + std::function func; + + friend Async; + }; + + public: + template + static void __cdecl Run( + std::shared_ptr input, + std::function*)> doWork, + std::function*)> afterWork, + Local callback, + Local receiver = Local()) { + HandleScope scope; + Local callbackData = CreateCallbackData(callback, receiver); + + Baton* baton = new Baton(); + baton->request.data = baton; + baton->callbackData.Reset(callbackData); + baton->error_code = 0; + baton->data = input; + baton->doWork = doWork; + baton->afterWork = afterWork; + + uv_queue_work(uv_default_loop(), &baton->request, + AsyncWork, AsyncAfter); + } + + static uv_async_t* __cdecl GetAsyncToken() { + return TokenData::NewAsyncToken(); + } + + static uv_async_t* __cdecl GetAsyncToken( + Local callback, + Local receiver = Local()) { + return TokenData::NewAsyncToken(callback, receiver); + } + + static uv_idle_t* __cdecl GetIdleToken() { return TokenData::NewIdleToken(); } + + static uv_idle_t* __cdecl GetIdleToken( + Local callback, + Local receiver = Local()) { + return TokenData::NewIdleToken(callback, receiver); + } + + static void __cdecl RunOnMain(uv_async_t* async, std::function func) { + TokenData* Token = static_cast(async->data); + Token->func = func; + uv_async_send(async); + } + + static void __cdecl RunOnMain(std::function func) { + uv_async_t* async = GetAsyncToken(); + RunOnMain(async, func); + } + + static void __cdecl RunCallbackOnMain( + uv_async_t* async, + std::function func) { + TokenData* Token = static_cast(async->data); + + InvokeCallbackDelegate invokeCallback = [Token](int argc, + Local* argv) { + if (!Token->callbackData.IsEmpty()) { + Nan::AsyncResource asyncResource(Nan::New("RunCallbackOnMain").ToLocalChecked()); + asyncResource.runInAsyncScope(New(Token->callbackData), + New("callback").ToLocalChecked(), argc, argv); + } + }; + + std::function wrapper = [func, invokeCallback]() { + HandleScope scope; + func(invokeCallback); + }; + + RunOnMain(async, wrapper); + } + + // defers execution of the provided function by creating an idler + // that means, the function will be invoked once the event loop has delivered + // all pending events. + static void __cdecl NextTick(std::function func) { + uv_idle_t* idler = GetIdleToken(); + NextTick(idler, func); + } + + static void __cdecl NextTick(uv_idle_t* idler, std::function func) { + TokenData* Token = static_cast(idler->data); + Token->func = func; + + uv_idle_start(idler, onNextTick); + } + + static void __cdecl RunCallbackOnNextTick( + uv_idle_t* idler, + std::function func) { + TokenData* Token = static_cast(idler->data); + + InvokeCallbackDelegate invokeCallback = [Token](int argc, + Local* argv) { + if (!Token->callbackData.IsEmpty()) { + Nan::AsyncResource asyncResource(Nan::New("RunCallbackOnNextTick").ToLocalChecked()); + asyncResource.runInAsyncScope(New(Token->callbackData), + New("callback").ToLocalChecked(), argc, argv); + } + }; + + std::function wrapper = [func, invokeCallback]() { + HandleScope scope; + func(invokeCallback); + }; + + NextTick(idler, wrapper); + } + + private: + static Local CreateCallbackData(Local callback, + Local receiver) { + EscapableHandleScope scope; + + Local callbackData; + if (!callback.IsEmpty() && !callback->Equals(Nan::GetCurrentContext(), Undefined()).FromMaybe(true)) { + callbackData = New(); + + if (!receiver.IsEmpty()) { + Nan::SetPrototype(callbackData, receiver); + } + + Nan::Set(callbackData, New("callback").ToLocalChecked(), + callback); + + // get the current domain: + Local currentDomain = Undefined(); + + Local process = + Nan::To(Nan::Get(GetCurrentContext()->Global(), + New("process").ToLocalChecked()) + .ToLocalChecked()) + .ToLocalChecked(); + if (!process->Equals(Nan::GetCurrentContext(), Undefined()).FromMaybe(true)) { + currentDomain = process->Get(Nan::GetCurrentContext(), New("domain").ToLocalChecked()).ToLocalChecked(); + } + + Nan::Set(callbackData, New("domain").ToLocalChecked(), + currentDomain); + } + + return scope.Escape(callbackData); + }; + + template + static void __cdecl AsyncWork(uv_work_t* req) { + // No HandleScope! + + Baton* baton = + static_cast*>(req->data); + + // Do work in threadpool here. + // Set baton->error_code/message on failures. + // Set baton->result with a final result object + baton->doWork(baton); + } + + template + static void __cdecl AsyncAfter(uv_work_t* req, int status) { + HandleScope scope; + ; + Baton* baton = + static_cast*>(req->data); + + // typical AfterWorkFunc implementation + // if (baton->error) + //{ + // Local err = Exception::Error(...); + // Local argv[] = { err }; + // baton->setCallbackArgs(argv, _countof(argv)); + //} + // else + //{ + // Local argv[] = { Undefined(), ... }; + // baton->setCallbackArgs(argv, _countof(argv)); + //} + + baton->afterWork(baton); + + if (!baton->callbackData.IsEmpty()) { + // call the callback, using domains and all + int argc = static_cast(baton->callback_args_size); + std::unique_ptr> handlesArr(new Local[argc]); + for (int i = 0; i < argc; i++) { + handlesArr.get()[i] = New(baton->callback_info.get()[i]); + } + + Nan::AsyncResource asyncResource(Nan::New("AsyncAfter").ToLocalChecked()); + asyncResource.callInAsyncScope(New(baton->callbackData), + New("callback").ToLocalChecked(), argc, + handlesArr.get()); + } + + baton->callbackData.Reset(); + delete baton; + } + + // called after the async handle is closed in order to free it's memory + static void __cdecl AyncCloseCb(uv_handle_t* handle) { + if (handle != nullptr) { + uv_async_t* async = reinterpret_cast(handle); + delete async; + } + } + + // Called by run on main in case we are not running on the main thread + NODEASYNC_ASYNC_WORK_CB(AsyncCb) { + auto Token = static_cast(handle->data); + Token->func(); + uv_close((uv_handle_t*)handle, AyncCloseCb); + delete Token; + } + + NODEASYNC_IDLE_WORK_CB(onNextTick) { + std::function* func = + static_cast*>(handle->data); + (*func)(); + delete func; + uv_idle_stop(handle); + delete handle; + } +}; +} // namespace NodeUtils diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.data.json-0.1.6.tgz b/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.data.json-0.1.6.tgz new file mode 100644 index 000000000..43db11595 Binary files /dev/null and b/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.data.json-0.1.6.tgz differ diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.devices.enumeration-0.1.6.tgz b/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.devices.enumeration-0.1.6.tgz new file mode 100644 index 000000000..77a2f3e0b Binary files /dev/null and b/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.devices.enumeration-0.1.6.tgz differ diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.devices.midi-0.1.6.tgz b/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.devices.midi-0.1.6.tgz new file mode 100644 index 000000000..0f19d8770 Binary files /dev/null and b/build/electron-projection/projection3_backup/windows.devices.midi2/nodert-win11-windows.devices.midi-0.1.6.tgz differ diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/package-lock.json b/build/electron-projection/projection3_backup/windows.devices.midi2/package-lock.json new file mode 100644 index 000000000..6da549173 --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/package-lock.json @@ -0,0 +1,2508 @@ +{ + "name": "windows.devices.midi2", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "windows.devices.midi2", + "version": "0.1.0", + "license": "Apache-2.0", + "dependencies": { + "nan": "latest" + }, + "devDependencies": { + "@electron/rebuild": "^3.6.0", + "electron": "^29.1.0" + } + }, + "node_modules/@electron/get": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.3.tgz", + "integrity": "sha512-Qkzpg2s9GnVV2I2BjRksUi43U5e6+zaQMcjoJy0C+C5oxaKl+fmckGDQFtRpZpZV0NQekuZZ+tGz7EA9TVnQtQ==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "env-paths": "^2.2.0", + "fs-extra": "^8.1.0", + "got": "^11.8.5", + "progress": "^2.0.3", + "semver": "^6.2.0", + "sumchecker": "^3.0.1" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "global-agent": "^3.0.0" + } + }, + "node_modules/@electron/rebuild": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@electron/rebuild/-/rebuild-3.6.0.tgz", + "integrity": "sha512-zF4x3QupRU3uNGaP5X1wjpmcjfw1H87kyqZ00Tc3HvriV+4gmOGuvQjGNkrJuXdsApssdNyVwLsy+TaeTGGcVw==", + "dev": true, + "dependencies": { + "@malept/cross-spawn-promise": "^2.0.0", + "chalk": "^4.0.0", + "debug": "^4.1.1", + "detect-libc": "^2.0.1", + "fs-extra": "^10.0.0", + "got": "^11.7.0", + "node-abi": "^3.45.0", + "node-api-version": "^0.2.0", + "node-gyp": "^9.0.0", + "ora": "^5.1.0", + "read-binary-file-arch": "^1.0.6", + "semver": "^7.3.5", + "tar": "^6.0.5", + "yargs": "^17.0.1" + }, + "bin": { + "electron-rebuild": "lib/cli.js" + }, + "engines": { + "node": ">=12.13.0" + } + }, + "node_modules/@electron/rebuild/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@electron/rebuild/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/@electron/rebuild/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@electron/rebuild/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/@gar/promisify": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", + "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", + "dev": true + }, + "node_modules/@malept/cross-spawn-promise": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", + "integrity": "sha512-1DpKU0Z5ThltBwjNySMC14g0CkbyhCaz9FkhxqNsZI6uAPJXFS8cMXlBKo26FJ8ZuW6S9GCMcR9IO5k2X5/9Fg==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/malept" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/npm-.malept-cross-spawn-promise?utm_medium=referral&utm_source=npm_fund" + } + ], + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/@npmcli/fs": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-2.1.2.tgz", + "integrity": "sha512-yOJKRvohFOaLqipNtwYB9WugyZKhC/DZC4VYPmpaCzDBrA8YpK3qHZ8/HGscMnE4GqbkLNuVcCnxkeQEdGt6LQ==", + "dev": true, + "dependencies": { + "@gar/promisify": "^1.1.3", + "semver": "^7.3.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@npmcli/fs/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@npmcli/move-file": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/move-file/-/move-file-2.0.1.tgz", + "integrity": "sha512-mJd2Z5TjYWq/ttPLLGqArdtnC74J6bOzg4rMDnN+p1xTacZ2yPRCk2y0oSWQtygLR9YVQXgOcONrwtnk3JupxQ==", + "deprecated": "This functionality has been moved to @npmcli/fs", + "dev": true, + "dependencies": { + "mkdirp": "^1.0.4", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@sindresorhus/is": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", + "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@szmarczak/http-timer": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "dev": true, + "dependencies": { + "defer-to-connect": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@tootallnate/once": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", + "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@types/cacheable-request": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", + "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", + "dev": true, + "dependencies": { + "@types/http-cache-semantics": "*", + "@types/keyv": "^3.1.4", + "@types/node": "*", + "@types/responselike": "^1.0.0" + } + }, + "node_modules/@types/http-cache-semantics": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", + "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==", + "dev": true + }, + "node_modules/@types/keyv": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", + "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "20.11.25", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.25.tgz", + "integrity": "sha512-TBHyJxk2b7HceLVGFcpAUjsa5zIdsPWlR6XHfyGzd0SFu+/NFgQgMAl96MSDZgQDvJAvV6BKsFOrt6zIL09JDw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/responselike": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", + "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/yauzl": { + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", + "integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==", + "dev": true, + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dev": true, + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "dependencies": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "dev": true + }, + "node_modules/are-we-there-yet": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", + "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", + "dev": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/boolean": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz", + "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==", + "dev": true, + "optional": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/cacache": { + "version": "16.1.3", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-16.1.3.tgz", + "integrity": "sha512-/+Emcj9DAXxX4cwlLmRI9c166RuL3w30zp4R7Joiv2cQTtTtA+jeuCAjH3ZlGnYS3tKENSrKhAzVVP9GVyzeYQ==", + "dev": true, + "dependencies": { + "@npmcli/fs": "^2.1.0", + "@npmcli/move-file": "^2.0.0", + "chownr": "^2.0.0", + "fs-minipass": "^2.1.0", + "glob": "^8.0.1", + "infer-owner": "^1.0.4", + "lru-cache": "^7.7.1", + "minipass": "^3.1.6", + "minipass-collect": "^1.0.2", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.4", + "mkdirp": "^1.0.4", + "p-map": "^4.0.0", + "promise-inflight": "^1.0.1", + "rimraf": "^3.0.2", + "ssri": "^9.0.0", + "tar": "^6.1.11", + "unique-filename": "^2.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/cacache/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/cacache/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/cacache/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/cacache/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/cacheable-lookup": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", + "dev": true, + "engines": { + "node": ">=10.6.0" + } + }, + "node_modules/cacheable-request": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", + "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", + "dev": true, + "dependencies": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^4.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^6.0.1", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/clone-response": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", + "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", + "dev": true, + "dependencies": { + "mimic-response": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true, + "bin": { + "color-support": "bin.js" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dev": true, + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/decompress-response/node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dev": true, + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "optional": true, + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "optional": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", + "dev": true + }, + "node_modules/detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/detect-node": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", + "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==", + "dev": true, + "optional": true + }, + "node_modules/electron": { + "version": "29.1.0", + "resolved": "https://registry.npmjs.org/electron/-/electron-29.1.0.tgz", + "integrity": "sha512-giJVIm0sWVp+8V1GXrKqKTb+h7no0P3ooYqEd34AD9wMJzGnAeL+usj+R0155/0pdvvP1mgydnA7lcaFA2M9lw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@electron/get": "^2.0.0", + "@types/node": "^20.9.0", + "extract-zip": "^2.0.1" + }, + "bin": { + "electron": "cli.js" + }, + "engines": { + "node": ">= 12.20.55" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, + "optional": true, + "dependencies": { + "iconv-lite": "^0.6.2" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/err-code": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", + "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", + "dev": true + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dev": true, + "optional": true, + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true, + "optional": true + }, + "node_modules/escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "optional": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/exponential-backoff": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", + "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==", + "dev": true + }, + "node_modules/extract-zip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", + "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "get-stream": "^5.1.0", + "yauzl": "^2.10.0" + }, + "bin": { + "extract-zip": "cli.js" + }, + "engines": { + "node": ">= 10.17.0" + }, + "optionalDependencies": { + "@types/yauzl": "^2.9.1" + } + }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "optional": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gauge": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", + "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", + "dev": true, + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.3", + "console-control-strings": "^1.1.0", + "has-unicode": "^2.0.1", + "signal-exit": "^3.0.7", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dev": true, + "optional": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/global-agent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz", + "integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==", + "dev": true, + "optional": true, + "dependencies": { + "boolean": "^3.0.1", + "es6-error": "^4.1.1", + "matcher": "^3.0.0", + "roarr": "^2.15.3", + "semver": "^7.3.2", + "serialize-error": "^7.0.1" + }, + "engines": { + "node": ">=10.0" + } + }, + "node_modules/global-agent/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "optional": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dev": true, + "optional": true, + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "optional": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/got": { + "version": "11.8.6", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", + "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", + "dev": true, + "dependencies": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.2", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=10.19.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/got?sponsor=1" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "optional": true, + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==", + "dev": true + }, + "node_modules/hasown": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", + "dev": true, + "optional": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-cache-semantics": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", + "dev": true + }, + "node_modules/http-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", + "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", + "dev": true, + "dependencies": { + "@tootallnate/once": "2", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/http2-wrapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "dev": true, + "dependencies": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dev": true, + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dev": true, + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "optional": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/infer-owner": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", + "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dev": true, + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-lambda": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", + "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==", + "dev": true + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "dev": true, + "optional": true + }, + "node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-fetch-happen": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-10.2.1.tgz", + "integrity": "sha512-NgOPbRiaQM10DYXvN3/hhGVI2M5MtITFryzBGxHM5p4wnFxsVCbxkrBrDsk+EZ5OB4jEOT7AjDxtdF+KVEFT7w==", + "dev": true, + "dependencies": { + "agentkeepalive": "^4.2.1", + "cacache": "^16.1.0", + "http-cache-semantics": "^4.1.0", + "http-proxy-agent": "^5.0.0", + "https-proxy-agent": "^5.0.0", + "is-lambda": "^1.0.1", + "lru-cache": "^7.7.1", + "minipass": "^3.1.6", + "minipass-collect": "^1.0.2", + "minipass-fetch": "^2.0.3", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.4", + "negotiator": "^0.6.3", + "promise-retry": "^2.0.1", + "socks-proxy-agent": "^7.0.0", + "ssri": "^9.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/make-fetch-happen/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/matcher": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", + "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==", + "dev": true, + "optional": true, + "dependencies": { + "escape-string-regexp": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-collect": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/minipass-collect/-/minipass-collect-1.0.2.tgz", + "integrity": "sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minipass-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-2.1.2.tgz", + "integrity": "sha512-LT49Zi2/WMROHYoqGgdlQIZh8mLPZmOrN2NdJjMXxYe4nkN6FUyuPuOAOedNJDrx0IRGg9+4guZewtp8hE6TxA==", + "dev": true, + "dependencies": { + "minipass": "^3.1.6", + "minipass-sized": "^1.0.3", + "minizlib": "^2.1.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "optionalDependencies": { + "encoding": "^0.1.13" + } + }, + "node_modules/minipass-flush": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz", + "integrity": "sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minipass-pipeline": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz", + "integrity": "sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-sized": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/minipass-sized/-/minipass-sized-1.0.3.tgz", + "integrity": "sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/nan": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz", + "integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-abi": { + "version": "3.56.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.56.0.tgz", + "integrity": "sha512-fZjdhDOeRcaS+rcpve7XuwHBmktS1nS1gzgghwKUQQ8nTy2FdSDr6ZT8k6YhvlJeHmmQMYiT/IH9hfco5zeW2Q==", + "dev": true, + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-abi/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-api-version": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/node-api-version/-/node-api-version-0.2.0.tgz", + "integrity": "sha512-fthTTsi8CxaBXMaBAD7ST2uylwvsnYxh2PfaScwpMhos6KlSFajXQPcM4ogNE1q2s3Lbz9GCGqeIHC+C6OZnKg==", + "dev": true, + "dependencies": { + "semver": "^7.3.5" + } + }, + "node_modules/node-api-version/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-gyp": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-9.4.1.tgz", + "integrity": "sha512-OQkWKbjQKbGkMf/xqI1jjy3oCTgMKJac58G2+bjZb3fza6gW2YrCSdMQYaoTb70crvE//Gngr4f0AgVHmqHvBQ==", + "dev": true, + "dependencies": { + "env-paths": "^2.2.0", + "exponential-backoff": "^3.1.1", + "glob": "^7.1.4", + "graceful-fs": "^4.2.6", + "make-fetch-happen": "^10.0.3", + "nopt": "^6.0.0", + "npmlog": "^6.0.0", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.2", + "which": "^2.0.2" + }, + "bin": { + "node-gyp": "bin/node-gyp.js" + }, + "engines": { + "node": "^12.13 || ^14.13 || >=16" + } + }, + "node_modules/node-gyp/node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/nopt": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz", + "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==", + "dev": true, + "dependencies": { + "abbrev": "^1.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/normalize-url": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", + "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npmlog": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", + "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", + "dev": true, + "dependencies": { + "are-we-there-yet": "^3.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^4.0.3", + "set-blocking": "^2.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "optional": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dev": true, + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-cancelable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-map": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", + "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", + "dev": true, + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true + }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/promise-inflight": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", + "integrity": "sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==", + "dev": true + }, + "node_modules/promise-retry": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", + "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", + "dev": true, + "dependencies": { + "err-code": "^2.0.2", + "retry": "^0.12.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-binary-file-arch": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/read-binary-file-arch/-/read-binary-file-arch-1.0.6.tgz", + "integrity": "sha512-BNg9EN3DD3GsDXX7Aa8O4p92sryjkmzYYgmgTAc6CA4uGLEDzFfxOxugu21akOxpcXHiEgsYkC6nPsQvLLLmEg==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "bin": { + "read-binary-file-arch": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-alpn": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", + "dev": true + }, + "node_modules/responselike": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", + "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", + "dev": true, + "dependencies": { + "lowercase-keys": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/roarr": { + "version": "2.15.4", + "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz", + "integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==", + "dev": true, + "optional": true, + "dependencies": { + "boolean": "^3.0.1", + "detect-node": "^2.0.4", + "globalthis": "^1.0.1", + "json-stringify-safe": "^5.0.1", + "semver-compare": "^1.0.0", + "sprintf-js": "^1.1.2" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "optional": true + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", + "dev": true, + "optional": true + }, + "node_modules/serialize-error": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", + "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==", + "dev": true, + "optional": true, + "dependencies": { + "type-fest": "^0.13.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "dev": true, + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.1.tgz", + "integrity": "sha512-B6w7tkwNid7ToxjZ08rQMT8M9BJAf8DKx8Ft4NivzH0zBUfd6jldGcisJn/RLgxcX3FPNDdNQCUEMMT79b+oCQ==", + "dev": true, + "dependencies": { + "ip-address": "^9.0.5", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks-proxy-agent": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-7.0.0.tgz", + "integrity": "sha512-Fgl0YPZ902wEsAyiQ+idGd1A7rSFx/ayC1CQVMw5P+EQx2V0SgpGtf6OKFhVjPflPUl9YMmEOnmfjCdMUsygww==", + "dev": true, + "dependencies": { + "agent-base": "^6.0.2", + "debug": "^4.3.3", + "socks": "^2.6.2" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "dev": true + }, + "node_modules/ssri": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz", + "integrity": "sha512-o57Wcn66jMQvfHG1FlYbWeZWW/dHZhJXjpIcTfXldXEk5nz5lStPo3mK0OJQfGR3RbZUlbISexbljkJzuEj/8Q==", + "dev": true, + "dependencies": { + "minipass": "^3.1.1" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sumchecker": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", + "integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==", + "dev": true, + "dependencies": { + "debug": "^4.1.0" + }, + "engines": { + "node": ">= 8.0" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", + "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "dev": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tar/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/type-fest": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", + "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/unique-filename": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-2.0.1.tgz", + "integrity": "sha512-ODWHtkkdx3IAR+veKxFV+VBkUMcN+FaqzUUd7IZzt+0zhDZFPFxhlqwPF3YQvMHx1TD0tdgYl+kuPnJ8E6ql7A==", + "dev": true, + "dependencies": { + "unique-slug": "^3.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/unique-slug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-3.0.0.tgz", + "integrity": "sha512-8EyMynh679x/0gqE9fT9oilG+qEt+ibFyqjuVTsZn1+CMxH+XLlpvr2UZx4nVcCwTpx81nICr2JQFkM+HPLq4w==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dev": true, + "dependencies": { + "defaults": "^1.0.3" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } +} diff --git a/build/electron-projection/projection3_backup/windows.devices.midi2/package.json b/build/electron-projection/projection3_backup/windows.devices.midi2/package.json new file mode 100644 index 000000000..9bb8a21ce --- /dev/null +++ b/build/electron-projection/projection3_backup/windows.devices.midi2/package.json @@ -0,0 +1,102 @@ +{ + "name": "windows.devices.midi2", + "version": "0.1.0", + "description": "Use the Windows.Devices.Midi2 UWP API directly from Node.js", + "main": "lib/main.js", + "keywords": [ + "Windows.Devices.Midi2", + "Windows", + "Devices", + "Midi2", + "IMidiEndpointConnectionSettings", + "IMidiEndpointConnectionSource", + "IMidiEndpointMessageProcessingPlugin", + "IMidiMessageReceivedEventSource", + "IMidiServiceMessageProcessingPluginConfiguration", + "IMidiServiceTransportPluginConfiguration", + "IMidiUniversalPacket", + "MidiChannel", + "MidiChannelEndpointListener", + "MidiClock", + "MidiEndpointConnection", + "MidiEndpointDeviceInformation", + "MidiEndpointDeviceInformationAddedEventArgs", + "MidiEndpointDeviceInformationRemovedEventArgs", + "MidiEndpointDeviceInformationUpdatedEventArgs", + "MidiEndpointDeviceWatcher", + "MidiFunctionBlock", + "MidiGroup", + "MidiGroupEndpointListener", + "MidiGroupTerminalBlock", + "MidiMessage128", + "MidiMessage32", + "MidiMessage64", + "MidiMessage96", + "MidiMessageBuilder", + "MidiMessageConverter", + "MidiMessageReceivedEventArgs", + "MidiMessageTypeEndpointListener", + "MidiMessageUtility", + "MidiService", + "MidiServiceConfigurationResponse", + "MidiServiceLoopbackEndpointCreationResult", + "MidiServiceLoopbackEndpointDefinition", + "MidiServiceMessageProcessingPluginInfo", + "MidiServicePingResponse", + "MidiServicePingResponseSummary", + "MidiServiceSessionConnectionInfo", + "MidiServiceSessionInfo", + "MidiServiceTransportPluginInfo", + "MidiSession", + "MidiSessionSettings", + "MidiStreamConfigurationRequestReceivedEventArgs", + "MidiStreamConfigurationRequestedSettings", + "MidiStreamMessageBuilder", + "MidiUniqueId", + "MidiVirtualEndpointDevice", + "MidiVirtualEndpointDeviceDefinition", + "Midi1ChannelVoiceMessageStatus", + "Midi2ChannelVoiceMessageStatus", + "MidiEndpointDeviceInformationFilters", + "MidiEndpointDeviceInformationSortOrder", + "MidiEndpointDevicePurpose", + "MidiEndpointDiscoveryRequests", + "MidiEndpointNativeDataFormat", + "MidiFunctionBlockDirection", + "MidiFunctionBlockDiscoveryRequests", + "MidiFunctionBlockMidi10", + "MidiFunctionBlockUIHint", + "MidiGroupTerminalBlockDirection", + "MidiGroupTerminalBlockProtocol", + "MidiMessageType", + "MidiPacketType", + "MidiProtocol", + "MidiSendMessageResults", + "MidiServiceConfigurationResponseStatus", + "MidiSystemExclusive8Status", + "MidiMessageStruct", + "NodeRT", + "WinRT", + "Microsoft" + ], + "dependencies": { + "nan": "latest" + }, + "repository": { + "type": "git", + "url": "git://github.com/MaySoMusician/NodeRT.git" + }, + "homepage": "https://github.com/MaySoMusician/NodeRT/tree/feature/136-vs2019", + "author": "Generated by NodeRT (modified)", + "contributors": [ + "nadavbar (http://www.nadavos.com)", + "Felix Rieseberg (https://www.felix.fun)", + "MaySoMusician (https://msmsm.work/)" + ], + "gypfile": true, + "license": "Apache-2.0", + "devDependencies": { + "@electron/rebuild": "^3.6.0", + "electron": "^29.1.0" + } +} diff --git a/build/staging/version/BundleInfo.wxi b/build/staging/version/BundleInfo.wxi index da0383ac1..f6c1a3352 100644 --- a/build/staging/version/BundleInfo.wxi +++ b/build/staging/version/BundleInfo.wxi @@ -1,4 +1,4 @@ - +