Skip to content

Commit 041c45b

Browse files
committed
OpenXR loader: factor out turning functions content into functions json
1 parent a6dfa10 commit 041c45b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/loader/android_utilities.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,17 @@ static bool getCursor(wrap::android::content::Context const &context, jni::Array
363363
return true;
364364
}
365365

366+
/// Shared helper for populating the functions object in a manifest
367+
static void populateFunctionsData(Cursor &cursor, Json::Value &functionsObject) {
368+
auto functionIndex = cursor.getColumnIndex(functions::Columns::FUNCTION_NAME);
369+
auto symbolIndex = cursor.getColumnIndex(functions::Columns::SYMBOL_NAME);
370+
while (cursor.moveToNext()) {
371+
functionsObject[cursor.getString(functionIndex)] = cursor.getString(symbolIndex);
372+
}
373+
374+
cursor.close();
375+
}
376+
366377
static int populateRuntimeFunctions(wrap::android::content::Context const &context, bool systemBroker,
367378
const std::string &packageName, Json::Value &manifest) {
368379
const jni::Array<std::string> projection = makeArray({functions::Columns::FUNCTION_NAME, functions::Columns::SYMBOL_NAME});
@@ -373,14 +384,8 @@ static int populateRuntimeFunctions(wrap::android::content::Context const &conte
373384
if (!getCursor(context, projection, uri, systemBroker, "functions", cursor)) {
374385
return -1;
375386
}
387+
populateFunctionsData(cursor, manifest["functions"]);
376388

377-
auto functionIndex = cursor.getColumnIndex(functions::Columns::FUNCTION_NAME);
378-
auto symbolIndex = cursor.getColumnIndex(functions::Columns::SYMBOL_NAME);
379-
while (cursor.moveToNext()) {
380-
manifest["functions"][cursor.getString(functionIndex)] = cursor.getString(symbolIndex);
381-
}
382-
383-
cursor.close();
384389
return 0;
385390
}
386391

@@ -464,11 +469,7 @@ static int populateApiLayerFunctions(wrap::android::content::Context const &cont
464469
return -1;
465470
}
466471

467-
auto functionIndex = cursor.getColumnIndex(functions::Columns::FUNCTION_NAME);
468-
auto symbolIndex = cursor.getColumnIndex(functions::Columns::SYMBOL_NAME);
469-
while (cursor.moveToNext()) {
470-
rootNode["api_layer"]["functions"][cursor.getString(functionIndex)] = cursor.getString(symbolIndex);
471-
}
472+
populateFunctionsData(cursor, rootNode["api_layer"]["functions"]);
472473

473474
cursor.close();
474475
return 0;

0 commit comments

Comments
 (0)