Skip to content

Commit

Permalink
update olua to v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Sep 1, 2024
1 parent 60feb2f commit 3d74e0e
Show file tree
Hide file tree
Showing 7 changed files with 1,191 additions and 872 deletions.
4 changes: 2 additions & 2 deletions build.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OLUA_AUTO_EXPORT_PARENT = true

require "olua"

olua.AUTO_EXPORT_PARENT = true

-------------------------------------------------------------------------------
--- clang compile options
-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion llvm-project
Submodule llvm-project updated 6720 files
2 changes: 1 addition & 1 deletion olua
Submodule olua updated 65 files
+2 −50 addons/clang/library/clang.lua
+1 −0 addons/clang/library/clang/AvailabilityKind.lua
+1 −0 addons/clang/library/clang/CXXAccessSpecifier.lua
+1 −0 addons/clang/library/clang/CallingConv.lua
+34 −44 addons/clang/library/clang/Cursor.lua
+7 −0 addons/clang/library/clang/Cursor/SourceLocation.lua
+7 −0 addons/clang/library/clang/Cursor/SourceRange.lua
+19 −18 addons/clang/library/clang/CursorKind.lua
+3 −3 addons/clang/library/clang/Diagnostic.lua
+1 −0 addons/clang/library/clang/DiagnosticSeverity.lua
+2 −6 addons/clang/library/clang/File.lua
+1 −0 addons/clang/library/clang/GlobalOptFlags.lua
+7 −2 addons/clang/library/clang/Index.lua
+6 −1 addons/clang/library/clang/IndexError.lua
+1 −0 addons/clang/library/clang/LanguageKind.lua
+1 −0 addons/clang/library/clang/LinkageKind.lua
+1 −0 addons/clang/library/clang/Module.lua
+3 −2 addons/clang/library/clang/RefQualifierKind.lua
+1 −0 addons/clang/library/clang/StorageClass.lua
+1 −0 addons/clang/library/clang/TLSKind.lua
+1 −0 addons/clang/library/clang/TemplateArgumentKind.lua
+25 −12 addons/clang/library/clang/TranslationUnit.lua
+15 −7 addons/clang/library/clang/Type.lua
+1 −0 addons/clang/library/clang/TypeKind.lua
+1 −0 addons/clang/library/clang/TypeNullabilityKind.lua
+1 −0 addons/clang/library/clang/VisibilityKind.lua
+59 −0 addons/clang/library/clang/clang.lua
+3 −3 examples/00-testapi/build.lua
+7 −0 examples/00-testapi/src/Example.h
+796 −932 examples/00-testapi/src/lua_example.cpp
+1 −1 examples/00-testapi/src/lua_example.h
+3 −7 examples/00-testapi/src/test.lua
+3 −3 examples/01-helloworld/build.lua
+59 −32 examples/01-helloworld/src/lua_example.cpp
+1 −1 examples/01-helloworld/src/lua_example.h
+97 −58 examples/02-callback/src/lua_example.cpp
+1 −1 examples/02-callback/src/lua_example.h
+90 −63 examples/03-convertor/src/lua_example.cpp
+1 −1 examples/03-convertor/src/lua_example.h
+73 −55 examples/04-reference/src/lua_example.cpp
+1 −1 examples/04-reference/src/lua_example.h
+2 −2 examples/05-template/build.lua
+185 −104 examples/05-template/src/lua_example.cpp
+1 −1 examples/05-template/src/lua_example.h
+16 −15 examples/05-template/src/test.lua
+2 −2 examples/06-smartptr/build.lua
+5 −0 examples/06-smartptr/src/Example.h
+98 −41 examples/06-smartptr/src/lua_example.cpp
+1 −1 examples/06-smartptr/src/lua_example.h
+7 −6 examples/06-smartptr/src/test.lua
+1,427 −3,152 examples/common/lua_types.cpp
+1 −1 examples/common/lua_types.h
+1 −1 init.lua
+15 −15 olua.c
+53 −1 olua.code-workspace
+5 −9 olua.h
+66 −74 olua.hpp
+381 −270 script/autoconf.lua
+25 −16 script/basictype.lua
+20 −5 script/gen-callback.lua
+160 −127 script/gen-class.lua
+136 −104 script/gen-func.lua
+118 −46 script/idl.lua
+22 −30 script/olua.lua
+91 −43 script/parser.lua
17 changes: 0 additions & 17 deletions src/clang_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,6 @@ std::shared_ptr<Cursor> TranslationUnit::cursor()
return _cursor->shared_from_this();
}

bool TranslationUnit::isFileMultipleIncludeGuarded(File *f)
{
return clang_isFileMultipleIncludeGuarded(_value, f->_value);
}

std::shared_ptr<File> TranslationUnit::getFile(const std::string &path)
{
return makeFile(clang_getFile(_value, path.c_str()));
}

