const char* GetClipboardText(){ JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "getClipboardText", "()Ljava/lang/String;"); if (mid == 0) return std::string("").c_str(); jstring jPref = (jstring) env->CallStaticObjectMethod(cls, mid); return JStringToStdString(env,jPref,true).c_str(); }
void setTransform(const SoundTransform &inTransform) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/Sound"); jstring path = env->NewStringUTF(mSoundPath.c_str()); jmethodID mid = env->GetStaticMethodID(cls, "setMusicTransform", "(Ljava/lang/String;DD)V"); if (mid > 0 ) { env->CallStaticVoidMethod(cls, mid, path, inTransform.volume*((1-inTransform.pan)/2), inTransform.volume*((inTransform.pan+1)/2)); } }
void stop() { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/Sound"); jstring path = env->NewStringUTF(mSoundPath.c_str()); jmethodID mid = env->GetStaticMethodID(cls, "stopMusic", "(Ljava/lang/String;)V"); if (mid > 0) { env->CallStaticVoidMethod(cls, mid, path); } }
double getRight() { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/Sound"); jstring path = env->NewStringUTF(mSoundPath.c_str()); jmethodID mid = env->GetStaticMethodID(cls, "getRight", "(Ljava/lang/String;)D"); if (mid > 0) { return env->CallStaticDoubleMethod(cls, mid, path); } return -1; }
bool isComplete() { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/Sound"); jstring path = env->NewStringUTF(mSoundPath.c_str()); jmethodID mid = env->GetStaticMethodID(cls, "getComplete", "(Ljava/lang/String;)Z"); if (mid > 0) { return env->CallStaticBooleanMethod(cls, mid, path); } return false; }
double CapabilitiesGetScreenResolutionY () { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "CapabilitiesGetScreenResolutionY", "()D"); if (mid == 0) return 1; return env->CallStaticDoubleMethod (cls, mid); }
HWND CreateRootWindow() { static HWND hRoot; HWND32 lpRootWindow; HCLASS32 hClassRoot32; WNDCLASSEX RootClass; int nScreenWidth,nScreenHeight; if(hRoot) return hRoot; /* Check if class has been registered */ if (!(hClassRoot32 = FindClass((LPSTR)"ROOTWClass",(HANDLE)0))) { return (HWND)0; } /* Get class information */ InternalGetClassInfoEx(hClassRoot32,&RootClass); /* Create handle for the new window */ if (!(lpRootWindow = CREATEHWIN(hRoot))) { RELEASECLASSINFO(hClassRoot32); return 0; } /* Set root window proc */ lpRootWindow->lpfnWndProc = RootClass.lpfnWndProc; /* set style & flags*/ lpRootWindow->dwStyle = WS_POPUP|WS_VISIBLE; lpRootWindow->dwWinFlags = 0L; /* set class pointer */ lpRootWindow->hWindowClass32 = hClassRoot32; /* for now root window doesn't have any extra bytes */ /* Set root window size */ nScreenWidth = GetSystemMetrics(SM_CXSCREEN); nScreenHeight = GetSystemMetrics(SM_CYSCREEN); SetRect(&lpRootWindow->rWnd,0,0,nScreenWidth,nScreenHeight); lpRootWindow->wWidth = nScreenWidth; lpRootWindow->wHeight = nScreenHeight; /* Every window must have a task. It determines the queue to use */ lpRootWindow->hTask = GetCurrentTask(); RELEASEWININFO(lpRootWindow); RELEASECLASSINFO(hClassRoot32); return hRoot; }
MgFeatureSchemaCollection* MgFeatureServiceCacheEntry::GetSchemas(CREFSTRING schemaName, MgStringCollection* classNames, bool serialized) { STRING schemaKey, classKey; INT32 classCount = FormatKeys(m_classNameHintUsed, schemaName, classNames, schemaKey, classKey); Ptr<MgFeatureSchemaCollection> data; Ptr<MgFeatureSchemaCacheItem> item = GetFeatureSchemaCacheItem(schemaKey); // Get the data from the current item. if (NULL != item.p) { data = item->GetSchemas(classKey, serialized); } // If the data is not found, then try to find it in the superset data from the current item or superset one. if (NULL == data.p) { if (0 == classCount) { ACE_ASSERT(classKey.empty()); // If there is no class, then try to find the data in the superset data from the superset item. data = FindSchema(schemaKey, classKey, serialized, classCount); } else if (1 == classCount) { Ptr<MgFeatureSchemaCollection> supersetData; // Get the superset data from the current item. if (NULL != item.p && !classKey.empty()) { supersetData = item->GetSchemas(L"", serialized); } // If the data is not found, then try to find it in the superset data from the superset item. if (NULL == supersetData.p) { data = FindSchema(schemaKey, classKey, serialized, classCount); } // Otherwise, determine if the superset data from the current item is reusable. else if (FindClass(supersetData.p, classKey)) { data = supersetData; } } // Update the cache with the found data. if (NULL != data.p) { SetSchemas(schemaKey, classNames, serialized, data.p); } } return data.Detach(); }
void reloadSound() { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/Sound"); jmethodID mid = env->GetStaticMethodID(cls, "getSoundHandle", "(Ljava/lang/String;)I"); if (mid > 0) { jstring path = env->NewStringUTF(mSoundPath.c_str()); handleID = env->CallStaticIntMethod(cls, mid, path); //env->ReleaseStringUTFChars(path, mSoundName.c_str() ); } }
void ClassInfo::GetClassMethods(MethodVec &ret, const char *classname, int type /* = 0 */) { if (classname && *classname) { const ClassInfo *classInfo = NULL; switch (type) { case 0: classInfo = FindClass(classname); if (classInfo == NULL) { classInfo = FindInterface(classname); type = 2; } break; case 1: classInfo = FindClass(classname); break; case 2: classInfo = FindInterface(classname); break; default: ASSERT(false); } if (classInfo) { const ClassInfo::MethodVec &methods = classInfo->getMethodsVec(); ret.insert(ret.end(), methods.begin(), methods.end()); if (type != 2) { const char *parentClass = classInfo->getParentClass(); if (parentClass && *parentClass) { GetClassMethods(ret, parentClass, 1); } } const ClassInfo::InterfaceVec &interfaces = classInfo->getInterfacesVec(); for (unsigned int i = 0; i < interfaces.size(); i++) { GetClassMethods(ret, interfaces[i], 2); } } } }
void stop() { if (mStreamID > -1) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/Sound"); jmethodID mid = env->GetStaticMethodID(cls, "stopSound", "(I)V"); if (mid > 0){ env->CallStaticVoidMethod(cls, mid, mStreamID); } } }
bool ClearUserPreference(const char *inId) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "clearUserPreference", "(Ljava/lang/String;)V"); if (mid == 0) return false; jstring jInId = env->NewStringUTF( inId ); env->CallStaticVoidMethod(cls, mid, jInId ); return true; }
std::string CapabilitiesGetLanguage() { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "CapabilitiesGetLanguage", "()Ljava/lang/String;"); if(mid == 0) return std::string(""); jstring jLang = (jstring) env->CallStaticObjectMethod(cls, mid); const char *nativeLang = env->GetStringUTFChars(jLang, 0); std::string result(nativeLang); env->ReleaseStringUTFChars(jLang, nativeLang); return result; }
bool SetClipboardText(const char* text) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "setClipboardText", "(Ljava/lang/String;)Z"); if (mid == 0) return false; jstring jtext = env->NewStringUTF( text ); bool result = env->CallStaticBooleanMethod (cls, mid, jtext); env->DeleteLocalRef(jtext); return result; }
bool CEntityClassRegistry::UnregisterEntityClass( IEntityClass *pClass ) { assert( pClass != NULL ); if (FindClass(pClass->GetName())) { m_mapClassName.erase(pClass->GetName()); NotifyListeners(ECRE_CLASS_UNREGISTERED, pClass); pClass->Release(); return true; } return false; }
PClass *PClass::CreateDerivedClass(FName name, unsigned int size) { assert(size >= Size); PClass *type; bool notnew; const PClass *existclass = FindClass(name); if (existclass != nullptr) { // This is a placeholder so fill it in if (existclass->Size == TentativeClass) { type = const_cast<PClass*>(existclass); if (!IsDescendantOf(type->ParentClass)) { I_Error("%s must inherit from %s but doesn't.", name.GetChars(), type->ParentClass->TypeName.GetChars()); } DPrintf(DMSG_SPAMMY, "Defining placeholder class %s\n", name.GetChars()); notnew = true; } else { // a different class with the same name already exists. Let the calling code deal with this. return nullptr; } } else { type = new PClass; notnew = false; } type->TypeName = name; type->bRuntimeClass = true; Derive(type, name); type->Size = size; if (size != TentativeClass) { NewClassType(type); type->InitializeDefaults(); type->Virtuals = Virtuals; } else type->bOptional = false; if (!notnew) { type->InsertIntoHash(false); } return type; }
double getLength() { if (mLength == 0) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/Sound"); jstring path = env->NewStringUTF(mSoundPath.c_str()); jmethodID mid = env->GetStaticMethodID(cls, "getDuration", "(Ljava/lang/String;)I"); if (mid > 0) { mLength = env->CallStaticIntMethod(cls, mid, path); } } return mLength; }
AndroidSound(float *inData, int len, bool inForceMusic) { JNIEnv *env = GetEnv(); jbyteArray data = env->NewByteArray(len); env->SetByteArrayRegion(data, 0, len, (const jbyte *)inData); jclass cls = FindClass("org/haxe/nme/Sound"); jmethodID mid = env->GetStaticMethodID(cls, "getSoundPathByByteArray", "([B)Ljava/lang/String;"); jstring jname = (jstring)env->CallStaticObjectMethod(cls, mid, data); std::string inPath = std::string(env->GetStringUTFChars(jname, NULL)); loadWithPath(inPath, inForceMusic); }
AAsset *AndroidGetAsset(const char *inResource) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "getAssetManager", "()Landroid/content/res/AssetManager;"); if (mid == 0) return 0; jobject assetManager = (jobject)env->CallStaticObjectMethod(cls, mid); assert(0 != assetManager); AAssetManager* mgr = AAssetManager_fromJava(env, assetManager); assert(0 != mgr); return AAssetManager_open(mgr, inResource, AASSET_MODE_UNKNOWN); }
bool LaunchBrowser(const char *inUtf8URL) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "launchBrowser", "(Ljava/lang/String;)V"); if (mid == 0) return false; jstring str = env->NewStringUTF( inUtf8URL ); env->CallStaticVoidMethod(cls, mid, str ); return true; }
void SHM_DrawPage( hobj_t *page ) { int i; char entryname[256]; shm_funcmap_t *map; hpair_t *pair; hobj_t *entry; // hobj_search_iterator_t *iter; pair = FindHPair( page, "active" ); __chkptr( pair ); i = 255; for( ; ; ) { sprintf( entryname, "%d", i ); entry = FindClass( page, entryname ); if( !entry ) { if( i >= 255 ) { i = 0; continue; } else { break; } } map = SHM_LookupFuncmap( entry->type ); if( !map ) { __warning( "unknown widget type '%s'\n", entry->type ); continue; } if( !map->drawfunc ) __error( "no drawfunc for '%s'\n", entry->type ); if( !strcmp( pair->value, entry->name ) ) { map->drawfunc( entry, 1 ); } else map->drawfunc( entry, 0 ); i++; } }
CClass *CCodeProcessor::AddClass( const char *classname ) { CClass *cl = FindClass( classname ); if ( !cl ) { cl = new CClass( classname ); m_nClassesParsed++; cl->m_pNext = m_pClassList; m_pClassList = cl; } return cl; }
std::string GetUserPreference(const char *inId) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "getUserPreference", "(Ljava/lang/String;)Ljava/lang/String;"); if (mid == 0) { return std::string(""); } jstring jInId = env->NewStringUTF(inId); jstring jPref = (jstring) env->CallStaticObjectMethod(cls, mid, jInId); env->DeleteLocalRef(jInId); return JStringToStdString(env,jPref,true); }
bool ClassInfo::hasMethod(const char *name) const { ASSERT(name); const MethodMap &methods = getMethods(); MethodMap::const_iterator it = methods.find(name); if (it != methods.end()) { MethodInfo *m = it->second; if (m->invokeFn) { return *(m->invokeFn) != m->invokeFailedFn; } return true; } const ClassInfo *parent = FindClass(getParentClass()); return parent && parent->hasMethod(name); }
AndroidMusicChannel(Object *inSound, const std::string &inPath, double startTime, int loops, const SoundTransform &inTransform) { JNIEnv *env = GetEnv(); mState = 0; mSound = inSound; inSound->IncRef(); jclass cls = FindClass("org/haxe/nme/Sound"); jstring path = env->NewStringUTF(inPath.c_str()); jmethodID mid = env->GetStaticMethodID(cls, "playMusic", "(Ljava/lang/String;DDID)I"); if (mid > 0) { mState = env->CallStaticIntMethod(cls, mid, path, inTransform.volume*((1-inTransform.pan)/2), inTransform.volume*((inTransform.pan+1)/2), loops, startTime); } mSoundPath = inPath; }
void CEntityClassRegistry::LoadClassDescription( XmlNodeRef &root,bool bOnlyNewClasses ) { assert( root != (IXmlNode*)NULL ); if (root->isTag("Entity")) { const char *sName = root->getAttr("Name"); if (*sName == 0) return; // Empty name. const char *sScript = root->getAttr("Script"); IEntityClass *pClass = FindClass( sName ); if (!pClass) { // New class. SEntityClassDesc cd; cd.flags = 0; cd.sName = sName; cd.sScriptFile = sScript; bool bInvisible = false; if (root->getAttr("Invisible",bInvisible)) { if (bInvisible) cd.flags |= ECLF_INVISIBLE; } bool bBBoxSelection = false; if (root->getAttr("BBoxSelection",bBBoxSelection)) { if (bBBoxSelection) cd.flags |= ECLF_BBOX_SELECTION; } RegisterStdClass( cd ); } else { // This class already registered. if (!bOnlyNewClasses) { EntityWarning( "[CEntityClassRegistry] LoadClassDescription failed, Entity Class name %s already registered",sName ); } } } }
std::string GetUserPreference(const char *inId) { JNIEnv *env = GetEnv(); jclass cls = FindClass("org/haxe/nme/GameActivity"); jmethodID mid = env->GetStaticMethodID(cls, "getUserPreference", "(Ljava/lang/String;)Ljava/lang/String;"); if (mid == 0) { return std::string(""); } jstring jInId = env->NewStringUTF(inId); jstring jPref = (jstring) env->CallStaticObjectMethod(cls, mid, jInId); env->DeleteLocalRef(jInId); const char *nativePref = env->GetStringUTFChars(jPref, 0); std::string result(nativePref); env->ReleaseStringUTFChars(jPref, nativePref); return result; }
AndroidSoundChannel(Object *inSound, int inHandle, double startTime, int loops, const SoundTransform &inTransform) { //LOGV("Android Sound Channel create, in handle, %d",inHandle); JNIEnv *env = GetEnv(); mStreamID = -1; mSound = inSound; mSoundHandle = inHandle; mLoop = (loops < 1) ? 1 : loops; inSound->IncRef(); if (inHandle >= 0) { jclass cls = FindClass("org/haxe/nme/Sound"); jmethodID mid = env->GetStaticMethodID(cls, "playSound", "(IDDI)I"); if (mid > 0) { mStreamID = env->CallStaticIntMethod(cls, mid, inHandle, inTransform.volume*((1-inTransform.pan)/2), inTransform.volume*((inTransform.pan+1)/2), mLoop ); } } }
PClass *PClass::FindClassTentative(FName name) { if (name == NAME_None) { return nullptr; } PClass *found = FindClass(name); if (found != nullptr) return found; PClass *type = new PClass; DPrintf(DMSG_SPAMMY, "Creating placeholder class %s : %s\n", name.GetChars(), TypeName.GetChars()); Derive(type, name); type->Size = TentativeClass; type->InsertIntoHash(false); return type; }
bool CEntityClassRegistry::RegisterEntityClass( IEntityClass *pClass ) { assert( pClass != NULL ); bool newClass = false; if ((pClass->GetFlags() & ECLF_MODIFY_EXISTING) == 0) { IEntityClass *pOldClass = FindClass(pClass->GetName()); if (pOldClass) { EntityWarning( "CEntityClassRegistry::RegisterEntityClass failed, class with name %s already registered", pOldClass->GetName() ); return false; } newClass = true; } m_mapClassName[pClass->GetName()] = pClass; NotifyListeners(newClass ? ECRE_CLASS_REGISTERED : ECRE_CLASS_MODIFIED, pClass); return true; }