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


C++ Local::ForceSet方法代码示例

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


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

示例1: scope

Handle<Object> GetTableCall::buildDBIndex(const NdbDictionary::Index *idx) {
  EscapableHandleScope scope(isolate);

  Local<Object> obj = NdbDictIndexEnv.newWrapper();
  wrapPointerInObject(idx, NdbDictIndexEnv, obj);

  obj->ForceSet(SYMBOL(isolate, "name"), String::NewFromUtf8(isolate, idx->getName()));
  obj->ForceSet(SYMBOL(isolate, "isPrimaryKey"), Boolean::New(isolate, false), ReadOnly);
  obj->ForceSet(SYMBOL(isolate, "isUnique"),
                Boolean::New(isolate, idx->getType() == NdbDictionary::Index::UniqueHashIndex),
                ReadOnly);
  obj->ForceSet(SYMBOL(isolate, "isOrdered"),
                Boolean::New(isolate, idx->getType() == NdbDictionary::Index::OrderedIndex),
                ReadOnly);
  
  /* Loop over the columns of the key. 
     Build the "columns" array and the "record" object, then set both.
  */  
  int ncol = idx->getNoOfColumns();
  Local<Array> idx_columns = Array::New(isolate, ncol);
  DEBUG_PRINT("Creating Index Record (%s)", idx->getName());
  Record * idx_record = new Record(dict, ncol);
  for(int i = 0 ; i < ncol ; i++) {
    const char *colName = idx->getColumn(i)->getName();
    const NdbDictionary::Column *col = ndb_table->getColumn(colName);
    idx_columns->Set(i, v8::Int32::New(isolate, col->getColumnNo()));
    idx_record->addColumn(col);
  }
  idx_record->completeIndexRecord(idx);
  obj->ForceSet(SYMBOL(isolate, "record"), Record_Wrapper(idx_record), ReadOnly);
  obj->Set(SYMBOL(isolate, "columnNumbers"), idx_columns);
  
  return scope.Escape(obj);
}
开发者ID:alMysql,项目名称:mysql-js,代码行数:34,代码来源:DBDictionaryImpl.cpp

示例2: onFrameSetup

void* JsVlcPlayer::onFrameSetup( const I420VideoFrame& videoFrame )
{
    using namespace v8;

    if( 0 == videoFrame.width() || 0 == videoFrame.height() ||
        0 == videoFrame.uPlaneOffset() || 0 == videoFrame.vPlaneOffset() ||
        0 == videoFrame.size() )
    {
        assert( false );
        return nullptr;
    }

    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope( isolate );

    Local<Object> global = isolate->GetCurrentContext()->Global();

    Local<Value> abv =
        global->Get(
            String::NewFromUtf8( isolate,
                                 "Uint8Array",
                                 v8::String::kInternalizedString ) );
    Local<Value> argv[] =
        { Integer::NewFromUnsigned( isolate, videoFrame.size() ) };
    Local<Uint8Array> jsArray =
        Handle<Uint8Array>::Cast( Handle<Function>::Cast( abv )->NewInstance( 1, argv ) );

    Local<Integer> jsWidth = Integer::New( isolate, videoFrame.width() );
    Local<Integer> jsHeight = Integer::New( isolate, videoFrame.height() );
    Local<Integer> jsPixelFormat = Integer::New( isolate, static_cast<int>( PixelFormat::I420 ) );

    jsArray->ForceSet( String::NewFromUtf8( isolate, "width", v8::String::kInternalizedString ),
                       jsWidth,
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "height", v8::String::kInternalizedString ),
                       jsHeight,
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "pixelFormat", v8::String::kInternalizedString ),
                       jsPixelFormat,
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "uOffset", v8::String::kInternalizedString ),
                       Integer::New( isolate, videoFrame.uPlaneOffset() ),
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "vOffset", v8::String::kInternalizedString ),
                       Integer::New( isolate, videoFrame.vPlaneOffset() ),
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );

    _jsFrameBuffer.Reset( isolate, jsArray );

    callCallback( CB_FrameSetup, { jsWidth, jsHeight, jsPixelFormat, jsArray } );

