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


C++ Handle::IsArray方法代码示例

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


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

示例1: Read

IOBasicTypes::LongBufferSizeType ObjectByteReaderWithPosition::Read(IOBasicTypes::Byte* inBuffer,IOBasicTypes::LongBufferSizeType inBufferSize)
{
	CREATE_ISOLATE_CONTEXT;
	CREATE_ESCAPABLE_SCOPE;

	Handle<Value> value = OBJECT_FROM_PERSISTENT(mObject)->Get(NEW_STRING("read"));
    if(value->IsUndefined())
        return 0;
    Handle<Function> func = Handle<Function>::Cast(value);
    
    Handle<Value> args[1];
    args[0] = NEW_NUMBER(inBufferSize);
    
	Handle<Value> result = func->Call(OBJECT_FROM_PERSISTENT(mObject), 1, args);
    
    if(!result->IsArray())
        return 0;
    
    IOBasicTypes::LongBufferSizeType bufferLength = result->ToObject()->Get(NEW_STRING("length"))->ToObject()->Uint32Value();
    for(IOBasicTypes::LongBufferSizeType i=0;i < bufferLength;++i)
        inBuffer[i] = (IOBasicTypes::Byte)(result->ToObject()->Get((uint32_t)i)->ToNumber()->Uint32Value());
    
    return bufferLength;
    
}
开发者ID:JoshLaseter,项目名称:HummusJS,代码行数:25,代码来源:ObjectByteReaderWithPosition.cpp

示例2: UserException

    int V8Scope::type( const char *field ){
        V8_SIMPLE_HEADER
        Handle<Value> v = get( field );
        if ( v->IsNull() )
            return jstNULL;
        if ( v->IsUndefined() )
            return Undefined;
        if ( v->IsString() )
            return String;
        if ( v->IsFunction() )
            return Code;
        if ( v->IsArray() )
            return Array;
        if ( v->IsBoolean() )
            return Bool;
        if ( v->IsInt32() )
            return NumberInt;
        if ( v->IsNumber() )
            return NumberDouble;
        if ( v->IsExternal() ){
            uassert( 10230 ,  "can't handle external yet" , 0 );
            return -1;
        }
        if ( v->IsDate() )
            return Date;
        if ( v->IsObject() )
            return Object;

        throw UserException( 12509, (string)"don't know what this is: " + field );
    }
开发者ID:IlyaM,项目名称:mongo,代码行数:30,代码来源:engine_v8.cpp

示例3:

/*! Queues up an array to be sent to the sound card */
void Audio::AudioEngine::queueOutputBuffer( Handle<Array> result ) {
	// Reset our record of the number of cached output samples
	m_uNumCachedOutputSamples[m_uCurrentWriteBuffer] = 0;

	if( m_bInterleaved ) {
		for( int iSample=0; iSample<m_uSamplesPerBuffer*m_uOutputChannels; ++iSample )
			setSample( iSample, result->Get(iSample) );

		m_uNumCachedOutputSamples[m_uCurrentWriteBuffer] = result->Length()/m_uOutputChannels;

	} else {
		// Validate the structure of the output buffer array
		if( !result->Get(0)->IsArray() ) {
			NanThrowTypeError("Output buffer not properly setup, 0th channel is not an array");
			return;
		}

		Handle<Array> item;

		for( int iChannel=0; iChannel<m_uOutputChannels; ++iChannel ) {
			for( int iSample=0; iSample<m_uSamplesPerBuffer; ++iSample ) {

				item = Handle<Array>::Cast( result->Get(iChannel) );
				if( item->IsArray() ) {
					if( item->Length() > m_uNumCachedOutputSamples[m_uCurrentWriteBuffer] )
						m_uNumCachedOutputSamples[m_uCurrentWriteBuffer] = item->Length();

					setSample( iSample, item->Get(iSample) );
				}
			} // end for each sample
		} // end for each channel
	}
	m_uCurrentWriteBuffer = (m_uCurrentWriteBuffer + 1)%m_uNumBuffers;
} // end AudioEngine::queueOutputBuffer()
开发者ID:MrZunz,项目名称:AVA-Home,代码行数:35,代码来源:AudioEngine.cpp

示例4: GetNaturalType

