From 3fa286b4c2f110c6be2bbfac9c715bb1ec880338 Mon Sep 17 00:00:00 2001 From: Shih-wei Liao Date: Thu, 10 Feb 2011 11:04:44 -0800 Subject: Fix b/3427124. Adding the overloadable invokable feature. Reflect that type of invokables to Java. 1. Add __attribute__((overloadable)) support on the rs side for invokables. Requested by the Books team. 2. Add name mangling support and MangleContext. 3. Add the test P_overload. 4. This CL only affects Honeycomb SDK. It doesn't affect Final ROM. 5. This CL should go in at the same time with another CL on external/clang.git (to be done now.) Change-Id: I9e743894a97626d8c27b0dd9c0a51cef1175d2ab --- slang_rs_export_func.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'slang_rs_export_func.h') diff --git a/slang_rs_export_func.h b/slang_rs_export_func.h index 3a16c6d..101080a 100644 --- a/slang_rs_export_func.h +++ b/slang_rs_export_func.h @@ -43,12 +43,27 @@ class RSExportFunc : public RSExportable { private: std::string mName; + std::string mMangledName; + bool mShouldMangle; RSExportRecordType *mParamPacketType; - RSExportFunc(RSContext *Context, const llvm::StringRef &Name) + RSExportFunc(RSContext *Context, const llvm::StringRef &Name, + const clang::FunctionDecl *FD) : RSExportable(Context, RSExportable::EX_FUNC), mName(Name.data(), Name.size()), + mMangledName(), + mShouldMangle(false), mParamPacketType(NULL) { + + mShouldMangle = Context->getMangleContext().shouldMangleDeclName(FD); + + if (mShouldMangle) { + llvm::SmallString<256> Buffer; + Context->getMangleContext().mangleName(FD, Buffer); + + mMangledName = Buffer.str(); + } + return; } @@ -69,7 +84,9 @@ class RSExportFunc : public RSExportable { return mParamPacketType->fields_end(); } - inline const std::string &getName() const { return mName; } + inline const std::string &getName(bool mangle=true) const { + return (mShouldMangle && mangle) ? mMangledName : mName; + } inline bool hasParam() const { return (mParamPacketType && !mParamPacketType->getFields().empty()); } -- cgit v1.2.3