string TranslationUnit::getFileContents(File *f)
{
size_t len;
const char *data = clang_getFileContents(_value, f->_value, &len);
return string(data, len);
}

std::vector<std::shared_ptr<Diagnostic>> TranslationUnit::diagnostics()
{
std::vector<std::shared_ptr<Diagnostic>> arr;
Expand Down
86 changes: 54 additions & 32 deletions src/clang_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class File : public IndexError, public std::enable_shared_from_this<File>
}

/** @oluasee clang_File_tryGetRealPathName */
string tryGetRealPathName() {
OLUA_GETTER string realPathName() {
return clang_File_tryGetRealPathName(_value);
}
private:
Expand Down Expand Up @@ -267,6 +267,11 @@ class Type : public IndexError, public std::enable_shared_from_this<Type>
return arr;
}

/** @oluasee clang_getNumArgTypes */
OLUA_GETTER int numArgTypes() {
return clang_getNumArgTypes(_value);
}

/** @oluasee clang_getArgType */
std::shared_ptr<Type> getArgType(unsigned int i) {
return makeType(clang_getArgType(_value, i));
Expand Down Expand Up @@ -337,7 +342,7 @@ class Type : public IndexError, public std::enable_shared_from_this<Type>
return makeType(clang_Type_getValueType(_value));
}
/** @oluasee clang_Type_getOffsetOf */
long long offsetOf(const char *field) {
long long getOffsetOf(const char *field) {
return clang_Type_getOffsetOf(_value, field);
}

Expand All @@ -351,6 +356,12 @@ class Type : public IndexError, public std::enable_shared_from_this<Type>
return arr;
}

/** @oluasee clang_Type_getNumTemplateArguments */
OLUA_GETTER int numTemplateArguments() {
return clang_Type_getNumTemplateArguments(_value);
}