int Conv::GetNaturalType(Handle<Object> val) {
  if(val.IsEmpty()) return TYPE_INVALID;
  if(val->IsDate()) return TYPE_DATE;
  if(val->IsFunction()) return TYPE_FUNCTION;
  if(val->IsArray()) return TYPE_ARRAY;
  if(val->IsObject()) return TYPE_OBJECT;
  return TYPE_INVALID;
}
开发者ID:Armen138,项目名称:anode,代码行数:8,代码来源:Conv.cpp

示例5: SerializePart

int SerializePart(google::protobuf::Message *message, Handle<Object> subj) {
  Nan::HandleScope scope;
  // get a reflection
  const Reflection *r = message->GetReflection();
  const Descriptor *d = message->GetDescriptor();

  // build a list of required properties
  vector<string> required;
  for (int i = 0; i < d->field_count(); i++) {
    const FieldDescriptor *field = d->field(i);
    if (field->is_required())
      required.push_back(field->name());
  }

  // build a reflection
  // get properties of passed object
  Handle<Array> properties = subj->GetPropertyNames();
  uint32_t len = properties->Length();

  // check that all required properties are present
  for (uint32_t i = 0; i < required.size(); i++) {
    Handle<String> key = Nan::New<String>(required.at(i).c_str()).ToLocalChecked();
    if (!subj->Has(key))
      return -1;
  }

  for (uint32_t i = 0; i < len; i++) {
    Handle<Value> property = properties->Get(i);
    Handle<String> property_s = property->ToString();

    if (*property_s == NULL)
      continue;

    String::Utf8Value temp(property);
    std::string propertyName = std::string(*temp);

    const FieldDescriptor *field = d->FindFieldByName(propertyName);
    if (field == NULL) continue;

    Handle<Value> val = subj->Get(property);

    if (field->is_repeated()) {
      if (!val->IsArray())
        continue;

      Handle<Array> array = val.As<Array>();
      int len = array->Length();

      for (int i = 0; i < len; i++)
        SerializeField(message, r, field, array->Get(i));

    } else {
      SerializeField(message, r, field, val);
    }
  }

  return 0;
}
开发者ID:dkarpman,项目名称:node-protobuf,代码行数:58,代码来源:serialize.cpp

示例6: getByteArrayFromValue

QByteArray TiObject::getByteArrayFromValue(Handle<Value> value)
{
	if (value->IsArray()) {
		Handle<Array> array = Handle<Array>::Cast(value);
		int length = array->Length();
		QByteArray result = QByteArray(length, 0);
		char *data = result.data();
		for (int index = 0; index < length; ++index) {
			data[index] = Handle<Number>::Cast(array->Get(index))->Value();
		}
		return result;
	}
	return QByteArray();
}
开发者ID:saggy,项目名称:titanium_mobile_blackberry,代码行数:14,代码来源:TiObject.cpp

示例7: v

static vector<string> get_paths(Handle<Function> require) {
    HandleScope hs;
    Handle<Object> paths = Handle<Object>::Cast(require->Get(String::New("paths")));
    if(!paths->IsArray()) return vector<string>();
    vector<string> res;
    unsigned int length = paths->Get(String::New("length"))->Uint32Value();
    cerr << "paths.length = " << length << endl;
    for(unsigned int i=0; i<length ; ++i) {
	String::Utf8Value v(paths->Get(i));
	cerr << "found " << *v << " in paths[" << i << "]\n";
	res.push_back(string(*v));
    }
    return res;
}
开发者ID:Floby,项目名称:Purple,代码行数:14,代码来源:ModuleManager.cpp

示例8: keyStr

