Search code examples
androidc++java-native-interface

What does this C++ code mean? 'const ResTable& res = am->getResources();'


I'm trying to understand how R file is read in android, everything went well before I see this line:

const ResTable& res = am->getResources();

I found this line at file

core/jni/android/android_util_AssetManager.cpp

in method

static jobject android_content_AssetManager_getAssignedPackageIdentifiers(JNIEnv* env, jobject clazz)

I have learned some c&cpp before, but have never seen syntax like this, what does this mean? I found ResTable is a class, but I can't find symbol 'res' anywhere. Is this file I'm reading broken or I'm I missing something?

thanks for any help!


Solution

  • It calls the getResources method for the AssetManager instance pointed to by am and saves the result in res. The type of res is const ResTable&, i.e. a reference to a const ResTable (which also is the return type of AssetManager::getResources).