#ifdef USE_ARRAY_BUFFER
    return jsArray->Buffer()->GetContents().Data();
#else
    return jsArray->GetIndexedPropertiesExternalArrayData();
#endif
}
开发者ID:atifzaidi,项目名称:WebChimera.js,代码行数:57,代码来源:JsVlcPlayer.cpp

示例3: exp

static gboolean
gum_v8_module_handle_export_match (const GumExportDetails * details,
                                   gpointer user_data)
{
  GumV8ExportsContext * ctx =
      static_cast<GumV8ExportsContext *> (user_data);
  Isolate * isolate = ctx->isolate;
  Local<Context> jc = isolate->GetCurrentContext ();
  PropertyAttribute attrs =
      static_cast<PropertyAttribute> (ReadOnly | DontDelete);

  Local<Object> exp (ctx->exp->Clone ());

  if (details->type != GUM_EXPORT_FUNCTION)
  {
    Maybe<bool> success = exp->ForceSet (jc, ctx->type, ctx->variable, attrs);
    g_assert (success.IsJust ());
  }

  Maybe<bool> success = exp->ForceSet (jc,
      ctx->name,
      String::NewFromOneByte (isolate,
          reinterpret_cast<const uint8_t *> (details->name)),
      attrs);
  g_assert (success.IsJust ());

  success = exp->ForceSet (jc,
      ctx->address,
      _gum_v8_native_pointer_new (GSIZE_TO_POINTER (details->address),
          ctx->self->core),
      attrs);
  g_assert (success.IsJust ());

  Handle<Value> argv[] = {
    exp
  };
  Local<Value> result = ctx->on_match->Call (ctx->receiver, 1, argv);

  gboolean proceed = TRUE;
  if (!result.IsEmpty () && result->IsString ())
  {
    String::Utf8Value str (result);
    proceed = (strcmp (*str, "stop") != 0);
  }

  return proceed;
}
开发者ID:terry2012,项目名称:frida-gum,代码行数:47,代码来源:gumv8module.cpp

示例4: scope