Susi::Util::Any Susi::JS::Engine::convertFromJS(Handle<Value> jsVal){
	if(jsVal->IsArray()){
		Susi::Util::Any::Array result;
		auto obj = jsVal->ToObject();
		const Local<Array> props = obj->GetPropertyNames();
		const uint32_t length = props->Length();
		for (uint32_t i=0 ; i<length ; ++i){
			const Local<Value> key = props->Get(i);
			const Local<Value> value = obj->Get(key);
			result.push_back(Susi::JS::Engine::convertFromJS(value));
		}
		return result;
	}
	if(jsVal->IsObject()){
		Susi::Util::Any result = Susi::Util::Any::Object{};
		auto obj = jsVal->ToObject();
		const Local<Array> props = obj->GetPropertyNames();
		const uint32_t length = props->Length();
		for (uint32_t i=0 ; i<length ; ++i){
			const Local<Value> key = props->Get(i);
			const Local<Value> value = obj->Get(key);
			String::Utf8Value keyStr(key);
			result[std::string(*keyStr)] = Susi::JS::Engine::convertFromJS(value);
		}
		return result;
	}
	if(jsVal->IsString()){
		String::Utf8Value val(jsVal);
		Susi::Util::Any result{std::string(*val)};
		return result;
	}
	if(jsVal->IsNumber()){
		Susi::Util::Any result{jsVal->ToNumber()->Value()};
		return result;
	}
	if(jsVal->IsBoolean()){
		Susi::Util::Any result{jsVal->ToBoolean()->Value()};
		return result;
	}
	if(jsVal->IsNativeError()){
		String::Utf8Value val(jsVal);
		Susi::Util::Any result{std::string(*val)};
		return result;
	}
	if(jsVal->IsUndefined()){
		Susi::Util::Any result;
		return result;
	}
	return Susi::Util::Any{"type not known"};
}
开发者ID:Spacefish,项目名称:susi,代码行数:50,代码来源:JSEngine.cpp

示例9: DecodeWrite

// Returns number of bytes written.
ssize_t DecodeWrite(char *buf,
                    size_t buflen,
                    Handle<Value> val,
                    enum encoding encoding) {
  HandleScope scope;

  // XXX
  // A lot of improvement can be made here. See:
  // http://code.google.com/p/v8/issues/detail?id=270
  // http://groups.google.com/group/v8-dev/browse_thread/thread/dba28a81d9215291/ece2b50a3b4022c
  // http://groups.google.com/group/v8-users/browse_thread/thread/1f83b0ba1f0a611

  if (val->IsArray()) {
    fprintf(stderr, "'raw' encoding (array of integers) has been removed. "
                    "Use 'binary'.\n");
    assert(0);
    return -1;
  }

  Local<String> str = val->ToString();

  if (encoding == UTF8) {
    str->WriteUtf8(buf, buflen, NULL, String::HINT_MANY_WRITES_EXPECTED);
    return buflen;
  }

  if (encoding == ASCII) {
    str->WriteAscii(buf, 0, buflen, String::HINT_MANY_WRITES_EXPECTED);
    return buflen;
  }

  // THIS IS AWFUL!!! FIXME

  assert(encoding == BINARY);

  uint16_t * twobytebuf = new uint16_t[buflen];

  str->Write(twobytebuf, 0, buflen, String::HINT_MANY_WRITES_EXPECTED);

  for (size_t i = 0; i < buflen; i++) {
    unsigned char *b = reinterpret_cast<unsigned char*>(&twobytebuf[i]);
    buf[i] = b[0];
  }

  delete [] twobytebuf;

  return buflen;
}
开发者ID:ngocdaothanh,项目名称:jsg,代码行数:49,代码来源:node.cpp

示例10: NullTerminatedList

  void NullTerminatedList (const Wrapper* wrapper, Handle<Value> value, vector<void*>& natives) {
    if (!value->IsArray()) {
      natives.push_back(NULL);
      return;
    }
    Handle<Array> array = Handle<Array>::Cast<Value>(value);
    const size_t size = array->Length() + 1;
    intptr_t *nativeArray = (intptr_t*) malloc(sizeof(intptr_t) * size);

    for (size_t i = 0; i < size - 1; ++i) {
      nativeArray[i] = array->Get(i)->IntegerValue();
    }
    nativeArray[size - 1] = 0;

    natives.push_back(nativeArray);
  }
开发者ID:brainshave,项目名称:v8cl,代码行数:16,代码来源:converters.cpp

示例11: assert

