Skip to content

Commit 8359653

Browse files
committed
Fix char array in struct
1 parent 32431a0 commit 8359653

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Main.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#define CATCH_CONFIG_RUNNER
55
#include "catch/catch.hpp"
66

7-
#include <sys/types.h>
8-
97
static llvm::cl::OptionCategory Category("Binding Generator");
108
static llvm::cl::extrahelp CommonHelp(clang::tooling::CommonOptionsParser::HelpMessage);
119
static llvm::cl::extrahelp MoreHelp("\nProduce Bindings for scala native. Please specify lib name wit parameter name\n");
@@ -62,8 +60,11 @@ int main(int argc, char *argv[]) {
6260
<< "@native.extern\n"
6361
<< "object " << lib << " {\n"
6462
<< declarations
65-
<< "}\n\n"
66-
<< "import " + lib + "._\n\n";
63+
<< "}\n\n";
64+
}
65+
66+
if(enums != "" || helpers != ""){
67+
llvm::outs() << "import " + lib + "._\n\n";
6768
}
6869

6970
if(enums != ""){

TypeTranslator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ std::string TypeTranslator::TranslateFunctionPointer(const clang::QualType& qtpe
6262
}
6363
}
6464

65-
std::string TypeTranslator::TranslatePointer(const clang::PointerType* ptr, const std::string* avoid){
66-
const clang::QualType& pte = ptr->getPointeeType();
65+
std::string TypeTranslator::TranslatePointer(const clang::QualType& pte, const std::string* avoid){
6766

6867
if(pte->isBuiltinType()){
6968
const clang::BuiltinType* as = pte->getAs<clang::BuiltinType>();
@@ -147,7 +146,7 @@ std::string TypeTranslator::Translate(const clang::QualType& qtpe, const std::st
147146
return TranslateFunctionPointer(qtpe, avoid);
148147

149148
} else if(tpe->isPointerType()){
150-
return TranslatePointer(tpe->getAs<clang::PointerType>(), avoid);
149+
return TranslatePointer(tpe->getAs<clang::PointerType>()->getPointeeType(), avoid);
151150

152151
} else if(qtpe->isStructureType() || qtpe->isUnionType()){
153152
return TranslateStructOrUnion(qtpe);
@@ -157,7 +156,8 @@ std::string TypeTranslator::Translate(const clang::QualType& qtpe, const std::st
157156

158157
} else if(qtpe->isConstantArrayType()){
159158
return TranslateConstantArray(ctx->getAsConstantArrayType(qtpe), avoid);
160-
159+
} else if(qtpe->isArrayType()){
160+
return TranslatePointer(ctx->getAsArrayType(qtpe)->getElementType(), avoid);
161161
} else {
162162

163163
auto found = typeMap.find(qtpe.getUnqualifiedType().getAsString());

TypeTranslator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TypeTranslator {
2121
*/
2222
std::string Translate(const clang::QualType& tpe, const std::string* = nullptr);
2323
std::string TranslateFunctionPointer(const clang::QualType& qtpe, const std::string* avoid );
24-
std::string TranslatePointer(const clang::PointerType* ptr, const std::string* avoid );
24+
std::string TranslatePointer(const clang::QualType& pointee, const std::string* avoid);
2525
std::string TranslateStructOrUnion(const clang::QualType& qtpe);
2626
std::string TranslateEnum(const clang::QualType& qtpe);
2727
std::string TranslateConstantArray(const clang::ConstantArrayType* ar, const std::string* avoid );

0 commit comments

Comments
 (0)