void CanvasRenderingContext2D::Create(const v8::FunctionCallbackInfo<v8::Value>& args)
{
	auto isolate = args.GetIsolate();
	HandleScope scope(isolate);

	Local<ObjectTemplate> contextTemplate = ObjectTemplate::New(isolate);
	contextTemplate->SetInternalFieldCount(1);

	contextTemplate->Set(ConvertToV8String("__draw"), FunctionTemplate::New(isolate, &Draw));
	contextTemplate->Set(ConvertToV8String("__sizeChanged"), FunctionTemplate::New(isolate, &SizeChanged));

	contextTemplate->SetAccessor(ConvertToV8String("fillStyle"), &GetFillStyle, &SetFillStyle);
	contextTemplate->SetAccessor(ConvertToV8String("strokeStyle"), &GetStrokeStyle, &SetStrokeStyle);

	contextTemplate->Set(ConvertToV8String("arc"), FunctionTemplate::New(isolate, &Arc));
	contextTemplate->Set(ConvertToV8String("beginPath"), FunctionTemplate::New(isolate, &BeginPath));
	contextTemplate->Set(ConvertToV8String("bezierCurveTo"), FunctionTemplate::New(isolate, &BezierCurveTo));
	contextTemplate->Set(ConvertToV8String("clearRect"), FunctionTemplate::New(isolate, &ClearRect));
	contextTemplate->Set(ConvertToV8String("closePath"), FunctionTemplate::New(isolate, &ClosePath));
	contextTemplate->Set(ConvertToV8String("drawImage"), FunctionTemplate::New(isolate, &DrawImage));
	contextTemplate->Set(ConvertToV8String("fill"), FunctionTemplate::New(isolate, &Fill));
	contextTemplate->Set(ConvertToV8String("fillRect"), FunctionTemplate::New(isolate, &FillRect));
	contextTemplate->Set(ConvertToV8String("fillText"), FunctionTemplate::New(isolate, &FillText));
	contextTemplate->Set(ConvertToV8String("getImageData"), FunctionTemplate::New(isolate, &GetImageData));
	contextTemplate->Set(ConvertToV8String("lineTo"), FunctionTemplate::New(isolate, &LineTo));
	contextTemplate->Set(ConvertToV8String("measureText"), FunctionTemplate::New(isolate, &MeasureText));
	contextTemplate->Set(ConvertToV8String("moveTo"), FunctionTemplate::New(isolate, &MoveTo));
	contextTemplate->Set(ConvertToV8String("quadraticCurveTo"), FunctionTemplate::New(isolate, &QuadraticCurveTo));
	contextTemplate->Set(ConvertToV8String("restore"), FunctionTemplate::New(isolate, &Restore));
	contextTemplate->Set(ConvertToV8String("rotate"), FunctionTemplate::New(isolate, &Rotate));
	contextTemplate->Set(ConvertToV8String("save"), FunctionTemplate::New(isolate, &Save));
	contextTemplate->Set(ConvertToV8String("stroke"), FunctionTemplate::New(isolate, &Stroke));
	contextTemplate->Set(ConvertToV8String("translate"), FunctionTemplate::New(isolate, &Translate));

	Local<Object> newContext = contextTemplate->NewInstance();
	newContext->ForceSet(ConvertToV8String("canvas"), args[0]);
	newContext->ForceSet(ConvertToV8String("__kind"), ConvertToV8String("2d"));

	auto nativeContext = new CanvasRenderingContext2D();
	newContext->SetInternalField(0, External::New(isolate, nativeContext));

	Persistent<Object> persistentHandle(isolate, newContext);
	persistentHandle.SetWeak(nativeContext, &Deallocate);

	args.GetReturnValue().Set(newContext);
}
开发者ID:NativeScript,项目名称:nativescript-canvas,代码行数:46,代码来源:CanvasRenderingContext2D.cpp

示例5: type

void
_gum_v8_module_realize (GumV8Module * self)
{
  static gsize gonce_value = 0;

  if (g_once_init_enter (&gonce_value))
  {
    Isolate * isolate = self->core->isolate;
    Local<Context> context = isolate->GetCurrentContext ();

    Local<String> type (String::NewFromUtf8 (isolate, "type"));
    Local<String> name (String::NewFromUtf8 (isolate, "name"));
    Local<String> module (String::NewFromUtf8 (isolate, "module"));
    Local<String> address (String::NewFromUtf8 (isolate, "address"));

    Local<String> function (String::NewFromUtf8 (isolate, "function"));
    Local<String> variable (String::NewFromUtf8 (isolate, "variable"));

    Local<String> empty_string = String::NewFromUtf8 (isolate, "");

    Local<Object> imp (Object::New (isolate));
    Maybe<bool> result = imp->ForceSet (context, type, function);
    g_assert (result.IsJust ());
    result = imp->ForceSet (context, name, empty_string, DontDelete);
    g_assert (result.IsJust ());
    result = imp->ForceSet (context, module, empty_string);
    g_assert (result.IsJust ());
    result = imp->ForceSet (context, address, _gum_v8_native_pointer_new (
        GSIZE_TO_POINTER (NULL), self->core));
    g_assert (result.IsJust ());

    Local<Object> exp (Object::New (isolate));
    result = exp->ForceSet (context, type, function, DontDelete);
    g_assert (result.IsJust ());
    result = exp->ForceSet (context, name, empty_string, DontDelete);
    g_assert (result.IsJust ());
    result = exp->ForceSet (context, address, _gum_v8_native_pointer_new (
        GSIZE_TO_POINTER (NULL), self->core), DontDelete);
    g_assert (result.IsJust ());

    eternal_imp.Set (isolate, imp);
    eternal_exp.Set (isolate, exp);

    eternal_type.Set (isolate, type);
    eternal_name.Set (isolate, name);
    eternal_module.Set (isolate, module);
    eternal_address.Set (isolate, address);
    eternal_variable.Set (isolate, variable);

    g_once_init_leave (&gonce_value, 1);
  }
}
开发者ID:terry2012,项目名称:frida-gum,代码行数:52,代码来源:gumv8module.cpp

