Minsky: 3.17.0
MinskyAddon Struct Reference
Inheritance diagram for MinskyAddon:
Inheritance graph
Collaboration diagram for MinskyAddon:
Collaboration graph

Public Member Functions

 MinskyAddon (Env env, Napi::Object exports)
 
Value setMessageCallback (const Napi::CallbackInfo &info)
 
Value setBusyCursorCallback (const Napi::CallbackInfo &info)
 
Value setProgressCallback (const Napi::CallbackInfo &info)
 
Value setBookmarkRefreshCallback (const Napi::CallbackInfo &info)
 
Value setResetScrollCallback (const Napi::CallbackInfo &info)
 
Value cancelProgress (const Napi::CallbackInfo &info)
 
Value call (const Napi::CallbackInfo &info)
 

Public Attributes

minsky::AddOnMinsky addOnMinsky
 

Detailed Description

Definition at line 560 of file addon.cc.

Constructor & Destructor Documentation

◆ MinskyAddon()

MinskyAddon::MinskyAddon ( Env  env,
Napi::Object  exports 
)
inline

Definition at line 566 of file addon.cc.

References call(), cancelProgress(), handleSignal(), minsky::anonymous_namespace{addon.cc}::l_minsky, setBookmarkRefreshCallback(), setBusyCursorCallback(), setMessageCallback(), setProgressCallback(), setResetScrollCallback(), and anonymous_namespace{addon.cc}::tsPromiseResolver.

567  {
568  minsky::l_minsky=&addOnMinsky; // set the global minsky object
569  tsPromiseResolver=TypedThreadSafeFunction<void,PromiseResolver,resolvePromise>::
570  New(env,"TSResolver", 0, 2, nullptr);
571  addOnMinsky.tsDrawNativeWindows_=
572  TypedThreadSafeFunction<minsky::AddOnMinsky,void,minsky::AddOnMinsky::tsDrawNativeWindows>::
573  New(env,"TSDrawNativeWindows",0, 2,&addOnMinsky);
574 
575  DefineAddon(exports, {
576  InstanceMethod("call", &MinskyAddon::call),
577  InstanceMethod("setMessageCallback", &MinskyAddon::setMessageCallback),
578  InstanceMethod("setBusyCursorCallback", &MinskyAddon::setBusyCursorCallback),
579  InstanceMethod("setProgressCallback", &MinskyAddon::setProgressCallback),
580  InstanceMethod("setBookmarkRefreshCallback", &MinskyAddon::setBookmarkRefreshCallback),
581  InstanceMethod("setResetScrollCallback", &MinskyAddon::setResetScrollCallback),
582  InstanceMethod("cancelProgress", &MinskyAddon::cancelProgress)
583  });
584 #ifndef _WIN32
585  signal(SIGTRAP,handleSignal);
586 #endif
587  }
Value setBusyCursorCallback(const Napi::CallbackInfo &info)
Definition: addon.cc:590
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Value setMessageCallback(const Napi::CallbackInfo &info)
Definition: addon.cc:589
Value setResetScrollCallback(const Napi::CallbackInfo &info)
Definition: addon.cc:593
Value cancelProgress(const Napi::CallbackInfo &info)
Definition: addon.cc:594
Value setBookmarkRefreshCallback(const Napi::CallbackInfo &info)
Definition: addon.cc:592
Value setProgressCallback(const Napi::CallbackInfo &info)
Definition: addon.cc:591
Value call(const Napi::CallbackInfo &info)
Definition: addon.cc:601
TypedThreadSafeFunction< void, PromiseResolver, resolvePromise > tsPromiseResolver
Definition: addon.cc:83
void handleSignal(int)
Definition: addon.cc:554
Here is the call graph for this function:

Member Function Documentation

◆ call()

Value MinskyAddon::call ( const Napi::CallbackInfo &  info)
inline

Definition at line 601 of file addon.cc.

Referenced by MinskyAddon().

602  {
603  const Env env = info.Env();
604  if (info.Length() < 1)
605  {
606  Napi::TypeError::New(env, "Needs to be call(endpoint[, arguments])").ThrowAsJavaScriptException();
607  return env.Null();
608  }
609 
610 #if defined(_PTHREAD_H) && defined(__USE_GNU) && !defined(NDEBUG)
611  pthread_setname_np(pthread_self(),"addon thread");
612 #endif
613 
614  try
615  {
616  json_pack_t arguments(json5_parser::mValue::null);
617  if (info.Length()>1)
618  {
619  const string jsonArguments=info[1].ToString();
620  if (!jsonArguments.empty())
621  read(jsonArguments, arguments);
622  }
623  return addOnMinsky.queueCommand(env,info[0].ToString(),arguments);
624  }
625  catch (const std::exception& ex)
626  {
627  // throw C++ exception as Javascript exception
628  Napi::Error::New(env, ex.what()).ThrowAsJavaScriptException();
629  return env.Null();
630  }
631  catch (...)
632  {
633  Napi::Error::New(env, "unknown exception caught").ThrowAsJavaScriptException();
634  return env.Null();
635  }
636  }
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Here is the caller graph for this function:

◆ cancelProgress()

Value MinskyAddon::cancelProgress ( const Napi::CallbackInfo &  info)
inline

Definition at line 594 of file addon.cc.

Referenced by MinskyAddon().

594  {
595  *addOnMinsky.progressState.cancel=true;
596  civita::ITensor::cancel(true);
597  return info.Env().Null();
598  }
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Here is the caller graph for this function:

◆ setBookmarkRefreshCallback()

Value MinskyAddon::setBookmarkRefreshCallback ( const Napi::CallbackInfo &  info)
inline

Definition at line 592 of file addon.cc.

Referenced by MinskyAddon().

592 {return addOnMinsky.setBookmarkRefreshCallback(info);}
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Here is the caller graph for this function:

◆ setBusyCursorCallback()

Value MinskyAddon::setBusyCursorCallback ( const Napi::CallbackInfo &  info)
inline

Definition at line 590 of file addon.cc.

Referenced by MinskyAddon().

590 {return addOnMinsky.setBusyCursorCallback(info);}
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Here is the caller graph for this function:

◆ setMessageCallback()

Value MinskyAddon::setMessageCallback ( const Napi::CallbackInfo &  info)
inline

Definition at line 589 of file addon.cc.

Referenced by MinskyAddon().

589 {return addOnMinsky.setMessageCallback(info);}
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Here is the caller graph for this function:

◆ setProgressCallback()

Value MinskyAddon::setProgressCallback ( const Napi::CallbackInfo &  info)
inline

Definition at line 591 of file addon.cc.

Referenced by MinskyAddon().

591 {return addOnMinsky.setProgressCallback(info);}
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Here is the caller graph for this function:

◆ setResetScrollCallback()

Value MinskyAddon::setResetScrollCallback ( const Napi::CallbackInfo &  info)
inline

Definition at line 593 of file addon.cc.

Referenced by MinskyAddon().

593 {return addOnMinsky.setResetScrollCallback(info);}
minsky::AddOnMinsky addOnMinsky
Definition: addon.cc:564
Here is the caller graph for this function:

Member Data Documentation

◆ addOnMinsky

minsky::AddOnMinsky MinskyAddon::addOnMinsky

Definition at line 564 of file addon.cc.


The documentation for this struct was generated from the following file: