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

Method IndexOf

src/NodeRTLib/ProjectFiles/CollectionsWrap.h:1175–1217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1173 }
1174
1175 static void IndexOf(Nan::NAN_METHOD_ARGS_TYPE info) {
1176 HandleScope scope;
1177
1178 if (!NodeRT::Utils::IsWinRtWrapperOf<
1179 ::Windows::Foundation::Collections::IVector<T> ^>(info.This())) {
1180 return;
1181 }
1182
1183 VectorWrapper<T>* wrapper =
1184 VectorWrapper<T>::Unwrap<VectorWrapper<T>>(info.This());
1185
1186 if (wrapper->_convertToTypeFunc == nullptr ||
1187 wrapper->_checkTypeFunc == nullptr) {
1188 Nan::ThrowError(
1189 Nan::Error(NodeRT::Utils::NewString(L"Method isn't supported")));
1190 return;
1191 }
1192
1193 if (info.Length() == 1 && wrapper->_checkTypeFunc(info[0])) {
1194 try {
1195 T item = wrapper->_convertToTypeFunc(info[0]);
1196
1197 unsigned int index;
1198 bool result = wrapper->_instance->IndexOf(item, &index);
1199
1200 Local<Object> resObj = Nan::New<Object>();
1201 Nan::Set(resObj, Nan::New<String>("boolean").ToLocalChecked(),
1202 Nan::New<Boolean>(result));
1203 Nan::Set(resObj, Nan::New<String>("index").ToLocalChecked(),
1204 Nan::New<Integer>(index));
1205 info.GetReturnValue().Set(resObj);
1206 } catch (Platform::Exception ^ exception) {
1207 NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
1208 return;
1209 }
1210 } else {
1211 Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(
1212 L"Bad arguments: no suitable overload found")));
1213 return;
1214 }
1215
1216 return;
1217 }
1218
1219 static void SizeGetter(Local<String> property,
1220 const Nan::PropertyCallbackInfo<v8::Value>& info) {

Callers 1

IndexOfMethod · 0.45

Calls 2

NewStringFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected