Esempio n. 1
0
GDALDataType TypedArray::Identify(Handle<Object> obj) {	
	switch(obj->GetIndexedPropertiesExternalArrayDataType()){
		case kExternalByteArray:          return GDT_Byte;
		case kExternalUnsignedByteArray:  return GDT_Byte;
		case kExternalShortArray:         return GDT_Int16;
		case kExternalUnsignedShortArray: return GDT_UInt16;
		case kExternalIntArray:           return GDT_Int32;
		case kExternalUnsignedIntArray:   return GDT_UInt32;
		case kExternalFloatArray:         return GDT_Float32;
		case kExternalDoubleArray:        return GDT_Float64;
		default:                          return GDT_Unknown;
	}
}
Esempio n. 2
0
  void TypedArray (const Wrapper* wrapper, Handle<Value> value, vector<void*>& natives) {
    void *buff = NULL;
    size_t byteLength = 0;

    if (value->IsObject()) {
      Handle<Object> obj = value->ToObject();
      if (obj->HasIndexedPropertiesInExternalArrayData()) {
        buff = obj->GetIndexedPropertiesExternalArrayData();
        byteLength = obj->GetIndexedPropertiesExternalArrayDataLength();

        switch (obj->GetIndexedPropertiesExternalArrayDataType()) {
        case kExternalByteArray:
        case kExternalUnsignedByteArray:
        case kExternalPixelArray:
          break;
        case kExternalShortArray:
        case kExternalUnsignedShortArray:
          byteLength *= 2;
          break;
        case kExternalIntArray:
        case kExternalUnsignedIntArray:
        case kExternalFloatArray:
          byteLength *= 4;
          break;
        case kExternalDoubleArray:
          byteLength *= 8;
          break;
        }
      } else {
        buff = Get<void*>(value);
      }
    }

    PushBackWrapped(natives, buff);
    PushBackWrapped(natives, byteLength);
  }