示例6: imp

static gboolean
gum_v8_module_handle_import_match (const GumImportDetails * details,
                                   gpointer user_data)
{
  GumV8ImportsContext * ctx =
      static_cast<GumV8ImportsContext *> (user_data);
  Isolate * isolate = ctx->isolate;
  Local<Context> jc = isolate->GetCurrentContext ();
  PropertyAttribute attrs =
      static_cast<PropertyAttribute> (ReadOnly | DontDelete);

  Local<Object> imp (ctx->imp->Clone ());

  switch (details->type)
  {
    case GUM_IMPORT_FUNCTION:
    {
      /* the default value in our template */
      break;
    }
    case GUM_IMPORT_VARIABLE:
    {
      Maybe<bool> success = imp->ForceSet (jc, ctx->type, ctx->variable, attrs);
      g_assert (success.IsJust ());
      break;
    }
    case GUM_IMPORT_UNKNOWN:
    {
      Maybe<bool> success = imp->Delete (jc, ctx->type);
      g_assert (success.IsJust ());
      break;
    }
    default:
    {
      g_assert_not_reached ();
      break;
    }
  }

  Maybe<bool> success = imp->ForceSet (jc,
      ctx->name,
      String::NewFromOneByte (isolate,
          reinterpret_cast<const uint8_t *> (details->name)),
      attrs);
  g_assert (success.IsJust ());

  if (details->module != NULL)
  {
    success = imp->ForceSet (jc,
        ctx->module,
        String::NewFromOneByte (isolate,
            reinterpret_cast<const uint8_t *> (details->module)),
        attrs);
    g_assert (success.IsJust ());
  }
  else
  {
    success = imp->Delete (jc, ctx->module);
    g_assert (success.IsJust ());
  }

  if (details->address != 0)
  {
    success = imp->ForceSet (jc,
        ctx->address,
        _gum_v8_native_pointer_new (GSIZE_TO_POINTER (details->address),
            ctx->self->core),
        attrs);
    g_assert (success.IsJust ());
  }
  else
  {
    success = imp->Delete (jc, ctx->address);
    g_assert (success.IsJust ());
  }

  Handle<Value> argv[] = {
    imp
  };
  Local<Value> result = ctx->on_match->Call (ctx->receiver, 1, argv);

  gboolean proceed = TRUE;
  if (!result.IsEmpty () && result->IsString ())
  {
    String::Utf8Value str (result);
    proceed = (strcmp (*str, "stop") != 0);
  }

  return proceed;
}
开发者ID:terry2012,项目名称:frida-gum,代码行数:90,代码来源:gumv8module.cpp

示例7: doAsyncCallback

