当前位置: 首页>>代码示例>>C++>>正文


C++ JsValuePtr类代码示例

本文整理汇总了C++中JsValuePtr的典型用法代码示例。如果您正苦于以下问题:C++ JsValuePtr类的具体用法?C++ JsValuePtr怎么用?C++ JsValuePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JsValuePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetSubscription

SubscriptionPtr FilterEngine::GetSubscription(const std::string& url)
{
  JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl");
  JsValueList params;
  params.push_back(jsEngine->NewValue(url));
  return SubscriptionPtr(new Subscription(std::move(*func->Call(params))));
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例2: AddToList

void Subscription::AddToList()
{
  JsValuePtr func = jsEngine->Evaluate("API.addSubscriptionToList");
  JsValueList params;
  params.push_back(shared_from_this());
  func->Call(params);
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例3: context

AdblockPlus::JsValuePtr AdblockPlus::JsValue::Call(const JsValueList& params, JsValuePtr thisPtr) const
{
  if (!IsFunction())
    throw new std::runtime_error("Attempting to call a non-function");

  const JsContext context(jsEngine);
  if (!thisPtr)
  {
	  v8::Local<v8::Context> localContext = v8::Local<v8::Context>::New(jsEngine->GetIsolate(), *jsEngine->context);
    thisPtr = JsValuePtr(new JsValue(jsEngine, localContext->Global()));
  }
  if (!thisPtr->IsObject())
    throw new std::runtime_error("`this` pointer has to be an object");
  v8::Local<v8::Object> thisObj = v8::Local<v8::Object>::Cast(thisPtr->UnwrapValue());

  std::vector<v8::Handle<v8::Value>> argv;
  for (JsValueList::const_iterator it = params.begin(); it != params.end(); ++it)
    argv.push_back((*it)->UnwrapValue());

  const v8::TryCatch tryCatch;
  v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(UnwrapValue());
  v8::Local<v8::Value> result = func->Call(thisObj, argv.size(),
      argv.size() ? &argv.front() : 0);

  if (tryCatch.HasCaught())
    throw JsError(tryCatch.Exception(), tryCatch.Message());

  return JsValuePtr(new JsValue(jsEngine, result));
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:29,代码来源:JsValue.cpp

示例4: GetFilter

FilterPtr FilterEngine::GetFilter(const std::string& text)
{
  JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText");
  JsValueList params;
  params.push_back(jsEngine->NewValue(text));
  return FilterPtr(new Filter(std::move(*func->Call(params))));
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例5: IsListed

bool Subscription::IsListed()
{
  JsValuePtr func = jsEngine->Evaluate("API.isListedSubscription");
  JsValueList params;
  params.push_back(shared_from_this());
  return func->Call(params)->AsBool();
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例6: GetPref

JsValuePtr FilterEngine::GetPref(const std::string& pref) const
{
  JsValuePtr func = jsEngine->Evaluate("API.getPref");
  JsValueList params;
  params.push_back(jsEngine->NewValue(pref));
  return func->Call(params);
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例7: jsEngine

FilterEngine::FilterEngine(JsEnginePtr jsEngine,
                           const FilterEngine::Prefs& preconfiguredPrefs)
    : jsEngine(jsEngine), initialized(false), firstRun(false), updateCheckId(0)
{
  jsEngine->SetEventCallback("_init", std::bind(&FilterEngine::InitDone,
      this, std::placeholders::_1));

  {
    // Lock the JS engine while we are loading scripts, no timeouts should fire
    // until we are done.
    const JsContext context(jsEngine);

    // Set the preconfigured prefs
    JsValuePtr preconfiguredPrefsObject = jsEngine->NewObject();
    for (FilterEngine::Prefs::const_iterator it = preconfiguredPrefs.begin();
         it != preconfiguredPrefs.end(); it++)
    {
      preconfiguredPrefsObject->SetProperty(it->first, it->second);
    }
    jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject);
    // Load adblockplus scripts
    for (int i = 0; !jsSources[i].empty(); i += 2)
      jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
  }

  // TODO: This should really be implemented via a conditional variable
  while (!initialized)
    ::Sleep(10);
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:29,代码来源:FilterEngine.cpp

示例8: UpdateFilters

void Subscription::UpdateFilters()
{
  JsValuePtr func = jsEngine->Evaluate("API.updateSubscription");
  JsValueList params;
  params.push_back(shared_from_this());
  func->Call(params);
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例9: GetHostFromURL

std::string FilterEngine::GetHostFromURL(const std::string& url)
{
  JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl");
  JsValueList params;
  params.push_back(jsEngine->NewValue(url));
  return func->Call(params)->AsString();
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例10: RemoveFromList

void Filter::RemoveFromList()
{
  JsValuePtr func = jsEngine->Evaluate("API.removeFilterFromList");
  JsValueList params;
  params.push_back(shared_from_this());
  func->Call(params);
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:7,代码来源:FilterEngine.cpp

示例11: IsUpdating

bool Subscription::IsUpdating()
{
  JsValuePtr func = jsEngine->Evaluate("API.isSubscriptionUpdating");
  JsValueList params;
  params.push_back(shared_from_this());
  JsValuePtr result = func->Call(params);
  return result->AsBool();
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:8,代码来源:FilterEngine.cpp

示例12: SetPref

void FilterEngine::SetPref(const std::string& pref, JsValuePtr value)
{
  JsValuePtr func = jsEngine->Evaluate("API.setPref");
  JsValueList params;
  params.push_back(jsEngine->NewValue(pref));
  params.push_back(value);
  func->Call(params);
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:8,代码来源:FilterEngine.cpp

示例13: CompareVersions

int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
{
  JsValueList params;
  params.push_back(jsEngine->NewValue(v1));
  params.push_back(jsEngine->NewValue(v2));
  JsValuePtr func = jsEngine->Evaluate("API.compareVersions");
  return func->Call(params)->AsInt();
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:8,代码来源:FilterEngine.cpp

示例14: Subscription

std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const
{
  JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions");
  JsValueList values = func->Call()->AsList();
  std::vector<SubscriptionPtr> result;
  for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
	  result.push_back(SubscriptionPtr(new Subscription(std::move(**it))));
  return result;
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:9,代码来源:FilterEngine.cpp

示例15: Filter

std::vector<FilterPtr> FilterEngine::GetListedFilters() const
{
  JsValuePtr func = jsEngine->Evaluate("API.getListedFilters");
  JsValueList values = func->Call()->AsList();
  std::vector<FilterPtr> result;
  for (JsValueList::iterator it = values.begin(); it != values.end(); it++)
	  result.push_back(FilterPtr(new Filter(std::move(**it))));
  return result;
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:9,代码来源:FilterEngine.cpp


注:本文中的JsValuePtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。