void
Session::formOptions(std::string* str, Handle<Value> value)
{
    // Use the HandleScope of the calling function for speed.

    if (value->IsUndefined() || value->IsNull())
        return;

    assert(value->IsObject());

    std::stringstream ss;

    if (value->IsArray()) {
        // Format each array value into the options string "V[&V]"
        Local<Object> object = value->ToObject();
        for (std::size_t i = 0; i < Array::Cast(*object)->Length(); ++i) {
            Local<String> key = object->Get(i)->ToString();
            String::Utf8Value valv(key);
            if (valv.length()) {
                if (i > 0)
                    ss << "&";
                ss << *valv;
            }
        }
    } else {
        // Format each KV pair into the options string "K=V[&K=V]"
        Local<Object> object = value->ToObject();
        Local<Array> keys = object->GetPropertyNames();
        for (std::size_t i = 0; i < keys->Length(); ++i) {
            Local<String> key = keys->Get(i)->ToString();
            String::Utf8Value keyv(key);
            if (keyv.length()) {
                if (i > 0)
                    ss << "&";
                ss << *keyv << "=";
            }

            Local<String> val = object->Get(key)->ToString();
            String::Utf8Value valv(val);
            if (valv.length())
                ss << *valv;
        }
    }

    *str = ss.str();
}
开发者ID:ZJONSSON,项目名称:node-blpapi,代码行数:46,代码来源:blpapijs.cpp

示例12:

Handle<Array> GeoJSONReader::getGeomsArray(Handle<Object> geojson) {
    Isolate* isolate = Isolate::GetCurrent();

    Handle<String> geomsKey = String::NewFromUtf8(isolate, "geometries");
    if (!geojson->HasOwnProperty(geomsKey))
        throw "Property \"geometries\" is missing";


    Handle<Value> geoms = geojson->Get(geomsKey);
    if (
        !geoms->IsArray()
    )
        throw "Property \"geometries\" must be an instance of Array";


    return Handle<Array>::Cast(geoms);
}
开发者ID:kashif,项目名称:node-geos,代码行数:17,代码来源:geojsonreader.cpp

示例13: Many

  void Many (const Wrapper* wrapper, Handle<Value> value, vector<void*>& natives) {
    if (!value->IsArray()) {
      natives.push_back(NULL);
      // set size = 0;
      PushBackWrapped<size_t>(natives, 0);
      return;
    }

    Handle<Array> array = Handle<Array>::Cast<Value>(value);
    const size_t size = array->Length();
    T *nativeArray = (T*) malloc(sizeof(T) * size);

    for (size_t i = 0; i < size; ++i) {
      nativeArray[i] = Get<T>(array->Get(i));
    }

    natives.push_back(nativeArray);
    PushBackWrapped(natives, size);
  }
开发者ID:brainshave,项目名称:v8cl,代码行数:19,代码来源:converters.cpp

示例14: setOrientationModes

int NativeWindowObject::setOrientationModes(TiObject* obj) {
    Handle<Value> val = obj->getValue();
    if (!val->IsArray()) {
        return NATIVE_ERROR_INVALID_ARG;
    }

    // Convert the array of modes into a bitwise flags value.
    Handle<Array> modes = Handle<Array>::Cast(val);
    uint32_t modeCount = modes->Length();
    int flags = 0;
    for (uint32_t i = 0; i < modeCount; i++) {
        int32_t flag = modes->Get(i)->Int32Value();
        flags |= Orientation::toSceneMode(static_cast<Orientation::Type>(flag));
    }

    scene_.setOrientationModes(flags);

    return NATIVE_ERROR_OK;
}
开发者ID:richardmadison,项目名称:titanium_mobile_blackberry,代码行数:19,代码来源:NativeWindowObject.cpp

示例15: valueToDouble

geos::geom::Coordinate GeoJSONReader::getCoordinate(Handle<Value> value, bool acceptArrayOnly) {

    bool isArray = value->IsArray();

    if (acceptArrayOnly) {
        if (!isArray)
            throw "A coordinate must be an instance of Array";


    }
    else {
        if (
            !isArray
            && !value->IsNull()
            && !value->IsUndefined()
        )
            throw "A coordinate must be an instance of Array or null";


        if (!isArray)
            return geos::geom::Coordinate::getNull();
    }


    Handle<Array> array = Handle<Array>::Cast(value);
    uint32_t length = array->Length();
    if (length < 2)
        throw "A coordinate's length must be >= 2";


    geos::geom::Coordinate coord;

    coord.x = valueToDouble(array->Get(0));
    coord.y = valueToDouble(array->Get(1));
    if (length > 2) {
        coord.z = valueToDouble(array->Get(2));
    }
    precisionModel->makePrecise(&coord);

    return coord;
}
开发者ID:kashif,项目名称:node-geos,代码行数:41,代码来源:geojsonreader.cpp


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