MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / VectorWrapper

Class VectorWrapper

src/NodeRTLib/ProjectFiles/CollectionsWrap.h:724–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

722
723template <class T>
724class VectorWrapper : NodeRT::WrapperBase {
725 public:
726 static void Init() {
727 HandleScope scope;
728
729 Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
730 s_constructorTemplate.Reset(localRef);
731 localRef->SetClassName(
732 Nan::New<String>("Windows::Foundation::Collections:IVector")
733 .ToLocalChecked());
734 localRef->InstanceTemplate()->SetInternalFieldCount(1);
735 Nan::SetIndexedPropertyHandler(localRef->InstanceTemplate(), Get, Set);
736
737 Nan::SetPrototypeMethod(localRef, "getMany", GetMany);
738 Nan::SetPrototypeMethod(localRef, "getAt", GetAt);
739 Nan::SetPrototypeMethod(localRef, "indexOf", IndexOf);
740 Nan::SetPrototypeMethod(localRef, "first", First);
741 Nan::SetPrototypeMethod(localRef, "append", Append);
742 Nan::SetPrototypeMethod(localRef, "clear", Clear);
743 Nan::SetPrototypeMethod(localRef, "getView", GetView);
744 Nan::SetPrototypeMethod(localRef, "insertAt", InsertAt);
745 Nan::SetPrototypeMethod(localRef, "removeAt", RemoveAt);
746 Nan::SetPrototypeMethod(localRef, "removeAtEnd", RemoveAtEnd);
747 Nan::SetPrototypeMethod(localRef, "replaceAll", ReplaceAll);
748 Nan::SetPrototypeMethod(localRef, "setAt", SetAt);
749
750 Nan::SetAccessor(localRef->PrototypeTemplate(),
751 Nan::New<String>("size").ToLocalChecked(), SizeGetter);
752 Nan::SetAccessor(localRef->PrototypeTemplate(),
753 Nan::New<String>("length").ToLocalChecked(), SizeGetter);
754
755 return;
756 }
757
758 static Local<Value> CreateVectorWrapper(
759 ::Windows::Foundation::Collections::IVector<T> ^ winRtInstance,
760 const std::function<Local<Value>(T)>& getterFunc,
761 const std::function<bool(Local<Value>)>& checkTypeFunc = nullptr,
762 const std::function<T(Local<Value>)>& convertToTypeFunc = nullptr) {
763 EscapableHandleScope scope;
764 if (winRtInstance == nullptr) {
765 return scope.Escape(Undefined());
766 }
767
768 if (s_constructorTemplate.IsEmpty()) {
769 Init();
770 }
771
772 v8::Local<Value> args[] = {Undefined()};
773 Local<FunctionTemplate> localRef =
774 Nan::New<FunctionTemplate>(s_constructorTemplate);
775 Local<Object> objectInstance =
776 Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args)
777 .ToLocalChecked();
778 if (objectInstance.IsEmpty()) {
779 return scope.Escape(Undefined());
780 }
781

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected