More coding style fixing to improve the readability. No actual semantics
changed. This also makes cpplint happy.
diff --git a/libslang.cpp b/libslang.cpp
index 4617920..089c52a 100644
--- a/libslang.cpp
+++ b/libslang.cpp
@@ -1,4 +1,4 @@
-#include "slang.hpp"
+#include "slang.h"
using namespace slang;
diff --git a/llvm-rs-link.cpp b/llvm-rs-link.cpp
index 4ccb88d..45ce77e 100644
--- a/llvm-rs-link.cpp
+++ b/llvm-rs-link.cpp
@@ -1,3 +1,7 @@
+#include <memory>
+#include <string>
+#include <vector>
+
#include "llvm/Linker.h"
#include "llvm/LLVMContext.h"
#include "llvm/Metadata.h"
@@ -16,9 +20,6 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/LinkAllVMCore.h"
-#include <memory>
-#include <string>
-#include <vector>
using namespace llvm;
@@ -109,7 +110,8 @@
for (unsigned i = 1; i < InputFilenames.size(); ++i) {
std::auto_ptr<Module> M(LoadFile(argv[0], InputFilenames[i], Context));
if (M.get() == 0) {
- errs() << argv[0] << ": error loading file '" << InputFilenames[i]<< "'\n";
+ errs() << argv[0] << ": error loading file '" << InputFilenames[i]
+ << "'\n";
return 1;
}
if (Linker::LinkModules(Composite.get(), M.get(), &ErrorMessage)) {
diff --git a/slang.cpp b/slang.cpp
index 77e8467..35891a4 100644
--- a/slang.cpp
+++ b/slang.cpp
@@ -1,23 +1,24 @@
-#include "slang.hpp"
-#include "libslang.h"
-#include "slang_rs_export_func.hpp"
-
-#include "llvm/Target/TargetSelect.h" /* for function LLVMInitialize[ARM|X86][TargetInfo|Target|AsmPrinter]() */
-
-#include "llvm/Support/MemoryBuffer.h" /* for class llvm::MemoryBuffer */
-#include "llvm/Support/ErrorHandling.h" /* for function llvm::install_fatal_error_handler() */
-#include "llvm/Support/ManagedStatic.h" /* for class llvm::llvm_shutdown */
-
-#include "clang/Basic/TargetInfo.h" /* for class clang::TargetInfo */
-#include "clang/Basic/LangOptions.h" /* for class clang::LangOptions */
-#include "clang/Basic/TargetOptions.h" /* for class clang::TargetOptions */
-
-#include "clang/Frontend/FrontendDiagnostic.h" /* for clang::diag::* */
-
-#include "clang/Parse/ParseAST.h" /* for function clang::ParseAST() */
+#include "slang.h"
#include <stdlib.h>
+#include "llvm/Target/TargetSelect.h"
+
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ManagedStatic.h"
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/TargetOptions.h"
+
+#include "clang/Frontend/FrontendDiagnostic.h"
+
+#include "clang/Parse/ParseAST.h"
+
+#include "libslang.h"
+#include "slang_rs_export_func.h"
+
using namespace slang;
#if defined(__arm__)
@@ -34,10 +35,23 @@
// Language option (define the language feature for compiler such as C99)
clang::LangOptions Slang::LangOpts;
-/* Code generation option for the compiler */
+// Code generation option for the compiler
clang::CodeGenOptions Slang::CodeGenOpts;
-const std::string Slang::TargetDescription = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32";
+const std::string Slang::TargetDescription =
+ "e-" // little-endian
+ "p:32:32:32-" // 32-bit pointer
+ "i1:8:8-"
+ "i8:8:8-"
+ "i16:16:16-"
+ "i32:32:32-"
+ "i64:64:64-"
+ "f32:32:32-"
+ "f64:64:64-"
+ "v64:64:64-" // 64-bit vector (e.g. float2, int2, short4)
+ "v128:128:128-"
+ "a0:0:64-"
+ "n32"; // native CPU only support 32-bit integer width.
// The named of metadata node that pragma resides (should be synced with
// bcc.cpp)
@@ -91,7 +105,7 @@
mTargetOpts));
if (Features != NULL)
- for (int i = 0; Features[i]!=NULL; i++)
+ for (int i = 0; Features[i] != NULL; i++)
mTargetOpts.Features.push_back(Features[i]);
return;
@@ -131,10 +145,9 @@
return;
}
-Slang::Slang(const char *Triple, const char *CPU, const char **Features) :
- mOutputType(SlangCompilerOutput_Default),
- mAllowRSPrefix(false)
-{
+Slang::Slang(const char *Triple, const char *CPU, const char **Features)
+ : mOutputType(SlangCompilerOutput_Default),
+ mAllowRSPrefix(false) {
GlobalInitialization();
createDiagnostic();
@@ -147,14 +160,17 @@
return;
}
-bool Slang::setInputSource(llvm::StringRef inputFile, const char *text, size_t textLength) {
+bool Slang::setInputSource(llvm::StringRef inputFile,
+ const char *text,
+ size_t textLength) {
mInputFileName = inputFile.str();
// Reset the ID tables if we are reusing the SourceManager
mSourceMgr->clearIDTables();
// Load the source
- llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getMemBuffer(text, text + textLength);
+ llvm::MemoryBuffer *SB =
+ llvm::MemoryBuffer::getMemBuffer(text, text + textLength);
mSourceMgr->createMainFileIDForMemBuffer(SB);
if (mSourceMgr->getMainFileID().isInvalid()) {
@@ -204,7 +220,7 @@
if (len + 1 <= sizeof(buf))
tmp = buf;
else
- tmp = new char [len + 1];
+ tmp = new char[len + 1];
strcpy(tmp, file);
@@ -231,7 +247,7 @@
switch (mOutputType) {
case SlangCompilerOutput_Assembly:
case SlangCompilerOutput_LL: {
- mOS.reset( new llvm::raw_fd_ostream(outputFile, Error, 0) );
+ mOS.reset(new llvm::raw_fd_ostream(outputFile, Error, 0));
break;
}
case SlangCompilerOutput_Nothing: {
@@ -334,9 +350,11 @@
const char* Slang::exportFuncs() {
std::string fNames;
- for (RSContext::const_export_func_iterator I=mRSContext->export_funcs_begin();
- I != mRSContext->export_funcs_end();
- ++I) {
+ for (RSContext::const_export_func_iterator
+ I = mRSContext->export_funcs_begin(),
+ E = mRSContext->export_funcs_end();
+ I != E;
+ I++) {
RSExportFunc* func = *I;
fNames.push_back(',');
fNames.append(func->getName());
diff --git a/slang.hpp b/slang.h
similarity index 91%
rename from slang.hpp
rename to slang.h
index 67284d6..0000f38 100644
--- a/slang.hpp
+++ b/slang.h
@@ -1,12 +1,8 @@
-#ifndef _SLANG_COMPILER_SLANG_HPP
-# define _SLANG_COMPILER_SLANG_HPP
+#ifndef _SLANG_COMPILER_SLANG_H
+#define _SLANG_COMPILER_SLANG_H
-#include "slang_backend.hpp"
-#include "slang_rs_context.hpp"
-#include "slang_rs_backend.hpp"
-#include "slang_pragma_recorder.hpp"
-#include "slang_diagnostic_buffer.hpp"
-
+#include <cstdio>
+#include <string>
#include <vector>
#include "llvm/Support/raw_ostream.h"
@@ -21,21 +17,25 @@
#include "clang/Lex/HeaderSearch.h"
#include "clang/Basic/Diagnostic.h"
-#include "clang/Sema/SemaDiagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/TargetOptions.h"
-#include <cstdio>
-#include <string>
+#include "clang/Sema/SemaDiagnostic.h"
+
+#include "slang_backend.h"
+#include "slang_rs_context.h"
+#include "slang_rs_backend.h"
+#include "slang_pragma_recorder.h"
+#include "slang_diagnostic_buffer.h"
namespace llvm {
-class TargetInfo;
+ class TargetInfo;
}
namespace clang {
-class LangOptions;
-class CodeGenOptions;
-class TargetOptions;
+ class LangOptions;
+ class CodeGenOptions;
+ class TargetOptions;
}
namespace slang {
@@ -176,11 +176,11 @@
void setOutputType(SlangCompilerOutputTy outputType);
inline bool setOutput(FILE *stream) {
- if(stream == NULL)
+ if (stream == NULL)
return false;
- mOS.reset(
- new llvm::raw_fd_ostream(fileno(stream), /* shouldClose */false));
+ mOS.reset(new llvm::raw_fd_ostream(fileno(stream),
+ /* shouldClose */false));
return true;
}
@@ -218,7 +218,6 @@
~Slang();
};
-
}
-#endif // _SLANG_COMPILER_SLANG_HPP
+#endif // _SLANG_COMPILER_SLANG_H
diff --git a/slang_backend.cpp b/slang_backend.cpp
index 90806d0..06ed418 100644
--- a/slang_backend.cpp
+++ b/slang_backend.cpp
@@ -1,5 +1,4 @@
-#include "slang.hpp"
-#include "slang_backend.hpp"
+#include "slang_backend.h"
#include "llvm/Module.h"
#include "llvm/Metadata.h"
@@ -28,6 +27,8 @@
#include "clang/CodeGen/ModuleBuilder.h"
+#include "slang.h"
+
using namespace slang;
bool Backend::CreateCodeGenPasses() {
@@ -49,7 +50,7 @@
std::string Error;
const llvm::Target* TargetInfo =
llvm::TargetRegistry::lookupTarget(Triple, Error);
- if(TargetInfo == NULL) {
+ if (TargetInfo == NULL) {
mDiags.Report(clang::diag::err_fe_unable_to_create_target) << Error;
return false;
}
@@ -116,7 +117,7 @@
OptLevel = llvm::CodeGenOpt::Aggressive;
llvm::TargetMachine::CodeGenFileType CGFT =
- llvm::TargetMachine::CGFT_AssemblyFile;;
+ llvm::TargetMachine::CGFT_AssemblyFile;
if (mOutputType == SlangCompilerOutput_Obj)
CGFT = llvm::TargetMachine::CGFT_ObjectFile;
if (TM->addPassesToEmitFile(*mCodeGenPasses, FormattedOutStream,
@@ -135,25 +136,25 @@
llvm::raw_ostream *OS,
SlangCompilerOutputTy OutputType,
clang::SourceManager &SourceMgr,
- bool AllowRSPrefix) :
- ASTConsumer(),
- mCodeGenOpts(CodeGenOpts),
- mTargetOpts(TargetOpts),
- mSourceMgr(SourceMgr),
- mpOS(OS),
- mOutputType(OutputType),
- mpTargetData(NULL),
- mGen(NULL),
- mPerFunctionPasses(NULL),
- mPerModulePasses(NULL),
- mCodeGenPasses(NULL),
- mAllowRSPrefix(AllowRSPrefix),
- mLLVMContext(llvm::getGlobalContext()),
- mDiags(Diags),
- mpModule(NULL),
- mPragmas(Pragmas)
-{
- FormattedOutStream.setStream(*mpOS, llvm::formatted_raw_ostream::PRESERVE_STREAM);
+ bool AllowRSPrefix)
+ : ASTConsumer(),
+ mCodeGenOpts(CodeGenOpts),
+ mTargetOpts(TargetOpts),
+ mSourceMgr(SourceMgr),
+ mpOS(OS),
+ mOutputType(OutputType),
+ mpTargetData(NULL),
+ mGen(NULL),
+ mPerFunctionPasses(NULL),
+ mPerModulePasses(NULL),
+ mCodeGenPasses(NULL),
+ mAllowRSPrefix(AllowRSPrefix),
+ mLLVMContext(llvm::getGlobalContext()),
+ mDiags(Diags),
+ mpModule(NULL),
+ mPragmas(Pragmas) {
+ FormattedOutStream.setStream(*mpOS,
+ llvm::formatted_raw_ostream::PRESERVE_STREAM);
mGen = CreateLLVMCodeGen(mDiags, "", mCodeGenOpts, mLLVMContext);
return;
}
@@ -253,7 +254,7 @@
switch (mOutputType) {
case SlangCompilerOutput_Assembly:
case SlangCompilerOutput_Obj: {
- if(!CreateCodeGenPasses())
+ if (!CreateCodeGenPasses())
return;
mCodeGenPasses->doInitialization();
@@ -261,7 +262,7 @@
for (llvm::Module::iterator I = mpModule->begin(), E = mpModule->end();
I != E;
I++)
- if(!I->isDeclaration())
+ if (!I->isDeclaration())
mCodeGenPasses->run(*I);
mCodeGenPasses->doFinalization();
diff --git a/slang_backend.hpp b/slang_backend.h
similarity index 91%
rename from slang_backend.hpp
rename to slang_backend.h
index fce4ce0..b434262 100644
--- a/slang_backend.hpp
+++ b/slang_backend.h
@@ -1,8 +1,5 @@
-#ifndef _SLANG_COMPILER_BACKEND_HPP
-# define _SLANG_COMPILER_BACKEND_HPP
-
-#include "libslang.h"
-#include "slang_pragma_recorder.hpp"
+#ifndef _SLANG_COMPILER_BACKEND_H
+#define _SLANG_COMPILER_BACKEND_H
#include "llvm/PassManager.h"
@@ -15,23 +12,26 @@
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Basic/SourceManager.h"
+#include "libslang.h"
+#include "slang_pragma_recorder.h"
+
namespace llvm {
-class LLVMContext;
-class NamedMDNode;
-class raw_ostream;
-class Module;
+ class LLVMContext;
+ class NamedMDNode;
+ class raw_ostream;
+ class Module;
}
namespace clang {
-class ASTConsumer;
-class Diagnostic;
-class TargetOptions;
-class PragmaList;
-class CodeGenerator;
-class ASTContext;
-class DeclGroupRef;
-class TagDecl;
-class VarDecl;
+ class ASTConsumer;
+ class Diagnostic;
+ class TargetOptions;
+ class PragmaList;
+ class CodeGenerator;
+ class ASTContext;
+ class DeclGroupRef;
+ class TagDecl;
+ class VarDecl;
}
namespace slang {
@@ -57,7 +57,7 @@
// Passes apply on function scope in a translation unit
llvm::FunctionPassManager *mPerFunctionPasses;
// Passes apply on module scope
- llvm::PassManager* mPerModulePasses;
+ llvm::PassManager *mPerModulePasses;
// Passes for code emission
llvm::FunctionPassManager *mCodeGenPasses;
@@ -157,4 +157,4 @@
} // namespace slang
-#endif // _SLANG_COMPILER_BACKEND_HPP
+#endif // _SLANG_COMPILER_BACKEND_H
diff --git a/slang_diagnostic_buffer.cpp b/slang_diagnostic_buffer.cpp
index 885b68f..53820cc 100644
--- a/slang_diagnostic_buffer.cpp
+++ b/slang_diagnostic_buffer.cpp
@@ -1,4 +1,4 @@
-#include "slang_diagnostic_buffer.hpp"
+#include "slang_diagnostic_buffer.h"
#include "llvm/ADT/SmallString.h"
diff --git a/slang_diagnostic_buffer.hpp b/slang_diagnostic_buffer.h
similarity index 60%
rename from slang_diagnostic_buffer.hpp
rename to slang_diagnostic_buffer.h
index 6c8bfdf..3ed48be 100644
--- a/slang_diagnostic_buffer.hpp
+++ b/slang_diagnostic_buffer.h
@@ -1,5 +1,5 @@
-#ifndef _SLANG_DIAGNOSTIC_BUFFER_HPP
-# define _SLANG_DIAGNOSTIC_BUFFER_HPP
+#ifndef _SLANG_DIAGNOSTIC_BUFFER_H
+#define _SLANG_DIAGNOSTIC_BUFFER_H
#include "llvm/Support/raw_ostream.h"
@@ -8,7 +8,7 @@
#include <string>
namespace llvm {
-class raw_string_ostream;
+ class raw_string_ostream;
}
namespace slang {
@@ -17,7 +17,7 @@
class DiagnosticBuffer : public clang::DiagnosticClient {
private:
std::string mDiags;
- llvm::raw_string_ostream* mSOS;
+ llvm::raw_string_ostream *mSOS;
public:
DiagnosticBuffer();
@@ -25,12 +25,18 @@
virtual void HandleDiagnostic(clang::Diagnostic::Level DiagLevel,
const clang::DiagnosticInfo& Info);
- inline const std::string &str() const { mSOS->flush(); return mDiags; }
+ inline const std::string &str() const {
+ mSOS->flush();
+ return mDiags;
+ }
- inline void reset() { this->mSOS->str().clear(); return; }
+ inline void reset() {
+ this->mSOS->str().clear();
+ return;
+ }
virtual ~DiagnosticBuffer();
};
}
-#endif // _SLANG_DIAGNOSTIC_BUFFER_HPP
+#endif // _SLANG_DIAGNOSTIC_BUFFER_H
diff --git a/slang_driver.cpp b/slang_driver.cpp
index aa46e15..f2ed42f 100644
--- a/slang_driver.cpp
+++ b/slang_driver.cpp
@@ -1,5 +1,5 @@
#include "libslang.h"
-#include "slang_rs_reflect_utils.hpp"
+#include "slang_rs_reflect_utils.h"
#include <assert.h>
#include <getopt.h>
diff --git a/slang_pragma_recorder.cpp b/slang_pragma_recorder.cpp
index 4dce7f2..7d007cc 100644
--- a/slang_pragma_recorder.cpp
+++ b/slang_pragma_recorder.cpp
@@ -1,10 +1,9 @@
-#include "slang_pragma_recorder.hpp"
-
-#include "clang/Lex/Token.h"
+#include "slang_pragma_recorder.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
using namespace slang;
@@ -23,16 +22,16 @@
bool PragmaRecorder::GetPragmaValueFromToken(const clang::Token &Token,
std::string &PragmaValue) {
// Same as the GetPragmaName()
- if(Token.is(clang::tok::r_paren))
+ if (Token.is(clang::tok::r_paren))
PragmaValue.clear();
else
return GetPragmaNameFromToken(Token, PragmaValue);
return true;
}
-PragmaRecorder::PragmaRecorder(PragmaList &Pragmas) :
- PragmaHandler(),
- mPragmas(Pragmas) {
+PragmaRecorder::PragmaRecorder(PragmaList &Pragmas)
+ : PragmaHandler(),
+ mPragmas(Pragmas) {
return;
}
@@ -66,10 +65,10 @@
}
// Until now, we ensure that we have a pragma name/value pair
- mPragmas.push_back( make_pair(PragmaName, PragmaValue) );
+ mPragmas.push_back(make_pair(PragmaName, PragmaValue));
}
-end_parsing_pragma_value:
+ end_parsing_pragma_value:
// Infor lex to eat the token
PP.LexUnexpandedToken(CurrentToken);
diff --git a/slang_pragma_recorder.hpp b/slang_pragma_recorder.h
similarity index 75%
rename from slang_pragma_recorder.hpp
rename to slang_pragma_recorder.h
index 7c0ad2f..26ac8cb 100644
--- a/slang_pragma_recorder.hpp
+++ b/slang_pragma_recorder.h
@@ -1,15 +1,14 @@
-#ifndef _SLANG_COMPILER_PRAGMA_HANDLER_HPP
-# define _SLANG_COMPILER_PRAGMA_HANDLER_HPP
-
-#include "clang/Lex/Pragma.h"
+#ifndef _SLANG_COMPILER_PRAGMA_HANDLER_H
+#define _SLANG_COMPILER_PRAGMA_HANDLER_H
#include <list>
#include <string>
+#include "clang/Lex/Pragma.h"
namespace clang {
-class Token;
-class Preprocessor;
+ class Token;
+ class Preprocessor;
}
namespace slang {
@@ -27,12 +26,11 @@
std::string &PragmaValue);
public:
- PragmaRecorder(PragmaList &Pragmas);
+ explicit PragmaRecorder(PragmaList &Pragmas);
virtual void HandlePragma(clang::Preprocessor &PP,
clang::Token &FirstToken);
};
-
}
-#endif // _SLANG_COMPILER_PRAGMA_HANDLER_HPP
+#endif // _SLANG_COMPILER_PRAGMA_HANDLER_H
diff --git a/slang_rs_backend.cpp b/slang_rs_backend.cpp
index 09bb6b8..ea138cc 100644
--- a/slang_rs_backend.cpp
+++ b/slang_rs_backend.cpp
@@ -1,25 +1,26 @@
-#include "slang_rs_backend.hpp"
-#include "slang_rs_context.hpp"
-#include "slang_rs_export_var.hpp"
-#include "slang_rs_export_func.hpp"
-#include "slang_rs_export_type.hpp"
+#include "slang_rs_backend.h"
+
+#include <vector>
+#include <string>
#include "llvm/Metadata.h"
-
-#include "llvm/ADT/Twine.h"
-#include "llvm/ADT/StringExtras.h"
-
-#include "llvm/Support/IRBuilder.h"
#include "llvm/Constant.h"
#include "llvm/Constants.h"
#include "llvm/Module.h"
#include "llvm/Function.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Support/IRBuilder.h"
+
+#include "llvm/ADT/Twine.h"
+#include "llvm/ADT/StringExtras.h"
+
#include "clang/AST/DeclGroup.h"
-#include <vector>
-#include <string>
+#include "slang_rs_context.h"
+#include "slang_rs_export_var.h"
+#include "slang_rs_export_func.h"
+#include "slang_rs_export_type.h"
using namespace slang;
@@ -31,19 +32,19 @@
llvm::raw_ostream *OS,
SlangCompilerOutputTy OutputType,
clang::SourceManager &SourceMgr,
- bool AllowRSPrefix) :
- Backend(Diags,
- CodeGenOpts,
- TargetOpts,
- Pragmas,
- OS,
- OutputType,
- SourceMgr,
- AllowRSPrefix),
- mContext(Context),
- mExportVarMetadata(NULL),
- mExportFuncMetadata(NULL),
- mExportTypeMetadata(NULL) {
+ bool AllowRSPrefix)
+ : Backend(Diags,
+ CodeGenOpts,
+ TargetOpts,
+ Pragmas,
+ OS,
+ OutputType,
+ SourceMgr,
+ AllowRSPrefix),
+ mContext(Context),
+ mExportVarMetadata(NULL),
+ mExportFuncMetadata(NULL),
+ mExportTypeMetadata(NULL) {
return;
}
@@ -64,12 +65,12 @@
llvm::SmallVector<llvm::Value*, 2> ExportVarInfo;
- for (RSContext::const_export_var_iterator I = mContext->export_vars_begin();
- I != mContext->export_vars_end();
- I++)
- {
- const RSExportVar* EV = *I;
- const RSExportType* ET = EV->getType();
+ for (RSContext::const_export_var_iterator I = mContext->export_vars_begin(),
+ E = mContext->export_vars_end();
+ I != E;
+ I++) {
+ const RSExportVar *EV = *I;
+ const RSExportType *ET = EV->getType();
// Variable name
ExportVarInfo.push_back(
@@ -80,15 +81,12 @@
ExportVarInfo.push_back(
llvm::MDString::get(
mLLVMContext, llvm::utostr_32(
- static_cast<const RSExportPrimitiveType*>(ET)->getType()
- )));
+ static_cast<const RSExportPrimitiveType*>(ET)->getType())));
else if (ET->getClass() == RSExportType::ExportClassPointer)
ExportVarInfo.push_back(
llvm::MDString::get(
mLLVMContext, ("*" + static_cast<const RSExportPointerType*>(ET)
- ->getPointeeType()->getName()
- ).c_str()
- ));
+ ->getPointeeType()->getName()).c_str()));
else
ExportVarInfo.push_back(
llvm::MDString::get(mLLVMContext,
@@ -111,17 +109,18 @@
llvm::SmallVector<llvm::Value*, 1> ExportFuncInfo;
- for (RSContext::const_export_func_iterator I=mContext->export_funcs_begin(),
- E = mContext->export_funcs_end();
+ for (RSContext::const_export_func_iterator
+ I = mContext->export_funcs_begin(),
+ E = mContext->export_funcs_end();
I != E;
I++) {
- const RSExportFunc* EF = *I;
+ const RSExportFunc *EF = *I;
// Function name
- if (!EF->hasParam())
- ExportFuncInfo.push_back( llvm::MDString::get(mLLVMContext,
- EF->getName().c_str()));
- else {
+ if (!EF->hasParam()) {
+ ExportFuncInfo.push_back(llvm::MDString::get(mLLVMContext,
+ EF->getName().c_str()));
+ } else {
llvm::Function *F = mpModule->getFunction(EF->getName());
llvm::Function *HelperFunction;
const std::string HelperFunctionName(".helper_" + EF->getName());
@@ -212,8 +211,9 @@
if (mContext->hasExportType()) {
llvm::SmallVector<llvm::Value*, 1> ExportTypeInfo;
- for (RSContext::const_export_type_iterator I=mContext->export_types_begin(),
- E = mContext->export_types_end();
+ for (RSContext::const_export_type_iterator
+ I = mContext->export_types_begin(),
+ E = mContext->export_types_end();
I != E;
I++) {
// First, dump type name list to export
@@ -246,8 +246,9 @@
assert(StructInfoMetadata->getNumOperands() == 0 &&
"Metadata with same name was created before");
- for (RSExportRecordType::const_field_iterator FI = ERT->fields_begin();
- FI != ERT->fields_end();
+ for (RSExportRecordType::const_field_iterator FI = ERT->fields_begin(),
+ FE = ERT->fields_end();
+ FI != FE;
FI++) {
const RSExportRecordType::Field *F = *FI;
@@ -276,15 +277,14 @@
FieldInfo.push_back(
llvm::MDString::get(mLLVMContext,
llvm::itostr(
- RSExportPrimitiveType::DataKindUser
- )));
+ RSExportPrimitiveType::DataKindUser)));
break;
}
}
- StructInfoMetadata->addOperand( llvm::MDNode::get(mLLVMContext,
- FieldInfo.data(),
- FieldInfo.size()));
+ StructInfoMetadata->addOperand(llvm::MDNode::get(mLLVMContext,
+ FieldInfo.data(),
+ FieldInfo.size()));
FieldInfo.clear();
}
diff --git a/slang_rs_backend.hpp b/slang_rs_backend.h
similarity index 71%
rename from slang_rs_backend.hpp
rename to slang_rs_backend.h
index e4e33b3..d4e6e15 100644
--- a/slang_rs_backend.hpp
+++ b/slang_rs_backend.h
@@ -1,22 +1,22 @@
-#ifndef _SLANG_COMPILER_RS_BACKEND_HPP
-# define _SLANG_COMPILER_RENDER_SCRIPT_BACKEND_HPP
+#ifndef _SLANG_COMPILER_RS_BACKEND_H
+#define _SLANG_COMPILER_RENDER_SCRIPT_BACKEND_H
#include "libslang.h"
-#include "slang_backend.hpp"
-#include "slang_pragma_recorder.hpp"
+#include "slang_backend.h"
+#include "slang_pragma_recorder.h"
namespace llvm {
-class NamedMDNode;
+ class NamedMDNode;
}
namespace clang {
-class ASTConsumer;
-class Diagnostic;
-class TargetOptions;
-class PragmaList;
-class CodeGenerator;
-class ASTContext;
-class DeclGroupRef;
+ class ASTConsumer;
+ class Diagnostic;
+ class TargetOptions;
+ class PragmaList;
+ class CodeGenerator;
+ class ASTContext;
+ class DeclGroupRef;
}
namespace slang {
@@ -49,7 +49,6 @@
virtual ~RSBackend();
};
-
}
-#endif // _SLANG_COMPILER_BACKEND_HPP
+#endif // _SLANG_COMPILER_BACKEND_H
diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp
index 4ec56a5..66208f9 100644
--- a/slang_rs_context.cpp
+++ b/slang_rs_context.cpp
@@ -1,10 +1,7 @@
-#include "slang.hpp"
-#include "slang_rs_context.hpp"
-#include "slang_rs_reflection.hpp"
-#include "slang_rs_export_var.hpp"
-#include "slang_rs_export_func.hpp"
-#include "slang_rs_export_type.hpp"
-#include "slang_rs_pragma_handler.hpp"
+#include "slang_rs_context.h"
+
+#include "llvm/LLVMContext.h"
+#include "llvm/Target/TargetData.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Linkage.h"
@@ -14,22 +11,26 @@
#include "clang/AST/ASTContext.h"
#include "clang/Index/ASTLocation.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Target/TargetData.h"
+#include "slang.h"
+#include "slang_rs_reflection.h"
+#include "slang_rs_export_var.h"
+#include "slang_rs_export_func.h"
+#include "slang_rs_export_type.h"
+#include "slang_rs_pragma_handler.h"
using namespace slang;
RSContext::RSContext(clang::Preprocessor *PP,
clang::ASTContext *Ctx,
- const clang::TargetInfo *Target) :
- mPP(PP),
- mCtx(Ctx),
- mTarget(Target),
- mTargetData(NULL),
- mLLVMContext(llvm::getGlobalContext()),
- mExportAllNonStaticVars(false),
- mExportAllNonStaticFuncs(false),
- mLicenseNote(NULL) {
+ const clang::TargetInfo *Target)
+ : mPP(PP),
+ mCtx(Ctx),
+ mTarget(Target),
+ mTargetData(NULL),
+ mLLVMContext(llvm::getGlobalContext()),
+ mExportAllNonStaticVars(false),
+ mExportAllNonStaticFuncs(false),
+ mLicenseNote(NULL) {
// For #pragma rs export_var
PP->AddPragmaHandler(
"rs", RSPragmaHandler::CreatePragmaExportVarHandler(this));
@@ -67,7 +68,7 @@
bool RSContext::processExportVar(const clang::VarDecl *VD) {
assert(!VD->getName().empty() && "Variable name should not be empty");
- // TODO: some check on variable
+ // TODO(zonr): some check on variable
RSExportType *ET = RSExportType::CreateFromDecl(this, VD);
if (!ET)
@@ -82,7 +83,7 @@
return true;
}
-bool RSContext::processExportFunc(const clang::FunctionDecl* FD) {
+bool RSContext::processExportFunc(const clang::FunctionDecl *FD) {
assert(!FD->getName().empty() && "Function name should not be empty");
if (!FD->isThisDeclarationADefinition())
@@ -112,7 +113,8 @@
const clang::IdentifierInfo *II = mPP->getIdentifierInfo(Name);
if (II == NULL)
- // TODO: error: identifier @Name mark as an exportable type cannot be found
+ // TODO(zonr): alert identifier @Name mark as an exportable type cannot be
+ // found
return false;
clang::DeclContext::lookup_const_result R = TUDecl->lookup(II);
@@ -132,12 +134,10 @@
ND)->getCanonicalDecl()->getUnderlyingType().getTypePtr();
break;
}
-
case clang::Decl::Record: {
T = static_cast<const clang::RecordDecl*>(ND)->getTypeForDecl();
break;
}
-
default: {
// unsupported, skip
break;
@@ -159,10 +159,8 @@
!mExportAllNonStaticVars && !mExportAllNonStaticFuncs) {
fprintf(stderr, "note: No reflection because there are no #pragma "
"rs export_var(...), #pragma rs export_func(...), "
- "#pragma rs export_var_all, or #pragma rs export_func_all\n"
- );
- //mExportAllNonStaticVars = true;
- //mExportAllNonStaticFuncs = true;
+ "#pragma rs export_var_all, or #pragma rs "
+ "export_func_all\n");
}
// Export variable
@@ -257,7 +255,7 @@
RSReflection *R = new RSReflection(this);
bool ret = R->reflect(OutputPackageName, InputFileName, OutputBCFileName);
- if(!ret)
+ if (!ret)
fprintf(stderr, "RSContext::reflectToJava : failed to do reflection "
"(%s)\n", R->getLastError());
delete R;
@@ -274,12 +272,6 @@
}
RSContext::~RSContext() {
- /* delete mRSExportVarPragma; // These are deleted by mPP.reset() that was invoked at the end of Slang::compile(). Doing it again in ~RSContext here will cause seg-faults
- delete mRSExportFuncPragma;
- delete mRSExportTypePragma;
- delete mRSJavaPackageNamePragma;
- delete mRSReflectLicensePragma;
- */
delete mLicenseNote;
delete mTargetData;
}
diff --git a/slang_rs_context.hpp b/slang_rs_context.h
similarity index 94%
rename from slang_rs_context.hpp
rename to slang_rs_context.h
index 16a9270..e960099 100644
--- a/slang_rs_context.hpp
+++ b/slang_rs_context.h
@@ -1,7 +1,5 @@
-#ifndef _SLANG_COMPILER_RS_CONTEXT_HPP
-# define _SLANG_COMPILER_RS_CONTEXT_HPP
-
-#include "slang_rs_export_element.hpp"
+#ifndef _SLANG_COMPILER_RS_CONTEXT_H
+#define _SLANG_COMPILER_RS_CONTEXT_H
#include <map>
#include <list>
@@ -13,17 +11,19 @@
#include "clang/Lex/Preprocessor.h"
+#include "slang_rs_export_element.h"
+
namespace llvm {
-class LLVMContext;
-class TargetData;
+ class LLVMContext;
+ class TargetData;
} // namespace llvm
namespace clang {
-class VarDecl;
-class ASTContext;
-class TargetInfo;
-class FunctionDecl;
-class SourceManager;
+ class VarDecl;
+ class ASTContext;
+ class TargetInfo;
+ class FunctionDecl;
+ class SourceManager;
} // namespace clang
namespace slang {
@@ -177,4 +177,4 @@
} // namespace slang
-#endif // _SLANG_COMPILER_RS_CONTEXT_HPP
+#endif // _SLANG_COMPILER_RS_CONTEXT_H
diff --git a/slang_rs_export_element.cpp b/slang_rs_export_element.cpp
index a5375f8..1ecacce 100644
--- a/slang_rs_export_element.cpp
+++ b/slang_rs_export_element.cpp
@@ -1,6 +1,4 @@
-#include "slang_rs_context.hpp"
-#include "slang_rs_export_type.hpp"
-#include "slang_rs_export_element.hpp"
+#include "slang_rs_export_element.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/IdentifierTable.h"
@@ -8,6 +6,9 @@
#include "clang/AST/Decl.h"
#include "clang/AST/Type.h"
+#include "slang_rs_context.h"
+#include "slang_rs_export_type.h"
+
using namespace slang;
bool RSExportElement::Initialized = false;
@@ -32,8 +33,7 @@
Name.begin(), \
Name.end(), \
ElementInfoMap.getAllocator(), \
- EI \
- )); \
+ EI)); \
}
#include "slang_rs_export_element_support.inc"
@@ -58,7 +58,7 @@
if (!RSExportType::NormalizeType(T, TypeName))
return NULL;
- switch(T->getTypeClass()) {
+ switch (T->getTypeClass()) {
case clang::Type::Builtin:
case clang::Type::Pointer: {
assert(EI->vsize == 1 && "Element not a primitive class (please check "
@@ -74,12 +74,10 @@
ET = EPT;
break;
}
-
case clang::Type::ConstantArray: {
- //XXX
+ // XXX
break;
}
-
case clang::Type::ExtVector: {
assert(EI->vsize > 1 && "Element not a vector class (please check your "
"macro)");
@@ -98,14 +96,12 @@
ET = EVT;
break;
}
-
case clang::Type::Record: {
// Must be RS object type
- if ( TypeName.equals(llvm::StringRef("rs_matrix2x2")) ||
- TypeName.equals(llvm::StringRef("rs_matrix3x3")) ||
- TypeName.equals(llvm::StringRef("rs_matrix4x4")) ) {
-
+ if (TypeName.equals(llvm::StringRef("rs_matrix2x2")) ||
+ TypeName.equals(llvm::StringRef("rs_matrix3x3")) ||
+ TypeName.equals(llvm::StringRef("rs_matrix4x4"))) {
const clang::RecordType *RT = static_cast<const clang::RecordType*> (T);
const clang::RecordDecl *RD = RT->getDecl();
RD = RD->getDefinition();
@@ -116,8 +112,7 @@
RSExportConstantArrayType::Create(
Context,
static_cast<const clang::ConstantArrayType*> (FT),
- TypeName
- );
+ TypeName);
ET = ECT;
} else {
RSExportPrimitiveType* EPT =
@@ -132,9 +127,8 @@
}
break;
}
-
default: {
- // TODO: warning: type is not exportable
+ // TODO(zonr): warn that type is not exportable
fprintf(stderr, "RSExportElement::Create : type '%s' is not exportable\n",
T->getTypeClassName());
break;
@@ -182,7 +176,7 @@
}
const RSExportElement::ElementInfo *
-RSExportElement::GetElementInfo(const llvm::StringRef& Name) {
+RSExportElement::GetElementInfo(const llvm::StringRef &Name) {
if (!Initialized)
Init();
diff --git a/slang_rs_export_element.h b/slang_rs_export_element.h
new file mode 100644
index 0000000..e4136df
--- /dev/null
+++ b/slang_rs_export_element.h
@@ -0,0 +1,56 @@
+#ifndef _SLANG_COMPILER_RS_EXPORT_ELEMENT_H
+#define _SLANG_COMPILER_RS_EXPORT_ELEMENT_H
+
+#include <string>
+
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+
+#include "clang/Lex/Token.h"
+
+#include "slang_rs_export_type.h"
+
+namespace clang {
+ class Type;
+ class DeclaratorDecl;
+} // namespace clang
+
+namespace slang {
+
+ class RSContext;
+ class RSExportType;
+
+class RSExportElement {
+ // This is a utility class for handling the RS_ELEMENT_ADD* marker
+ RSExportElement() { return; }
+
+ typedef struct {
+ RSExportPrimitiveType::DataKind kind;
+ RSExportPrimitiveType::DataType type;
+ bool normalized;
+ int vsize;
+ } ElementInfo;
+
+ typedef llvm::StringMap<const ElementInfo*> ElementInfoMapTy;
+
+ private:
+ // Macro name <-> ElementInfo
+ static ElementInfoMapTy ElementInfoMap;
+
+ static bool Initialized;
+
+ static RSExportType *Create(RSContext *Context,
+ const clang::Type *T,
+ const ElementInfo *EI);
+
+ static const ElementInfo *GetElementInfo(const llvm::StringRef &Name);
+ public:
+ static void Init();
+
+ static RSExportType *CreateFromDecl(RSContext *Context,
+ const clang::DeclaratorDecl *DD);
+};
+
+} // namespace slang
+
+#endif // _SLANG_COMPILER_RS_EXPORT_ELEMENT_H
diff --git a/slang_rs_export_element.hpp b/slang_rs_export_element.hpp
deleted file mode 100644
index 3cbc020..0000000
--- a/slang_rs_export_element.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef _SLANG_COMPILER_RS_EXPORT_ELEMENT_HPP
-# define _SLANG_COMPILER_RS_EXPORT_ELEMENT_HPP
-
-#include "slang_rs_export_type.hpp"
-
-#include "llvm/ADT/StringMap.h" /* for class llvm::StringMap */
-#include "llvm/ADT/StringRef.h" /* for class llvm::StringRef */
-
-#include "clang/Lex/Token.h" /* for class clang::Token */
-
-#include <string>
-
-namespace clang {
-class Type;
-class DeclaratorDecl;
-} // namespace clang
-
-namespace slang {
-
-class RSContext;
-class RSExportType;
-
-class RSExportElement {
- // This is a utility class for handling the RS_ELEMENT_ADD* marker
- RSExportElement() { return; }
-
- typedef struct {
- RSExportPrimitiveType::DataKind kind;
- RSExportPrimitiveType::DataType type;
- bool normalized;
- int vsize;
- } ElementInfo;
-
- typedef llvm::StringMap<const ElementInfo*> ElementInfoMapTy;
-
- private:
- // Macro name <-> ElementInfo
- static ElementInfoMapTy ElementInfoMap;
-
- static bool Initialized;
-
- static RSExportType *Create(RSContext *Context,
- const clang::Type* T,
- const ElementInfo *EI);
-
- static const ElementInfo *GetElementInfo(const llvm::StringRef &Name);
- public:
- static void Init();
-
- static RSExportType *CreateFromDecl(RSContext* Context,
- const clang::DeclaratorDecl* DD);
-};
-
-} // namespace slang
-
-#endif // _SLANG_COMPILER_RS_EXPORT_ELEMENT_HPP
diff --git a/slang_rs_export_func.cpp b/slang_rs_export_func.cpp
index a36b915..19d6cee 100644
--- a/slang_rs_export_func.cpp
+++ b/slang_rs_export_func.cpp
@@ -1,11 +1,12 @@
-#include "slang_rs_context.hpp"
-#include "slang_rs_export_func.hpp"
-#include "slang_rs_export_type.hpp"
+#include "slang_rs_export_func.h"
#include "llvm/Target/TargetData.h"
#include "clang/AST/Decl.h"
+#include "slang_rs_context.h"
+#include "slang_rs_export_type.h"
+
using namespace slang;
RSExportFunc *RSExportFunc::Create(RSContext *Context,
@@ -18,7 +19,7 @@
F = new RSExportFunc(Context, Name);
// Check whether the parameters passed to the function is exportable
- for(unsigned i = 0;i < FD->getNumParams(); i++) {
+ for (unsigned i = 0, e = FD->getNumParams(); i != e; i++) {
const clang::ParmVarDecl *PVD = FD->getParamDecl(i);
const llvm::StringRef ParamName = PVD->getName();
@@ -60,15 +61,15 @@
PE = params_end();
PI != PE;
PI++, Index++) {
- //For-Loop's body should be:
- const RSExportFunc::Parameter* P = *PI;
+ // For-Loop's body should be:
+ const RSExportFunc::Parameter *P = *PI;
std::string nam = P->getName();
- const RSExportType* typ = P->getType();
+ const RSExportType *typ = P->getType();
std::string typNam = typ->getName();
// If (type conversion is needed)
if (typNam.find("rs_") == 0) {
// P's type set to [1 x i32];
- RSExportConstantArrayType* ECT = new RSExportConstantArrayType
+ RSExportConstantArrayType *ECT = new RSExportConstantArrayType
(mContext, "addObj",
RSExportPrimitiveType::DataTypeSigned32,
RSExportPrimitiveType::DataKindUser,
@@ -86,21 +87,13 @@
ParamPacketType,
Index) );
}
-
- // ParamPacketType->mFields.push_back(
- // new RSExportRecordType::Field((*PI)->getType(),
- // (*PI)->getName(),
- // ParamPacketType,
- // Index
- // ));
}
ParamPacketType->AllocSize =
mContext->getTargetData()->getTypeAllocSize(
- ParamPacketType->getLLVMType()
- );
+ ParamPacketType->getLLVMType());
mParamPacketType = ParamPacketType;
}
@@ -115,7 +108,7 @@
PI++)
delete *PI;
- if(mParamPacketType != NULL)
+ if (mParamPacketType != NULL)
delete mParamPacketType;
return;
diff --git a/slang_rs_export_func.hpp b/slang_rs_export_func.h
similarity index 72%
rename from slang_rs_export_func.hpp
rename to slang_rs_export_func.h
index 3027237..cbc7aa3 100644
--- a/slang_rs_export_func.hpp
+++ b/slang_rs_export_func.h
@@ -1,20 +1,20 @@
-#ifndef _SLANG_COMPILER_RS_EXPORT_FUNC_HPP
-# define _SLANG_COMPILER_RS_EXPORT_FUNC_HPP
-
-#include "llvm/ADT/StringRef.h"
+#ifndef _SLANG_COMPILER_RS_EXPORT_FUNC_H
+#define _SLANG_COMPILER_RS_EXPORT_FUNC_H
#include <list>
#include <string>
+#include "llvm/ADT/StringRef.h"
+
namespace clang {
-class FunctionDecl;
+ class FunctionDecl;
} // namespace clang
namespace slang {
-class RSContext;
-class RSExportType;
-class RSExportRecordType;
+ class RSContext;
+ class RSExportType;
+ class RSExportRecordType;
class RSExportFunc {
friend class RSContext;
@@ -25,10 +25,9 @@
std::string mName;
public:
- Parameter(RSExportType *T, const llvm::StringRef &Name) :
- mType(T),
- mName(Name.data(), Name.size())
- {
+ Parameter(RSExportType *T, const llvm::StringRef &Name)
+ : mType(T),
+ mName(Name.data(), Name.size()) {
return;
}
@@ -42,11 +41,10 @@
std::list<const Parameter*> mParams;
mutable RSExportRecordType *mParamPacketType;
- RSExportFunc(RSContext *Context, const llvm::StringRef &Name) :
- mContext(Context),
- mName(Name.data(), Name.size()),
- mParamPacketType(NULL)
- {
+ RSExportFunc(RSContext *Context, const llvm::StringRef &Name)
+ : mContext(Context),
+ mName(Name.data(), Name.size()),
+ mParamPacketType(NULL) {
return;
}
@@ -80,10 +78,8 @@
const RSExportRecordType *getParamPacketType() const;
~RSExportFunc();
-
}; // RSExportFunc
-
} // namespace slang
-#endif // _SLANG_COMPILER_RS_EXPORT_FUNC_HPP
+#endif // _SLANG_COMPILER_RS_EXPORT_FUNC_H
diff --git a/slang_rs_export_type.cpp b/slang_rs_export_type.cpp
index 99aaca6..6fa035c 100644
--- a/slang_rs_export_type.cpp
+++ b/slang_rs_export_type.cpp
@@ -1,6 +1,6 @@
-#include "slang_rs_context.hpp"
-#include "slang_rs_export_type.hpp"
-#include "slang_rs_export_element.hpp"
+#include "slang_rs_export_type.h"
+
+#include <vector>
#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
@@ -10,7 +10,8 @@
#include "clang/AST/RecordLayout.h"
-#include <vector>
+#include "slang_rs_context.h"
+#include "slang_rs_export_element.h"
using namespace slang;
@@ -21,13 +22,13 @@
llvm::SmallPtrSet<const clang::Type*, 8>();
if ((T = RSExportType::TypeExportable(T, SPS)) == NULL)
- // TODO: warning the user: type not exportable
+ // TODO(zonr): warn that type not exportable.
return false;
// Get type name
TypeName = RSExportType::GetTypeName(T);
if (TypeName.empty())
- // TODO: warning the user: the type is unnamed
+ // TODO(zonr): warning that the type is unnamed.
return false;
return true;
@@ -75,7 +76,7 @@
return "short"; \
else if (type == RSExportPrimitiveType::DataTypeSigned32) \
return "int"; \
- else if(type == RSExportPrimitiveType::DataTypeSigned64) \
+ else if (type == RSExportPrimitiveType::DataTypeSigned64) \
return "long"; \
else if (type == RSExportPrimitiveType::DataTypeBoolean) \
return "bool"; \
@@ -92,7 +93,6 @@
}
break;
}
-
case clang::Type::Record: {
const clang::RecordDecl *RD = T->getAsStructureType()->getDecl();
llvm::StringRef Name = RD->getName();
@@ -100,7 +100,7 @@
if (RD->getTypedefForAnonDecl() != NULL)
Name = RD->getTypedefForAnonDecl()->getName();
- if(Name.empty())
+ if (Name.empty())
// Try to find a name from redeclaration (i.e. typedef)
for (clang::TagDecl::redecl_iterator RI = RD->redecls_begin(),
RE = RD->redecls_end();
@@ -115,10 +115,9 @@
}
return Name;
}
-
case clang::Type::Pointer: {
// "*" plus pointee name
- const clang::Type* PT = GET_POINTEE_TYPE(T);
+ const clang::Type *PT = GET_POINTEE_TYPE(T);
llvm::StringRef PointeeName;
if (NormalizeType(PT, PointeeName)) {
char *Name = new char[ 1 /* * */ + PointeeName.size() + 1 ];
@@ -129,21 +128,18 @@
}
break;
}
-
case clang::Type::ConstantArray: {
const clang::ConstantArrayType *ECT =
UNSAFE_CAST_TYPE(clang::ConstantArrayType, T);
return RSExportConstantArrayType::GetTypeName(ECT);
break;
}
-
case clang::Type::ExtVector: {
const clang::ExtVectorType *EVT =
UNSAFE_CAST_TYPE(clang::ExtVectorType, T);
return RSExportVectorType::GetTypeName(EVT);
break;
}
-
default: {
break;
}
@@ -173,19 +169,16 @@
{
return T;
}
-
default: {
return NULL;
}
}
// Never be here
}
-
-
case clang::Type::Record: {
if (RSExportPrimitiveType::GetRSObjectType(T) !=
RSExportPrimitiveType::DataTypeUnknown)
- return T; // RS object type, no further checks are needed
+ return T; // RS object type, no further checks are needed
// Check internal struct
const clang::RecordDecl *RD = T->getAsStructureType()->getDecl();
@@ -204,17 +197,16 @@
FE = RD->field_end();
FI != FE;
FI++) {
- const clang::Type* FT = GetTypeOfDecl(*FI);
+ const clang::Type *FT = GetTypeOfDecl(*FI);
FT = GET_CANONICAL_TYPE(FT);
if (!TypeExportable(FT, SPS))
- // TODO: warning: unsupported field type
+ // TODO(zonr): warn that is's an unsupported field type
return NULL;
}
return T;
}
-
case clang::Type::Pointer: {
const clang::PointerType *PT = UNSAFE_CAST_TYPE(clang::PointerType, T);
const clang::Type *PointeeType = GET_POINTEE_TYPE(PT);
@@ -244,7 +236,6 @@
else
return T;
}
-
case clang::Type::ExtVector: {
const clang::ExtVectorType *EVT =
UNSAFE_CAST_TYPE(clang::ExtVectorType, T);
@@ -261,7 +252,6 @@
else
return T;
}
-
default: {
return NULL;
}
@@ -340,7 +330,7 @@
break;
}
default: {
- // TODO: warning: type is not exportable
+ // TODO(zonr): warn that type is not exportable.
fprintf(stderr,
"RSExportType::Create : type '%s' is not exportable\n",
T->getTypeClassName());
@@ -351,7 +341,7 @@
return ET;
}
-RSExportType* RSExportType::Create(RSContext *Context, const clang::Type *T) {
+RSExportType *RSExportType::Create(RSContext *Context, const clang::Type *T) {
llvm::StringRef TypeName;
if (NormalizeType(T, TypeName))
return Create(Context, T, TypeName);
@@ -366,8 +356,7 @@
size_t RSExportType::GetTypeStoreSize(const RSExportType *ET) {
return ET->getRSContext()->getTargetData()->getTypeStoreSize(
- ET->getLLVMType()
- );
+ ET->getLLVMType());
}
size_t RSExportType::GetTypeAllocSize(const RSExportType *ET) {
@@ -375,17 +364,16 @@
return static_cast<const RSExportRecordType*>(ET)->getAllocSize();
else
return ET->getRSContext()->getTargetData()->getTypeAllocSize(
- ET->getLLVMType()
- );
+ ET->getLLVMType());
}
-RSExportType::RSExportType(RSContext *Context, const llvm::StringRef &Name) :
- mContext(Context),
- // Make a copy on Name since data of @Name which is stored in ASTContext
- // will be destroyed later
- mName(Name.data(), Name.size()),
- mLLVMType(NULL) {
- // TODO: need to check whether the insertion is successful or not
+RSExportType::RSExportType(RSContext *Context, const llvm::StringRef &Name)
+ : mContext(Context),
+ // Make a copy on Name since data of @Name which is stored in ASTContext
+ // will be destroyed later
+ mName(Name.data(), Name.size()),
+ mLLVMType(NULL) {
+ // TODO(zonr): Need to check whether the insertion is successful or not.
Context->insertExportType(Name, this);
return;
}
@@ -394,7 +382,7 @@
RSExportPrimitiveType::RSObjectTypeMapTy
*RSExportPrimitiveType::RSObjectTypeMap = NULL;
-llvm::Type* RSExportPrimitiveType::RSObjectLLVMType = NULL;
+llvm::Type *RSExportPrimitiveType::RSObjectLLVMType = NULL;
bool RSExportPrimitiveType::IsPrimitiveType(const clang::Type *T) {
if ((T != NULL) && (T->getTypeClass() == clang::Type::Builtin))
@@ -436,38 +424,38 @@
const size_t
RSExportPrimitiveType::SizeOfDataTypeInBits[
RSExportPrimitiveType::DataTypeMax + 1] = {
- 16, // DataTypeFloat16
- 32, // DataTypeFloat32
- 64, // DataTypeFloat64
- 8, // DataTypeSigned8
- 16, // DataTypeSigned16
- 32, // DataTypeSigned32
- 64, // DataTypeSigned64
- 8, // DataTypeUnsigned8
- 16, // DataTypeUnsigned16
- 32, // DataTypeUnsigned32
- 64, // DataTypeUnSigned64
- 1, // DataTypeBoolean
+ 16, // DataTypeFloat16
+ 32, // DataTypeFloat32
+ 64, // DataTypeFloat64
+ 8, // DataTypeSigned8
+ 16, // DataTypeSigned16
+ 32, // DataTypeSigned32
+ 64, // DataTypeSigned64
+ 8, // DataTypeUnsigned8
+ 16, // DataTypeUnsigned16
+ 32, // DataTypeUnsigned32
+ 64, // DataTypeUnSigned64
+ 1, // DataTypeBoolean
- 16, // DataTypeUnsigned565
- 16, // DataTypeUnsigned5551
- 16, // DataTypeUnsigned4444
+ 16, // DataTypeUnsigned565
+ 16, // DataTypeUnsigned5551
+ 16, // DataTypeUnsigned4444
- 128, // DataTypeRSMatrix2x2
- 288, // DataTypeRSMatrix3x3
- 512, // DataTypeRSMatrix4x4
+ 128, // DataTypeRSMatrix2x2
+ 288, // DataTypeRSMatrix3x3
+ 512, // DataTypeRSMatrix4x4
- 32, // DataTypeRSElement
- 32, // DataTypeRSType
- 32, // DataTypeRSAllocation
- 32, // DataTypeRSSampler
- 32, // DataTypeRSScript
- 32, // DataTypeRSMesh
- 32, // DataTypeRSProgramFragment
- 32, // DataTypeRSProgramVertex
- 32, // DataTypeRSProgramRaster
- 32, // DataTypeRSProgramStore
- 32, // DataTypeRSFont
+ 32, // DataTypeRSElement
+ 32, // DataTypeRSType
+ 32, // DataTypeRSAllocation
+ 32, // DataTypeRSSampler
+ 32, // DataTypeRSScript
+ 32, // DataTypeRSMesh
+ 32, // DataTypeRSProgramFragment
+ 32, // DataTypeRSProgramVertex
+ 32, // DataTypeRSProgramRaster
+ 32, // DataTypeRSProgramStore
+ 32, // DataTypeRSFont
0
};
@@ -479,7 +467,7 @@
}
RSExportPrimitiveType::DataType
-RSExportPrimitiveType::GetDataType(const clang::Type* T) {
+RSExportPrimitiveType::GetDataType(const clang::Type *T) {
if (T == NULL)
return DataTypeUnknown;
@@ -499,7 +487,7 @@
// int64_t, double, etc.): no support
default: {
- // TODO: warning the user: unsupported type
+ // TODO(zonr): warn that the type is unsupported
fprintf(stderr, "RSExportPrimitiveType::GetDataType : built-in type "
"has no corresponding data type for built-in type");
break;
@@ -566,7 +554,7 @@
//
if (RSObjectLLVMType == NULL) {
std::vector<const llvm::Type *> Elements;
- Elements.push_back( llvm::ArrayType::get(llvm::Type::getInt32Ty(C), 1) );
+ Elements.push_back(llvm::ArrayType::get(llvm::Type::getInt32Ty(C), 1));
RSObjectLLVMType = llvm::StructType::get(C, Elements, true);
}
return RSObjectLLVMType;
@@ -750,7 +738,7 @@
return llvm::ArrayType::get(typ, mNumElement);
}
-/****************************** RSExportVectorType ******************************/
+/***************************** RSExportVectorType *****************************/
const char* RSExportVectorType::VectorTypeNameStore[][3] = {
/* 0 */ { "char2", "char3", "char4" },
/* 1 */ { "uchar2", "uchar3", "uchar4" },
@@ -763,7 +751,8 @@
/* 8 */ { "long2", "long3", "long4" },
};
-llvm::StringRef RSExportVectorType::GetTypeName(const clang::ExtVectorType *EVT) {
+llvm::StringRef
+RSExportVectorType::GetTypeName(const clang::ExtVectorType *EVT) {
const clang::Type *ElementType = GET_EXT_VECTOR_ELEMENT_TYPE(EVT);
if ((ElementType->getTypeClass() != clang::Type::Builtin))
@@ -842,8 +831,8 @@
return RSExportType::ExportClassVector;
}
-const llvm::Type* RSExportVectorType::convertToLLVMType() const {
- const llvm::Type* ElementType = RSExportPrimitiveType::convertToLLVMType();
+const llvm::Type *RSExportVectorType::convertToLLVMType() const {
+ const llvm::Type *ElementType = RSExportPrimitiveType::convertToLLVMType();
return llvm::VectorType::get(ElementType, getNumElement());
}
@@ -859,7 +848,8 @@
RD = RD->getDefinition();
if (RD == NULL) {
- // TODO: warning: actual struct definition isn't declared in this moudle
+ // TODO(zonr): warn that actual struct definition isn't declared in this
+ // moudle.
fprintf(stderr, "RSExportRecordType::Create : this struct is not defined "
"in this module.");
return NULL;
@@ -891,15 +881,15 @@
// We don't support bit field
//
- // TODO: allow bitfield with size 8, 16, 32
+ // TODO(zonr): allow bitfield with size 8, 16, 32
if (FD->isBitField())
FAILED_CREATE_FIELD("bit field is not supported");
// Type
- RSExportType* ET = RSExportElement::CreateFromDecl(Context, FD);
+ RSExportType *ET = RSExportElement::CreateFromDecl(Context, FD);
- if(ET != NULL)
- ERT->mFields.push_back( new Field(ET, FD->getName(), ERT, Index) );
+ if (ET != NULL)
+ ERT->mFields.push_back(new Field(ET, FD->getName(), ERT, Index));
else
FAILED_CREATE_FIELD(FD->getName().str().c_str());
#undef FAILED_CREATE_FIELD
@@ -919,7 +909,7 @@
return RSExportType::ExportClassRecord;
}
-const llvm::Type* RSExportRecordType::convertToLLVMType() const {
+const llvm::Type *RSExportRecordType::convertToLLVMType() const {
std::vector<const llvm::Type*> FieldTypes;
for (const_field_iterator FI = fields_begin(),
@@ -942,7 +932,6 @@
// Struct layout obtains below will be cached by LLVM
const llvm::StructLayout *SL =
mParent->getRSContext()->getTargetData()->getStructLayout(
- static_cast<const llvm::StructType*>(mParent->getLLVMType())
- );
+ static_cast<const llvm::StructType*>(mParent->getLLVMType()));
return SL->getElementOffset(mIndex);
}
diff --git a/slang_rs_export_type.hpp b/slang_rs_export_type.h
similarity index 87%
rename from slang_rs_export_type.hpp
rename to slang_rs_export_type.h
index 68443fb..f9334b8 100644
--- a/slang_rs_export_type.hpp
+++ b/slang_rs_export_type.h
@@ -1,17 +1,17 @@
-#ifndef _SLANG_COMPILER_RS_EXPORT_TYPE_HPP
-# define _SLANG_COMPILER_RS_EXPORT_TYPE_HPP
-
-#include "llvm/ADT/StringRef.h" /* for class llvm::StringRef */
-#include "llvm/ADT/StringMap.h" /* for class llvm::StringMap */
-#include "llvm/ADT/SmallPtrSet.h" /* for class llvm::SmallPtrSet */
-
-#include "clang/AST/Type.h" /* for clang::Type and clang::QualType */
-#include "clang/AST/Decl.h" /* for clang::VarDecl and clang::DeclaratorDecl */
+#ifndef _SLANG_COMPILER_RS_EXPORT_TYPE_H
+#define _SLANG_COMPILER_RS_EXPORT_TYPE_H
#include <set>
#include <list>
#include <string>
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+#include "clang/AST/Type.h"
+#include "clang/AST/Decl.h"
+
#define GET_CANONICAL_TYPE(T) \
(((T) == NULL) ? NULL : (T)->getCanonicalTypeInternal().getTypePtr())
#define UNSAFE_CAST_TYPE(TT, T) \
@@ -27,17 +27,17 @@
GET_CANONICAL_TYPE((T)->getPointeeType().getTypePtr()))
namespace llvm {
-class Type;
+ class Type;
} // namespace llvm
namespace slang {
-class RSContext;
-class RSExportPrimitiveType;
-class RSExportConstantArrayType;
-class RSExportVectorType;
-class RSExportRecordType;
-class RSExportFunction;
+ class RSContext;
+ class RSExportPrimitiveType;
+ class RSExportConstantArrayType;
+ class RSExportVectorType;
+ class RSExportRecordType;
+ class RSExportFunction;
class RSExportType {
friend class RSExportElement;
@@ -64,17 +64,18 @@
// function.
//
// @T was normalized by calling RSExportType::TypeExportable().
- // @TypeName was retrieve from RSExportType::GetTypeName() before calling this.
+ // @TypeName was retrieve from RSExportType::GetTypeName() before calling
+ // this.
//
static RSExportType *Create(RSContext *Context,
const clang::Type *T,
- const llvm::StringRef& TypeName);
+ const llvm::StringRef &TypeName);
static llvm::StringRef GetTypeName(const clang::Type *T);
// Return the type that can be used to create RSExportType, will always return
// the canonical type
static const clang::Type
- *TypeExportable(const clang::Type* T,
+ *TypeExportable(const clang::Type *T,
// Contain the checked type for recursion
llvm::SmallPtrSet<const clang::Type*, 8> &SPS);
@@ -88,6 +89,7 @@
// by ourselves.
virtual const llvm::Type *convertToLLVMType() const = 0;
+ virtual ~RSExportType() {}
public:
static bool NormalizeType(const clang::Type *&T, llvm::StringRef &TypeName);
// @T may not be normalized
@@ -204,11 +206,11 @@
const llvm::StringRef &Name,
DataType DT,
DataKind DK,
- bool Normalized) :
- RSExportType(Context, Name),
- mType(DT),
- mKind(DK),
- mNormalized(Normalized) {
+ bool Normalized)
+ : RSExportType(Context, Name),
+ mType(DT),
+ mKind(DK),
+ mNormalized(Normalized) {
return;
}
@@ -244,9 +246,9 @@
RSExportPointerType(RSContext *Context,
const llvm::StringRef &Name,
- const RSExportType *PointeeType) :
- RSExportType(Context, Name),
- mPointeeType(PointeeType) {
+ const RSExportType *PointeeType)
+ : RSExportType(Context, Name),
+ mPointeeType(PointeeType) {
return;
}
@@ -279,10 +281,9 @@
DataType DT,
DataKind DK,
bool Normalized,
- int NumElement) :
- RSExportPrimitiveType(Context, Name, DT, DK, Normalized),
- mNumElement(NumElement)
- {
+ int NumElement)
+ : RSExportPrimitiveType(Context, Name, DT, DK, Normalized),
+ mNumElement(NumElement) {
return;
}
@@ -313,9 +314,9 @@
DataType DT,
DataKind DK,
bool Normalized,
- int NumElement) :
- RSExportPrimitiveType(Context, Name, DT, DK, Normalized),
- mNumElement(NumElement) {
+ int NumElement)
+ : RSExportPrimitiveType(Context, Name, DT, DK, Normalized),
+ mNumElement(NumElement) {
return;
}
@@ -357,11 +358,11 @@
Field(const RSExportType *T,
const llvm::StringRef &Name,
const RSExportRecordType *Parent,
- unsigned int Index) :
- mType(T),
- mName(Name.data(), Name.size()),
- mParent(Parent),
- mIndex(Index) {
+ unsigned int Index)
+ : mType(T),
+ mName(Name.data(), Name.size()),
+ mParent(Parent),
+ mIndex(Index) {
return;
}
@@ -392,10 +393,10 @@
RSExportRecordType(RSContext *Context,
const llvm::StringRef &Name,
bool IsPacked,
- bool IsArtificial = false) :
- RSExportType(Context, Name),
- mIsPacked(IsPacked),
- mIsArtificial(IsArtificial) {
+ bool IsArtificial = false)
+ : RSExportType(Context, Name),
+ mIsPacked(IsPacked),
+ mIsArtificial(IsArtificial) {
return;
}
@@ -429,4 +430,4 @@
} // namespace slang
-#endif // _SLANG_COMPILER_RS_EXPORT_TYPE_HPP
+#endif // _SLANG_COMPILER_RS_EXPORT_TYPE_H
diff --git a/slang_rs_export_var.cpp b/slang_rs_export_var.cpp
index 659e784..e3b60d2 100644
--- a/slang_rs_export_var.cpp
+++ b/slang_rs_export_var.cpp
@@ -1,20 +1,21 @@
-#include "slang_rs_context.hpp"
-#include "slang_rs_export_var.hpp"
-#include "slang_rs_export_type.hpp"
+#include "slang_rs_export_var.h"
#include "llvm/ADT/APSInt.h"
#include "clang/AST/Type.h"
+#include "slang_rs_context.h"
+#include "slang_rs_export_type.h"
+
using namespace slang;
RSExportVar::RSExportVar(RSContext *Context,
const clang::VarDecl *VD,
- const RSExportType *ET) :
- mContext(Context),
- mName(VD->getName().data(), VD->getName().size()),
- mET(ET),
- mIsConst(false) {
+ const RSExportType *ET)
+ : mContext(Context),
+ mName(VD->getName().data(), VD->getName().size()),
+ mET(ET),
+ mIsConst(false) {
// mInit - Evaluate initializer expression
const clang::Expr *Initializer = VD->getAnyInitializer();
if (Initializer != NULL) {
@@ -24,7 +25,6 @@
Initializer->Evaluate(mInit, *Context->getASTContext());
break;
}
-
case RSExportType::ExportClassPointer: {
if (Initializer->isNullPointerConstant
(*Context->getASTContext(),
@@ -35,7 +35,6 @@
Initializer->Evaluate(mInit, *Context->getASTContext());
break;
}
-
case RSExportType::ExportClassRecord: {
// No action
fprintf(stderr, "RSExportVar::RSExportVar : Reflection of initializer "
@@ -45,7 +44,6 @@
ET->getName().c_str());
break;
}
-
default: {
assert(false && "Unknown class of type");
}
diff --git a/slang_rs_export_var.hpp b/slang_rs_export_var.h
similarity index 80%
rename from slang_rs_export_var.hpp
rename to slang_rs_export_var.h
index e9b2290..543d53a 100644
--- a/slang_rs_export_var.hpp
+++ b/slang_rs_export_var.h
@@ -1,5 +1,5 @@
-#ifndef _SLANG_COMPILER_RS_EXPORT_VAR_HPP
-# define _SLANG_COMPILER_RS_EXPORT_VAR_HPP
+#ifndef _SLANG_COMPILER_RS_EXPORT_VAR_H
+#define _SLANG_COMPILER_RS_EXPORT_VAR_H
#include "llvm/ADT/StringRef.h"
@@ -9,13 +9,13 @@
#include <string>
namespace clang {
-class APValue;
+ class APValue;
}
namespace slang {
-class RSContext;
-class RSExportType;
+ class RSContext;
+ class RSExportType;
class RSExportVar {
friend class RSContext;
@@ -38,10 +38,8 @@
inline bool isConst() const { return mIsConst; }
inline const clang::APValue &getInit() const { return mInit.Val; }
-
}; // RSExportVar
-
} // namespace slang
-#endif // _SLANG_COMPILER_RS_EXPORT_VAR_HPP
+#endif // _SLANG_COMPILER_RS_EXPORT_VAR_H
diff --git a/slang_rs_pragma_handler.cpp b/slang_rs_pragma_handler.cpp
index 6d26883..8796ade 100644
--- a/slang_rs_pragma_handler.cpp
+++ b/slang_rs_pragma_handler.cpp
@@ -1,5 +1,4 @@
-#include "slang_rs_context.hpp"
-#include "slang_rs_pragma_handler.hpp"
+#include "slang_rs_pragma_handler.h"
#include "clang/Basic/TokenKinds.h"
@@ -7,6 +6,8 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/Token.h"
+#include "slang_rs_context.h"
+
using namespace slang;
namespace { // Anonymous namespace
@@ -18,8 +19,8 @@
}
public:
- RSExportVarPragmaHandler(llvm::StringRef Name, RSContext *Context) :
- RSPragmaHandler(Name, Context) {
+ RSExportVarPragmaHandler(llvm::StringRef Name, RSContext *Context)
+ : RSPragmaHandler(Name, Context) {
return;
}
@@ -30,8 +31,8 @@
class RSExportVarAllPragmaHandler : public RSPragmaHandler {
public:
- RSExportVarAllPragmaHandler(llvm::StringRef Name, RSContext *Context) :
- RSPragmaHandler(Name, Context) { return; }
+ RSExportVarAllPragmaHandler(llvm::StringRef Name, RSContext *Context)
+ : RSPragmaHandler(Name, Context) { return; }
void HandlePragma(clang::Preprocessor &PP, clang::Token &FirstToken) {
this->handleNonParamPragma(PP, FirstToken);
@@ -47,8 +48,8 @@
public:
RSExportFuncPragmaHandler(llvm::StringRef Name,
- RSContext *Context) :
- RSPragmaHandler(Name, Context) { return; }
+ RSContext *Context)
+ : RSPragmaHandler(Name, Context) { return; }
void HandlePragma(clang::Preprocessor &PP, clang::Token &FirstToken) {
this->handleItemListPragma(PP, FirstToken);
@@ -57,8 +58,8 @@
class RSExportFuncAllPragmaHandler : public RSPragmaHandler {
public:
- RSExportFuncAllPragmaHandler(llvm::StringRef Name, RSContext *Context) :
- RSPragmaHandler(Name, Context) { return; }
+ RSExportFuncAllPragmaHandler(llvm::StringRef Name, RSContext *Context)
+ : RSPragmaHandler(Name, Context) { return; }
void HandlePragma(clang::Preprocessor &PP, clang::Token &FirstToken) {
this->handleNonParamPragma(PP, FirstToken);
@@ -68,23 +69,23 @@
class RSExportTypePragmaHandler : public RSPragmaHandler {
private:
- void handleItem(const std::string& Item) {
+ void handleItem(const std::string &Item) {
mContext->addExportType(Item);
}
public:
- RSExportTypePragmaHandler(llvm::StringRef Name, RSContext* Context) :
- RSPragmaHandler(Name, Context) { return; }
+ RSExportTypePragmaHandler(llvm::StringRef Name, RSContext *Context)
+ : RSPragmaHandler(Name, Context) { return; }
- void HandlePragma(clang::Preprocessor& PP, clang::Token& FirstToken) {
+ void HandlePragma(clang::Preprocessor &PP, clang::Token &FirstToken) {
this->handleItemListPragma(PP, FirstToken);
}
};
class RSJavaPackageNamePragmaHandler : public RSPragmaHandler {
public:
- RSJavaPackageNamePragmaHandler(llvm::StringRef Name, RSContext *Context) :
- RSPragmaHandler(Name, Context) { return; }
+ RSJavaPackageNamePragmaHandler(llvm::StringRef Name, RSContext *Context)
+ : RSPragmaHandler(Name, Context) { return; }
void HandlePragma(clang::Preprocessor &PP, clang::Token &FirstToken) {
// FIXME: Need to validate the extracted package name from paragma.
@@ -129,9 +130,9 @@
PackageName.append(Spelling);
// Pre-mature end (syntax error will be triggered by preprocessor later)
- if (PragmaToken.is(clang::tok::eom) || PragmaToken.is(clang::tok::eof))
+ if (PragmaToken.is(clang::tok::eom) || PragmaToken.is(clang::tok::eof)) {
break;
- else {
+ } else {
// Next token is ')' (end of paragma)
const clang::Token &NextTok = PP.LookAhead(0);
if (NextTok.is(clang::tok::r_paren)) {
@@ -139,7 +140,7 @@
// Lex until meets clang::tok::eom
do {
PP.LexUnexpandedToken(PragmaToken);
- } while(PragmaToken.isNot(clang::tok::eom));
+ } while (PragmaToken.isNot(clang::tok::eom));
break;
}
}
@@ -215,7 +216,7 @@
// Lex variable name
PP.LexUnexpandedToken(PragmaToken);
if (PragmaToken.is(clang::tok::identifier))
- this->handleItem( PP.getSpelling(PragmaToken) );
+ this->handleItem(PP.getSpelling(PragmaToken));
else
break;
@@ -229,9 +230,9 @@
return;
}
-void RSPragmaHandler::handleNonParamPragma(clang::Preprocessor& PP,
- clang::Token& FirstToken) {
- clang::Token& PragmaToken = FirstToken;
+void RSPragmaHandler::handleNonParamPragma(clang::Preprocessor &PP,
+ clang::Token &FirstToken) {
+ clang::Token &PragmaToken = FirstToken;
// Skip first token, like "export_var_all"
PP.LexUnexpandedToken(PragmaToken);
@@ -263,7 +264,7 @@
fprintf(stderr, "RSPragmaHandler::handleOptionalStringLiateralParamPragma"
": illegal string literal\n");
else
- this->handleItem( std::string(StringLiteral.GetString()) );
+ this->handleItem(std::string(StringLiteral.GetString()));
// The current token should be clang::tok::r_para
PP.LexUnexpandedToken(PragmaToken);
@@ -272,6 +273,6 @@
": expected a ')'\n");
} else {
// If no argument, remove the license
- this->handleItem( "" );
+ this->handleItem("");
}
}
diff --git a/slang_rs_pragma_handler.hpp b/slang_rs_pragma_handler.h
similarity index 84%
rename from slang_rs_pragma_handler.hpp
rename to slang_rs_pragma_handler.h
index e71c97b..7cca40b 100644
--- a/slang_rs_pragma_handler.hpp
+++ b/slang_rs_pragma_handler.h
@@ -1,19 +1,19 @@
-#ifndef _SLANG_COMILER_RS_PRAGMA_HANDLER_HPP
-# define _SLANG_COMILER_RS_PRAGMA_HANDLER_HPP
+#ifndef _SLANG_COMILER_RS_PRAGMA_HANDLER_H
+#define _SLANG_COMILER_RS_PRAGMA_HANDLER_H
#include <string>
#include "clang/Lex/Pragma.h"
namespace clang {
-class Token;
-class IdentifierInfo;
-class Preprocessor;
+ class Token;
+ class IdentifierInfo;
+ class Preprocessor;
}
namespace slang {
-class RSContext;
+ class RSContext;
class RSPragmaHandler : public clang::PragmaHandler {
protected:
@@ -39,8 +39,8 @@
clang::Token &FirstToken);
// Handle pragma like #pragma rs [name] ("string literal")
- void handleOptionalStringLiateralParamPragma(clang::Preprocessor& PP,
- clang::Token& FirstToken);
+ void handleOptionalStringLiateralParamPragma(clang::Preprocessor &PP,
+ clang::Token &FirstToken);
public:
static RSPragmaHandler *CreatePragmaExportVarHandler(RSContext *Context);
@@ -57,4 +57,4 @@
} // namespace slang
-#endif // _SLANG_COMILER_RS_PRAGMA_HANDLER_HPP
+#endif // _SLANG_COMILER_RS_PRAGMA_HANDLER_H
diff --git a/slang_rs_reflect_utils.cpp b/slang_rs_reflect_utils.cpp
index 12245d6..a18a571 100644
--- a/slang_rs_reflect_utils.cpp
+++ b/slang_rs_reflect_utils.cpp
@@ -1,4 +1,4 @@
-#include "slang_rs_reflect_utils.hpp"
+#include "slang_rs_reflect_utils.h"
#include <cstdlib>
#include <cstdio>
@@ -12,9 +12,10 @@
using std::string;
string RSSlangReflectUtils::ComputePackagedPath(
- const char* prefixPath, const char* packageName) {
+ const char *prefixPath, const char *packageName) {
string packaged_path(prefixPath);
- if (!packaged_path.empty() && (packaged_path[packaged_path.length() - 1] != '/')) {
+ if (!packaged_path.empty() &&
+ (packaged_path[packaged_path.length() - 1] != '/')) {
packaged_path += "/";
}
size_t s = packaged_path.length();
@@ -28,9 +29,9 @@
return packaged_path;
}
-static string InternalFileNameConvert(const char* rsFileName, bool toLower) {
- const char* dot = rsFileName + strlen(rsFileName);
- const char* slash = dot - 1;
+static string InternalFileNameConvert(const char *rsFileName, bool toLower) {
+ const char *dot = rsFileName + strlen(rsFileName);
+ const char *slash = dot - 1;
while (slash >= rsFileName) {
if (*slash == '/') {
break;
@@ -58,17 +59,17 @@
}
std::string RSSlangReflectUtils::JavaClassNameFromRSFileName(
- const char* rsFileName) {
+ const char *rsFileName) {
return InternalFileNameConvert(rsFileName, false);
}
std::string RSSlangReflectUtils::BCFileNameFromRSFileName(
- const char* rsFileName) {
+ const char *rsFileName) {
return InternalFileNameConvert(rsFileName, true);
}
-bool RSSlangReflectUtils::mkdir_p(const char* path) {
+bool RSSlangReflectUtils::mkdir_p(const char *path) {
char buf[256];
char *tmp, *p = NULL;
size_t len = strlen(path);
@@ -76,7 +77,7 @@
if (len + 1 <= sizeof(buf))
tmp = buf;
else
- tmp = new char [len + 1];
+ tmp = new char[len + 1];
strcpy(tmp, path);
@@ -99,7 +100,7 @@
}
static bool GenerateAccessorHeader(
- const RSSlangReflectUtils::BitCodeAccessorContext& context, FILE* pfout) {
+ const RSSlangReflectUtils::BitCodeAccessorContext &context, FILE *pfout) {
fprintf(pfout, "/*\n");
fprintf(pfout, " * This file is auto-generated. DO NOT MODIFY!\n");
fprintf(pfout, " * The source RenderScript file: %s\n", context.rsFileName);
@@ -112,7 +113,7 @@
}
static bool GenerateAccessorMethodSignature(
- const RSSlangReflectUtils::BitCodeAccessorContext& context, FILE* pfout) {
+ const RSSlangReflectUtils::BitCodeAccessorContext &context, FILE *pfout) {
// the prototype of the accessor method
fprintf(pfout, " // return byte array representation of the bitcode.\n");
fprintf(pfout, " public static byte[] getBitCode() {\n");
@@ -122,19 +123,20 @@
// Java method size must not exceed 64k,
// so we have to split the bitcode into multiple segments.
static bool GenerateSegmentMethod(
- const char* buff, int blen, int seg_num, FILE* pfout) {
+ const char *buff, int blen, int seg_num, FILE *pfout) {
fprintf(pfout, " private static byte[] getSegment_%d() {\n", seg_num);
fprintf(pfout, " byte[] data = {\n");
- const static int LINE_BYTE_NUM = 16;
+ static const int LINE_BYTE_NUM = 16;
char out_line[LINE_BYTE_NUM*6 + 10];
- const char* out_line_end = out_line + sizeof(out_line);
- char* p = out_line;
+ const char *out_line_end = out_line + sizeof(out_line);
+ char *p = out_line;
int write_length = 0;
while (write_length < blen) {
- p += snprintf(p, out_line_end - p, " %4d,", (int)buff[write_length]);
+ p += snprintf(p, out_line_end - p,
+ " %4d,", static_cast<int>(buff[write_length]));
++write_length;
if (((write_length % LINE_BYTE_NUM) == 0)
|| (write_length == blen)) {
@@ -153,8 +155,8 @@
}
static bool GenerateJavaCodeAccessorMethod(
- const RSSlangReflectUtils::BitCodeAccessorContext& context, FILE* pfout) {
- FILE* pfin = fopen(context.bcFileName, "rb");
+ const RSSlangReflectUtils::BitCodeAccessorContext &context, FILE *pfout) {
+ FILE *pfin = fopen(context.bcFileName, "rb");
if (pfin == NULL) {
fprintf(stderr, "Error: could not read file %s\n", context.bcFileName);
return false;
@@ -169,8 +171,8 @@
// output the data
// make sure the generated function for a segment won't break the Javac
// size limitation (64K).
- const static int SEG_SIZE = 0x2000;
- char* buff = new char[SEG_SIZE];
+ static const int SEG_SIZE = 0x2000;
+ char *buff = new char[SEG_SIZE];
int read_length;
int seg_num = 0;
int total_length = 0;
@@ -200,8 +202,8 @@
}
static bool GenerateAccessorClass(
- const RSSlangReflectUtils::BitCodeAccessorContext& context,
- const char* clazz_name, FILE* pfout) {
+ const RSSlangReflectUtils::BitCodeAccessorContext &context,
+ const char *clazz_name, FILE *pfout) {
// begin the class.
fprintf(pfout, "/**\n");
fprintf(pfout, " * @hide\n");
@@ -228,7 +230,7 @@
bool RSSlangReflectUtils::GenerateBitCodeAccessor(
- const BitCodeAccessorContext& context) {
+ const BitCodeAccessorContext &context) {
string output_path = ComputePackagedPath(context.reflectPath,
context.packageName);
if (!mkdir_p(output_path.c_str())) {
@@ -246,18 +248,17 @@
output_filename += "/";
output_filename += filename;
printf("Generating %s ...\n", filename.c_str());
- FILE* pfout = fopen(output_filename.c_str(), "w");
+ FILE *pfout = fopen(output_filename.c_str(), "w");
if (pfout == NULL) {
fprintf(stderr, "Error: could not write to file %s\n",
output_filename.c_str());
return false;
}
- bool ret = GenerateAccessorHeader(context, pfout)
- && GenerateAccessorClass(context, clazz_name.c_str(), pfout);
+ bool ret = GenerateAccessorHeader(context, pfout) &&
+ GenerateAccessorClass(context, clazz_name.c_str(), pfout);
fclose(pfout);
return ret;
}
-
}
diff --git a/slang_rs_reflect_utils.hpp b/slang_rs_reflect_utils.h
similarity index 74%
rename from slang_rs_reflect_utils.hpp
rename to slang_rs_reflect_utils.h
index 5151c82..c8eb1d3 100644
--- a/slang_rs_reflect_utils.hpp
+++ b/slang_rs_reflect_utils.h
@@ -1,5 +1,5 @@
-#ifndef _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP
-#define _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP
+#ifndef _SLANG_COMPILER_SLANG_REFLECT_UTILS_H
+#define _SLANG_COMPILER_SLANG_REFLECT_UTILS_H
#include <string>
@@ -21,10 +21,10 @@
// it.
// packageName: the package of the output Java file.
struct BitCodeAccessorContext {
- const char* rsFileName;
- const char* bcFileName;
- const char* reflectPath;
- const char* packageName;
+ const char *rsFileName;
+ const char *bcFileName;
+ const char *reflectPath;
+ const char *packageName;
BitCodeStorageType bcStorage;
};
@@ -32,15 +32,15 @@
// Compuate a Java source file path from a given prefixPath and its package.
// Eg, given prefixPath=./foo/bar and packageName=com.x.y, then it returns
// ./foo/bar/com/x/y
- static std::string ComputePackagedPath(const char* prefixPath,
- const char* packageName);
+ static std::string ComputePackagedPath(const char *prefixPath,
+ const char *packageName);
// Compute Java class name from a .rs file name.
// Any non-alnum, non-underscore characters will be discarded.
// E.g. with rsFileName=./foo/bar/my-Renderscript_file.rs it returns
// "myRenderscript_file".
// rsFileName: the input .rs file name (with or without path).
- static std::string JavaClassNameFromRSFileName(const char* rsFileName);
+ static std::string JavaClassNameFromRSFileName(const char *rsFileName);
// Compute a bitcode file name (no extension) from a .rs file name.
// Because the bitcode file name may be used as Resource ID in the generated
@@ -51,17 +51,15 @@
// E.g. with rsFileName=./foo/bar/my-Renderscript_file.rs it returns
// "myrenderscript_file"
// rsFileName: the input .rs file name (with or without path).
- static std::string BCFileNameFromRSFileName(const char* rsFileName);
+ static std::string BCFileNameFromRSFileName(const char *rsFileName);
// "mkdir -p"
- static bool mkdir_p(const char* path);
+ static bool mkdir_p(const char *path);
// Generate the bit code accessor Java source file.
- static bool GenerateBitCodeAccessor(const BitCodeAccessorContext& context);
-
+ static bool GenerateBitCodeAccessor(const BitCodeAccessorContext &context);
};
-
}
-#endif // _SLANG_COMPILER_SLANG_REFLECT_UTILS_HPP
+#endif // _SLANG_COMPILER_SLANG_REFLECT_UTILS_H
diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp
index 2eaabf6..7a03219 100644
--- a/slang_rs_reflection.cpp
+++ b/slang_rs_reflection.cpp
@@ -1,16 +1,17 @@
-#include "slang_rs_context.hpp"
-#include "slang_rs_export_var.hpp"
-#include "slang_rs_reflection.hpp"
-#include "slang_rs_export_func.hpp"
-#include "slang_rs_reflect_utils.hpp"
-
-#include "llvm/ADT/APFloat.h"
+#include "slang_rs_reflection.h"
#include <utility>
#include <cstdarg>
#include <cctype>
#include <sys/stat.h>
+#include "llvm/ADT/APFloat.h"
+
+#include "slang_rs_context.h"
+#include "slang_rs_export_var.h"
+#include "slang_rs_export_func.h"
+#include "slang_rs_reflect_utils.h"
+
#define RS_SCRIPT_CLASS_NAME_PREFIX "ScriptC_"
#define RS_SCRIPT_CLASS_SUPER_CLASS_NAME "ScriptC"
@@ -157,7 +158,7 @@
}
static const char *GetPackerAPIName(const RSExportPrimitiveType *EPT) {
- static const char* PrimitiveTypePackerAPINameMap[] = {
+ static const char *PrimitiveTypePackerAPINameMap[] = {
"", // RSExportPrimitiveType::DataTypeFloat16
"addF32", // RSExportPrimitiveType::DataTypeFloat32
"addF64", // RSExportPrimitiveType::DataTypeFloat64
@@ -204,7 +205,8 @@
switch (ET->getClass()) {
case RSExportType::ExportClassPrimitive:
case RSExportType::ExportClassConstantArray: {
- return GetPrimitiveTypeName(static_cast<const RSExportPrimitiveType*>(ET));
+ return GetPrimitiveTypeName(
+ static_cast<const RSExportPrimitiveType*>(ET));
break;
}
case RSExportType::ExportClassPointer: {
@@ -222,7 +224,8 @@
break;
}
case RSExportType::ExportClassRecord: {
- return RS_TYPE_CLASS_NAME_PREFIX + ET->getName() + "."RS_TYPE_ITEM_CLASS_NAME;
+ return RS_TYPE_CLASS_NAME_PREFIX + ET->getName() +
+ "."RS_TYPE_ITEM_CLASS_NAME;
break;
}
default: {
@@ -236,7 +239,8 @@
static const char *GetBuiltinElementConstruct(const RSExportType *ET) {
if (ET->getClass() == RSExportType::ExportClassPrimitive ||
ET->getClass() == RSExportType::ExportClassConstantArray) {
- const RSExportPrimitiveType *EPT = static_cast<const RSExportPrimitiveType*>(ET);
+ const RSExportPrimitiveType *EPT =
+ static_cast<const RSExportPrimitiveType*>(ET);
if (EPT->getKind() == RSExportPrimitiveType::DataKindUser) {
static const char *PrimitiveBuiltinElementConstructMap[] = {
NULL, // RSExportPrimitiveType::DataTypeFloat16
@@ -260,12 +264,12 @@
"MATRIX_3X3", // RSExportPrimitiveType::DataTypeRSMatrix3x3
"MATRIX_4X4", // RSExportPrimitiveType::DataTypeRSMatrix4x4
- "ELEMENT", // RSExportPrimitiveType::DataTypeRSElement
- "TYPE", // RSExportPrimitiveType::DataTypeRSType
- "ALLOCATION", // RSExportPrimitiveType::DataTypeRSAllocation
- "SAMPLER", // RSExportPrimitiveType::DataTypeRSSampler
- "SCRIPT", // RSExportPrimitiveType::DataTypeRSScript
- "MESH", // RSExportPrimitiveType::DataTypeRSMesh
+ "ELEMENT", // RSExportPrimitiveType::DataTypeRSElement
+ "TYPE", // RSExportPrimitiveType::DataTypeRSType
+ "ALLOCATION", // RSExportPrimitiveType::DataTypeRSAllocation
+ "SAMPLER", // RSExportPrimitiveType::DataTypeRSSampler
+ "SCRIPT", // RSExportPrimitiveType::DataTypeRSScript
+ "MESH", // RSExportPrimitiveType::DataTypeRSMesh
"PROGRAM_FRAGMENT", // RSExportPrimitiveType::DataTypeRSProgramFragment
"PROGRAM_VERTEX", // RSExportPrimitiveType::DataTypeRSProgramVertex
"PROGRAM_RASTER", // RSExportPrimitiveType::DataTypeRSProgramRaster
@@ -310,7 +314,7 @@
}
} else if (ET->getClass() == RSExportType::ExportClassPointer) {
// Treat pointer type variable as unsigned int
- // (TODO: this is target dependent)
+ // TODO(zonr): this is target dependent
return "USER_I32";
}
@@ -402,8 +406,8 @@
C.getPackageName().c_str());
RSSlangReflectUtils::mkdir_p(_path.c_str());
- C.mOF.open(( _path + "/" + ClassName + ".java" ).c_str());
- if(!C.mOF.good()) {
+ C.mOF.open((_path + "/" + ClassName + ".java").c_str());
+ if (!C.mOF.good()) {
ErrorMsg = "failed to open file '" + _path + "/" + ClassName
+ ".java' for write";
@@ -603,12 +607,13 @@
break;
}
- // TODO: Resolving initializer of a record type variable is complex.
+ // TODO(zonr): Resolving initializer of a record type variable is complex.
// It cannot obtain by just simply evaluating the initializer expression.
case RSExportType::ExportClassRecord: {
#if 0
unsigned InitIndex = 0;
- const RSExportRecordType *ERT = static_cast<const RSExportRecordType*>(ET);
+ const RSExportRecordType *ERT =
+ static_cast<const RSExportRecordType*>(ET);
assert((Val.getKind() == clang::APValue::Vector) && "Unexpected type of "
"initializer for record type variable");
@@ -694,7 +699,7 @@
I != E;
I++) {
const RSExportFunc::Parameter *P = *I;
- Args.push_back( make_pair(GetTypeName(P->getType()), P->getName()) );
+ Args.push_back(make_pair(GetTypeName(P->getType()), P->getName()));
}
C.startFunction(Context::AM_Public,
@@ -723,9 +728,9 @@
void RSReflection::genPrimitiveTypeExportVariable(Context &C,
const RSExportVar *EV) {
- assert(( EV->getType()->getClass() == RSExportType::ExportClassPrimitive ||
- EV->getType()->getClass() == RSExportType::ExportClassConstantArray
- ) && "Variable should be type of primitive here");
+ assert((EV->getType()->getClass() == RSExportType::ExportClassPrimitive ||
+ EV->getType()->getClass() == RSExportType::ExportClassConstantArray)
+ && "Variable should be type of primitive here");
const RSExportPrimitiveType *EPT =
static_cast<const RSExportPrimitiveType*>(EV->getType());
@@ -946,7 +951,8 @@
}
case RSExportType::ExportClassRecord: {
- const RSExportRecordType *ERT = static_cast<const RSExportRecordType*>(ET);
+ const RSExportRecordType *ERT =
+ static_cast<const RSExportRecordType*>(ET);
// Relative pos from now on in field packer
unsigned Pos = 0;
@@ -1085,10 +1091,9 @@
FI != FE;
FI++) {
const RSExportRecordType::Field *F = *FI;
- if( (F->getType()->getClass() == RSExportType::ExportClassVector) ||
+ if ((F->getType()->getClass() == RSExportType::ExportClassVector) ||
(F->getType()->getClass() == RSExportType::ExportClassRecord) ||
- (F->getType()->getClass() == RSExportType::ExportClassConstantArray)
- ) {
+ (F->getType()->getClass() == RSExportType::ExportClassConstantArray)) {
C.indent() << F->getName() << " = new " << GetTypeName(F->getType())
<< "();" << std::endl;
}
@@ -1161,7 +1166,7 @@
}
void RSReflection::genTypeClassItemSetter(Context &C,
- const RSExportRecordType* ERT) {
+ const RSExportRecordType *ERT) {
C.startFunction(Context::AM_Public,
false,
"void",
@@ -1272,10 +1277,8 @@
1,
"int",
"index");
- //C.indent() << "if ("RS_TYPE_ITEM_BUFFER_NAME" == null) return null;"
- //<< std::endl;
- C.indent() << "return "RS_TYPE_ITEM_BUFFER_NAME"[index]." << F->getName() << ";"
- << std::endl;
+ C.indent() << "return "RS_TYPE_ITEM_BUFFER_NAME"[index]." << F->getName()
+ << ";" << std::endl;
C.endFunction();
}
return;
@@ -1298,7 +1301,7 @@
/******************** Methods to generate type class /end ********************/
/********** Methods to create Element in Java of given record type ***********/
-void RSReflection::genBuildElement(Context& C, const RSExportRecordType *ERT,
+void RSReflection::genBuildElement(Context &C, const RSExportRecordType *ERT,
const char *RenderScriptVar) {
const char *ElementBuilderName = "eb";
@@ -1369,7 +1372,7 @@
EB_ADD("createUser(" << RenderScriptVar << ", "
<< DataTypeName << ")");
} else {
- // (ET->getClass() == RSExportType::ExportClassVector) must hold here
+ // ET->getClass() == RSExportType::ExportClassVector must hold here
// Element.createVector()
EB_ADD("createVector(" << RenderScriptVar << ", "
<< DataTypeName << ", "
@@ -1385,8 +1388,8 @@
} else if (ET->getClass() == RSExportType::ExportClassRecord) {
// Simalar to case of RSExportType::ExportClassRecord in genPackVarOfType.
//
- // TODO: Generalize these two function such that there's no duplicated
- // codes.
+ // TODO(zonr): Generalize these two function such that there's no
+ // duplicated codes.
const RSExportRecordType *ERT =
static_cast<const RSExportRecordType*>(ET);
int Pos = 0; // relative pos from now on
@@ -1447,7 +1450,7 @@
void RSReflection::genAddPaddingToElementBuiler(Context &C,
int PaddingSize,
const char *ElementBuilderName,
- const char* RenderScriptVar) {
+ const char *RenderScriptVar) {
while (PaddingSize > 0) {
const std::string &VarName = C.createPaddingField();
if (PaddingSize >= 4) {
@@ -1532,7 +1535,7 @@
}
/************************** RSReflection::Context **************************/
-const char* const RSReflection::Context::ApacheLicenseNote =
+const char *const RSReflection::Context::ApacheLicenseNote =
"/*\n"
" * Copyright (C) 2010 The Android Open Source Project\n"
" *\n"
@@ -1657,11 +1660,11 @@
va_list vl;
va_start(vl, Argc);
- for (int i=0;i<Argc;i++) {
+ for (int i = 0; i < Argc; i++) {
const char *ArgType = va_arg(vl, const char*);
const char *ArgName = va_arg(vl, const char*);
- Args.push_back( std::make_pair(ArgType, ArgName) );
+ Args.push_back(std::make_pair(ArgType, ArgName));
}
va_end(vl);
@@ -1674,8 +1677,7 @@
bool IsStatic,
const char *ReturnType,
const std::string &FunctionName,
- const ArgTy &Args)
-{
+ const ArgTy &Args) {
indent() << AccessModifierStr(AM) << ((IsStatic) ? " static " : " ")
<< ((ReturnType) ? ReturnType : "") << " " << FunctionName << "(";
diff --git a/slang_rs_reflection.hpp b/slang_rs_reflection.h
similarity index 95%
rename from slang_rs_reflection.hpp
rename to slang_rs_reflection.h
index 34b07f4..deae276 100644
--- a/slang_rs_reflection.hpp
+++ b/slang_rs_reflection.h
@@ -1,9 +1,5 @@
-#ifndef _SLANG_COMPILER_RS_REFLECTION_HPP
-# define _SLANG_COMPILER_RS_REFLECTION_HPP
-
-#include "slang_rs_export_type.hpp"
-
-#include "llvm/ADT/StringExtras.h"
+#ifndef _SLANG_COMPILER_RS_REFLECTION_H
+#define _SLANG_COMPILER_RS_REFLECTION_H
#include <map>
#include <vector>
@@ -12,11 +8,15 @@
#include <fstream>
#include <iostream>
+#include "llvm/ADT/StringExtras.h"
+
+#include "slang_rs_export_type.h"
+
namespace slang {
-class RSContext;
-class RSExportVar;
-class RSExportFunc;
+ class RSContext;
+ class RSExportVar;
+ class RSExportFunc;
class RSReflection {
private:
@@ -92,7 +92,7 @@
}
inline std::ostream &out() const {
- if (mUseStdout) return std::cout; else return mOF;
+ return ((mUseStdout) ? std::cout : mOF);
}
inline std::ostream &indent() const {
out() << mIndent;
@@ -201,7 +201,7 @@
const std::string &VarName,
const clang::APValue &Val);
void genInitPrimitiveExportVariable(Context &C,
- const std::string& VarName,
+ const std::string &VarName,
const clang::APValue &Val);
void genInitExportVariable(Context &C,
const RSExportType *ET,
@@ -260,7 +260,7 @@
void genNewItemBufferPackerIfNull(Context &C);
public:
- RSReflection(const RSContext *Context)
+ explicit RSReflection(const RSContext *Context)
: mRSContext(Context),
mLastError("") {
return;
@@ -280,4 +280,4 @@
} // namespace slang
-#endif // _SLANG_COMPILER_RS_REFLECTION_HPP
+#endif // _SLANG_COMPILER_RS_REFLECTION_H