0

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!

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
gaolf
  • 53
  • 5
  • `res` is a new reference to a constant `ResTable` that is returned from the method `am->getResources()` . If this is still a problem try an introduction to C++ book. – Richard Critten Jan 12 '16 at 12:36
  • http://stackoverflow.com/a/596750/2491746 – Simple Jan 12 '16 at 12:39
  • Oh now I recall it, reference... I have never used it even I have learned about it, almost forgot reference. Thanks a lot! Now I can go on reading! – gaolf Jan 13 '16 at 08:05

1 Answers1

3

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).

Michael
  • 57,169
  • 9
  • 80
  • 125