/** @oluasee clang_Type_getTemplateArgumentAsType */
std::shared_ptr<Type> getTemplateArgument(unsigned int i) {
return makeType(clang_Type_getTemplateArgumentAsType(_value, i));
}
Expand Down Expand Up @@ -423,7 +434,7 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_hashCursor */
unsigned hashCursor() {
OLUA_GETTER unsigned hash() {
return clang_hashCursor(_value);
}

Expand Down Expand Up @@ -569,7 +580,7 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_getTypedefDeclUnderlyingType */
OLUA_GETTER std::shared_ptr<Type> underlyingType() {
OLUA_GETTER std::shared_ptr<Type> typedefDeclUnderlyingType() {
return makeType(clang_getTypedefDeclUnderlyingType(_value));
}

Expand Down Expand Up @@ -614,17 +625,17 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_Cursor_getTemplateArgumentValue */
TemplateArgumentKind templateArgumentKind(unsigned index) {
TemplateArgumentKind getTemplateArgumentKind(unsigned index) {
return clang_Cursor_getTemplateArgumentKind(_value, index);
}

/** @oluasee clang_Cursor_getTemplateArgumentValue */
long long templateArgumentValue(unsigned index) {
long long getTemplateArgumentValue(unsigned index) {
return clang_Cursor_getTemplateArgumentValue(_value, index);
}

/** @oluasee clang_Cursor_getTemplateArgumentUnsignedValue */
unsigned long long templateArgumentUnsignedValue(unsigned index) {
unsigned long long getTemplateArgumentUnsignedValue(unsigned index) {
return clang_Cursor_getTemplateArgumentUnsignedValue(_value, index);
}

Expand Down Expand Up @@ -722,11 +733,6 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}
return arr;
}

/** @oluasee clang_getIBOutletCollectionType */
OLUA_GETTER std::shared_ptr<Type> ibOutletCollectionType() {
return makeType(clang_getIBOutletCollectionType(_value));
}

/** @oluasee clang_visitChildren */
OLUA_GETTER std::vector<std::shared_ptr<Cursor>> children() {
Expand All @@ -736,7 +742,7 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_Cursor_getSpellingNameRange */
SourceRange nameRange(unsigned pieceIndex, unsigned options) {
SourceRange getNameRange(unsigned pieceIndex, unsigned options) {
CXSourceRange range = clang_Cursor_getSpellingNameRange(_value, pieceIndex, options);
return getRange(range);
}
Expand Down Expand Up @@ -819,7 +825,7 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_Cursor_getModule */
std::shared_ptr<Module> getModule() {
OLUA_GETTER std::shared_ptr<Module> getModule() {
return makeModule(clang_Cursor_getModule(_value));
}

Expand All @@ -844,52 +850,52 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_CXXField_isMutable */
OLUA_GETTER bool isCXXFieldMutable() {
OLUA_GETTER bool isCXXMutableField() {
return clang_CXXField_isMutable(_value);
}

/** @oluasee clang_CXXMethod_isDefaulted */
OLUA_GETTER bool isCXXMethodDefaulted() {
OLUA_GETTER bool isCXXDefaultedMethod() {
return clang_CXXMethod_isDefaulted(_value);
}

/** @oluasee clang_CXXMethod_isDeleted */
OLUA_GETTER bool isCXXMethodDeleted() {
OLUA_GETTER bool isCXXDeletedMethod() {
return clang_CXXMethod_isDeleted(_value);
}

/** @oluasee clang_CXXMethod_isPureVirtual */
OLUA_GETTER bool isCXXMethodPureVirtual() {
OLUA_GETTER bool isCXXPureVirtualMethod() {
return clang_CXXMethod_isPureVirtual(_value);
}

/** @oluasee clang_CXXMethod_isStatic */
OLUA_GETTER bool isCXXMethodStatic() {
OLUA_GETTER bool isCXXStaticMethod() {
return clang_CXXMethod_isStatic(_value);
}

/** @oluasee clang_CXXMethod_isVirtual */
OLUA_GETTER bool isCXXMethodVirtual() {
OLUA_GETTER bool isCXXVirtualMethod() {
return clang_CXXMethod_isVirtual(_value);
}

/** @oluasee clang_CXXMethod_isCopyAssignmentOperator */
OLUA_GETTER bool isCXXMethodCopyAssignmentOperator() {
OLUA_GETTER bool isCXXCopyAssignmentOperator() {
return clang_CXXMethod_isCopyAssignmentOperator(_value);
}

/** @oluasee clang_CXXMethod_isMoveAssignmentOperator */
OLUA_GETTER bool isCXXMethodMoveAssignmentOperator() {
OLUA_GETTER bool isCXXMoveAssignmentOperator() {
return clang_CXXMethod_isMoveAssignmentOperator(_value);
}

/** @oluasee clang_CXXMethod_isConst */
OLUA_GETTER bool isCXXMethodConst() {
OLUA_GETTER bool isCXXConstMethod() {
return clang_CXXMethod_isConst(_value);
}

/** @oluasee clang_CXXMethod_isExplicit */
OLUA_GETTER bool isCXXMethodExplicit() {
OLUA_GETTER bool isCXXExplicitMethod() {
return clang_CXXMethod_isExplicit(_value);
}

Expand All @@ -899,7 +905,7 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_EnumDecl_isScoped */
OLUA_GETTER bool isEnumDeclScoped() {
OLUA_GETTER bool isScopedEnumDecl() {
return clang_EnumDecl_isScoped(_value);
}

Expand All @@ -919,7 +925,7 @@ class Cursor : public IndexError, public std::enable_shared_from_this<Cursor>
}

/** @oluasee clang_getCursorReferenceNameRange */
SourceRange referenceNameRange(unsigned pieceIndex, unsigned options) {
SourceRange getReferenceNameRange(unsigned pieceIndex, unsigned options) {
CXSourceRange range = clang_getCursorReferenceNameRange(_value, pieceIndex, options);
return getRange(range);
}
Expand Down Expand Up @@ -965,18 +971,34 @@ class TranslationUnit : public IndexError, public std::enable_shared_from_this<T
OLUA_GETTER string name();
OLUA_GETTER std::shared_ptr<Cursor> cursor();

bool isFileMultipleIncludeGuarded(File *f);
std::shared_ptr<File> getFile(const std::string &path);
string getFileContents(File *f);
/** @oluasee clang_isFileMultipleIncludeGuarded */
bool isFileMultipleIncludeGuarded(File *f) {
return clang_isFileMultipleIncludeGuarded(_value, f->_value);
}

/** @oluasee clang_getFile */
std::shared_ptr<File> getFile(const std::string &path)
{
return makeFile(clang_getFile(_value, path.c_str()));
}

/** @oluasee clang_getFileContents */
string getFileContents(File *f)
{
size_t len;
const char *data = clang_getFileContents(_value, f->_value, &len);
return string(data, len);
}

OLUA_GETTER std::vector<std::shared_ptr<Diagnostic>> diagnostics();
OLUA_GETTER std::set<std::shared_ptr<Diagnostic>> diagnosticSetFromTU();
std::shared_ptr<Module> moduleForFile(const std::shared_ptr<File> &file);
unsigned numTopLevelHeaders(const std::shared_ptr<Module> &m);
std::shared_ptr<File> topLevelHeader(const std::shared_ptr<Module> &m, unsigned index);
unsigned defaultSaveOptions();
OLUA_GETTER unsigned defaultSaveOptions();
int saveTranslationUnit(const std::string &path, unsigned options);
unsigned suspendTranslationUnit();
unsigned defaultReparseOptions();
OLUA_GETTER unsigned suspendTranslationUnit();
OLUA_GETTER unsigned defaultReparseOptions();
private:
CXTranslationUnit _value;
std::shared_ptr<Cursor> _cursor;
Expand Down
Loading

0 comments on commit 3d74e0e

Please sign in to comment.