/* doAsyncCallback() runs in the main thread.  We don't want it to block.
   TODO: verify whether any IO is done 
         by checking WaitMetaRequestCount at the start and end.
*/    
void GetTableCall::doAsyncCallback(Local<Object> ctx) {
  const char *tableName;
  EscapableHandleScope scope(isolate);
  DEBUG_PRINT("GetTableCall::doAsyncCallback: return_val %d", return_val);

  /* User callback arguments */
  Handle<Value> cb_args[2];
  cb_args[0] = Null(isolate);
  cb_args[1] = Null(isolate);
  
  /* TableMetadata = {
      database         : ""    ,  // Database name
      name             : ""    ,  // Table Name
      columns          : []    ,  // ordered array of DBColumn objects
      indexes          : []    ,  // array of DBIndex objects 
      partitionKey     : []    ,  // ordered array of column numbers in the partition key
      sparseContainer  : null     // default column for sparse fields
    };
  */    
  if(ndb_table && ! return_val) {
    Local<Object> table = NdbDictTableEnv.wrap(ndb_table)->ToObject();

    // database
    table->Set(SYMBOL(isolate, "database"), String::NewFromUtf8(isolate, arg1));
    
    // name
    tableName = ndb_table->getName();
    table->Set(SYMBOL(isolate, "name"), String::NewFromUtf8(isolate, tableName));

    // partitionKey
    int nPartitionKeys = 0;
    Handle<Array> partitionKeys = Array::New(isolate);
    table->Set(SYMBOL(isolate, "partitionKey"), partitionKeys);

    // sparseContainer
    table->Set(SYMBOL(isolate,"sparseContainer"), Null(isolate));

    // columns
    Local<Array> columns = Array::New(isolate, ndb_table->getNoOfColumns());
    for(int i = 0 ; i < ndb_table->getNoOfColumns() ; i++) {
      const NdbDictionary::Column *ndb_col = ndb_table->getColumn(i);
      Handle<Object> col = buildDBColumn(ndb_col);
      columns->Set(i, col);
      if(ndb_col->getPartitionKey()) { /* partition key */
        partitionKeys->Set(nPartitionKeys++, String::NewFromUtf8(isolate, ndb_col->getName()));
      }
      if(     ! strcmp(ndb_col->getName(), "SPARSE_FIELDS")
          && ( (! strncmp(getColumnType(ndb_col), "VARCHAR", 7)
                  && (getEncoderCharsetForColumn(ndb_col)->isUnicode))
              || ! strncmp(getColumnType(ndb_col), "VARBINARY", 9)))
      {
        table->Set(SYMBOL(isolate,"sparseContainer"),
                   String::NewFromUtf8(isolate, ndb_col->getName()));
      }
    }
    table->Set(SYMBOL(isolate, "columns"), columns);

    // indexes (primary key & secondary) 
    Local<Array> js_indexes = Array::New(isolate, idx_list.count + 1);
    js_indexes->Set(0, buildDBIndex_PK());                   // primary key
    for(unsigned int i = 0 ; i < idx_list.count ; i++) {   // secondary indexes
      const NdbDictionary::Index * idx =
        dict->getIndex(idx_list.elements[i].name, arg2);
      js_indexes->Set(i+1, buildDBIndex(idx));
    }    
    table->ForceSet(SYMBOL(isolate, "indexes"), js_indexes, ReadOnly);

    // foreign keys (only foreign keys for which this table is the child)
    // now create the javascript foreign key metadata objects for dictionary objects cached earlier
    Local<Array> js_fks = Array::New(isolate, fk_count);

    int fk_number = 0;
    for(unsigned int i = 0 ; i < fk_list.count ; i++) {
      NdbDictionary::ForeignKey fk;
      if (fk_list.elements[i].type == NdbDictionary::Object::ForeignKey) {
        const char * fk_name = fk_list.elements[i].name;
        int fkGetCode = dict->getForeignKey(fk, fk_name);
        DEBUG_PRINT("getForeignKey for %s returned %i", fk_name, fkGetCode);
        // see if the foreign key child table is this table
        if(splitNameMatchesDbAndTable(fk.getChildTable())) {
          // the foreign key child table is this table; build the fk object
          DEBUG_PRINT("Adding foreign key for %s at %i", fk.getName(), fk_number);
          js_fks->Set(fk_number++, buildDBForeignKey(&fk));
        }
      }
    }
    table->ForceSet(SYMBOL(isolate, "foreignKeys"), js_fks, ReadOnly);

    // Autoincrement Cache Impl (also not part of spec)
    if(per_table_ndb) {
      table->Set(SYMBOL(isolate, "per_table_ndb"), Ndb_Wrapper(per_table_ndb));
    }
    
    // User Callback
    cb_args[1] = table;
  }
//.........这里部分代码省略.........
开发者ID:alMysql,项目名称:mysql-js,代码行数:101,代码来源:DBDictionaryImpl.cpp


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