From ba87e3e6c985e7175152993b5efcc7dd2f0e1c93 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Fri, 13 Mar 2009 13:04:22 -0700 Subject: auto import from //branches/cupcake_rel/...@138607 --- tools/aidl/aidl.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'tools/aidl/aidl.cpp') diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp index e24876331c72..fc658f5b54fb 100644 --- a/tools/aidl/aidl.cpp +++ b/tools/aidl/aidl.cpp @@ -609,6 +609,62 @@ generate_dep_file(const Options& options) fclose(to); } +// ========================================================== +static string +generate_outputFileName(const Options& options, const document_item_type* items) +{ + string result; + + // items has already been checked to have only one interface. + if (items->item_type == INTERFACE_TYPE) { + interface_type* type = (interface_type*)items; + + // create the path to the destination folder based on the + // interface package name + result = options.outputBaseFolder; + result += OS_PATH_SEPARATOR; + + string package = type->package; + size_t len = package.length(); + for (size_t i=0; iname.data, '.'); + len = p ? p-type->name.data : strlen(type->name.data); + + result += OS_PATH_SEPARATOR; + result.append(type->name.data, len); + result += ".java"; + } + + return result; +} + +// ========================================================== +static void +check_outputFileName(const string& path) { + size_t len = path.length(); + for (size_t i=0; i 0) { + outputFileName = generate_outputFileName(options, mainDoc); + } + + // make sure the folders of the output file all exists + check_outputFileName(outputFileName); + + err = generate_java(outputFileName, options.inputFileName.c_str(), (interface_type*)mainDoc); return err; -- cgit v1.2.3-59-g8ed1b