Skip to content

Commit

Permalink
Refactoring (#25)
Browse files Browse the repository at this point in the history
refactored (is not stable)
  • Loading branch information
Vipul-Cariappa authored Jan 15, 2023
1 parent 5d5a593 commit 69f9fce
Show file tree
Hide file tree
Showing 23 changed files with 3,636 additions and 6,272 deletions.
142 changes: 142 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
- DS_LIST_FOREACH
- DS_LIST_PTR_FOREACH
- DS_ARRAY_FOREACH
- DS_ARRAY_PTR_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
...

43 changes: 43 additions & 0 deletions .github/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from distutils.core import setup, Extension


with open("README.md") as f:
module_discription = f.read()

module = Extension(
"PyC",
sources=[
"src/CppTypeInfo.c",
"src/CppWrapper_PyTypes.c",
"src/PyC.c",
"src/TypeConversions.c",
"src/Py_C_Types.c",
],
include_dirs=[
"src/",
"/usr/include/x86_64-linux-gnu",
"/usr/lib/llvm-14/include",
],
libraries=[
"ffi",
"clang-14",
],
extra_compile_args=[
"-ftest-coverage",
"-fprofile-arcs",
],
extra_link_args=[
"-lgcov",
]
)

setup(
name="PyC",
version="0.0.1",
description="General Purpose Binding between Python & C/C++",
ext_modules=[module],
author="Vipul Cariappa",
author_email="[email protected]",
url="https://github.com/Vipul-Cariappa/PyC",
long_description=module_discription,
)
9 changes: 6 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- name: Install Requirements
run: |
sudo apt-get install -y libclang-dev libffi-dev
sudo apt-get install -y libclang-14-dev libffi-dev
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v2
Expand All @@ -22,13 +22,16 @@ jobs:
# queries: security-and-quality

- name: Build
run: python setup.py build
run: |
mv -f ./.github/setup.py ./setup.py
python setup.py build
# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v2

- name: Install
run: python setup.py install
run: |
python setup.py install
- name: Test
run: bash ./.github/test.sh
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,4 @@ PyC.vcxproj
PyC.vcxproj.user
run.sh
premake5.lua
.clangd/
9 changes: 4 additions & 5 deletions .gitpod.run.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ if ! gcc -g -Wall -shared -fPIC -I./tests/c/ -o tests/libcmodule.so tests/c/modu
fi

printf "\nRunning the tests\n"
if ! python3.11 -X dev -X showrefcount tests/test.py -v ; then
if ! python3.11d -X dev -X showrefcount tests/test.py -v ; then
exit 1
fi


printf "\nBuilding PyC\n"
printf "\nBuilding PyC to Check Memory Leaks\n"
if ! make config=memorytest ; then
exit 1
fi
Expand All @@ -34,7 +33,7 @@ if ! cp ./bin/MemoryTest/libPyC.so ./tests/PyC.so ; then
exit 1
fi

printf "\nRunning the tests\n"
if ! LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/9/libasan.so python3.11 -X dev -X showrefcount tests/test.py -v ; then
printf "\nRunning tests to Check Memory Leaks\n"
if ! LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/10/libasan.so python3.11d -X dev -X showrefcount tests/test.py -v ; then
exit 1
fi
19 changes: 3 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,13 @@
],
include_dirs=[
"src/",
"/usr/include/python3.9",
"/usr/local/include",
"/usr/lib/llvm-10/include",
],
library_dirs=[
"/usr/local/lib",
"/usr/lib",
"usr/lib/x86_64-linux-gnu",
"/usr/include/x86_64-linux-gnu",
"/usr/lib/llvm-14/include",
],
libraries=[
"ffi",
"clang-10",
],
extra_compile_args=[
"-ftest-coverage",
"-fprofile-arcs",
"clang-14",
],
extra_link_args=[
"-lgcov",
]
)

setup(
Expand Down
Loading

0 comments on commit 69f9fce

Please sign in to comment.