Locale* Locale::CreateLocale(const char* l, const char* c, const char* v) { for (auto iter = locales.begin(); iter != locales.end(); ++iter) { if (!_stricmp(l, iter->GetLanguage())) { if (c && *c) { if (!_stricmp(c, iter->GetCountry())) { if (v && *v) { if (!_stricmp(v, iter->GetVariant())) { return &(*iter); } } else { return &(*iter); } } } else { return &(*iter); } } } if (l[0]) { if (c[0]) { if (v[0]) { return new(__FILE__,__LINE__) Locale(l, c, v); } return new(__FILE__,__LINE__) Locale(l, c); } return new(__FILE__,__LINE__) Locale(l); } return 0; }
static duk_ret_t Terrain_SetAttribute_String_Variant_AttributeChange__Type(duk_context* ctx) { int numArgs = duk_get_top(ctx); Terrain* thisObj = GetThisWeakObject<Terrain>(ctx); String id = duk_require_string(ctx, 0); Variant value = GetVariant(ctx, 1); AttributeChange::Type change = numArgs > 2 ? (AttributeChange::Type)(int)duk_require_number(ctx, 2) : AttributeChange::Default; thisObj->SetAttribute(id, value, change); return 0; }
void Control::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const { switch (address.mSelector) { case kCMIOObjectPropertyName: ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOObjectPropertyName"); *static_cast<CFStringRef*>(data) = CopyName(); dataUsed = sizeof(CFStringRef); break; case kCMIOObjectPropertyManufacturer: ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOObjectPropertyManufacturer"); *static_cast<CFStringRef*>(data) = CopyManufacturerName(); dataUsed = sizeof(CFStringRef); break; case kCMIOControlPropertyScope: ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOControlPropertyScope"); *static_cast<CMIOObjectPropertyScope*>(data) = GetPropertyScope(); dataUsed = sizeof(CMIOObjectPropertyScope); break; case kCMIOControlPropertyElement: ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOControlPropertyElement"); *static_cast<CMIOObjectPropertyElement*>(data) = GetPropertyElement(); dataUsed = sizeof(CMIOObjectPropertyElement); break; case kCMIOControlPropertyVariant: ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOControlPropertyVariant"); *static_cast<UInt32*>(data) = GetVariant(); dataUsed = sizeof(UInt32); break; default: Object::GetPropertyData(address, qualifierDataSize, qualifierData, dataSize, dataUsed, data); break; }; }
bool StatementObject::Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { //sprintf(tmp, "stmt Invoke [%s]\n", NPN_UTF8FromIdentifier(name)); log(tmp); NPError rc; VOID_TO_NPVARIANT(*result); int index = 0; if (name == mc_Init_id) { if (argCount < 2) { NPN_SetException(this, "Too few parameters count"); return true; } #if 0 if (!(NPVARIANT_IS_INT32(args[0]) && NPVARIANT_IS_OBJECT(args[1]))) { NPN_SetException(this, "Wrong argument type"); return true; } SQLHANDLE hdbc = (SQLHANDLE)(long)NPVARIANT_TO_INT32(args[0]); #else if (!(NPVARIANT_IS_OBJECT(args[0]) && NPVARIANT_IS_OBJECT(args[1]))) { NPN_SetException(this, "Wrong argument type"); return true; } SQLHANDLE hdbc = (SQLHANDLE)NPVARIANT_TO_OBJECT(args[0]); #endif Init(hdbc, NPVARIANT_TO_OBJECT(args[1])); return true; } else if (name == mc_AddParameter_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } AddParam(args); return true; } else if (name == mc_Execute_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (!NPVARIANT_IS_STRING(args[0])) { NPN_SetException(this, "Wrong argument type"); return true; } Execute((NPString*)&NPVARIANT_TO_STRING(args[0])); return true; } else if (name == mc_Close_id) { Close(); return true; } else if (name == mc_Fetch_id) { bool ret; rc = Fetch(&ret); if (rc != NPERR_NO_ERROR) return true; BOOLEAN_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_MoreResults_id) { bool ret; rc = MoreResults(&ret); if (rc != NPERR_NO_ERROR) return true; BOOLEAN_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_GetColumnName_id) { const char *ret; if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } rc = GetColumnName(index, &ret); if (rc != NPERR_NO_ERROR) return true; STRING_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_GetVariant_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } GetVariant(index, result); return true; } else if (name == mc_GetColumnType_id) { int ret; if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } rc = GetColumnType(index, &ret); if (rc != NPERR_NO_ERROR) return true; INT32_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_IsColumnNullable_id) { bool ret; if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } rc = IsColumnNullable(index, &ret); if (rc != NPERR_NO_ERROR) return true; BOOLEAN_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_GetTables_id) { if (argCount < 4) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } GetTables(&args[0], &args[1], &args[2], &args[3]); return true; } else if (name == mc_GetColumns_id) { if (argCount < 4) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } GetColumns(&args[0], &args[1], &args[2], &args[3]); return true; } else if (name == mc_GetTypeInfo_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } GetTypeInfo(index); return true; } else if (name == mc_GetPrimaryKeys_id) { if (argCount < 3) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } GetPrimaryKeys(&args[0], &args[1], &args[2]); return true; } else if (name == mc_GetForeignKeys_id) { if (argCount < 6) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[4]) || NPVARIANT_IS_STRING(args[4]))) { NPN_SetException(this, "Wrong 5 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[5]) || NPVARIANT_IS_STRING(args[5]))) { NPN_SetException(this, "Wrong 6 argument type"); return true; } GetForeignKeys(&args[0], &args[1], &args[2], &args[3], &args[4], &args[5]); return true; } else if (name == mc_GetProcedures_id) { if (argCount < 3) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } GetProcedures(&args[0], &args[1], &args[2]); return true; } else if (name == mc_GetProcedureColumns_id) { if (argCount < 4) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } GetProcedureColumns(&args[0], &args[1], &args[2], &args[3]); return true; } return false; }