-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include cppguts/tests/data/*.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <iostream> | ||
|
||
// helper class that is used by the target class `Src` | ||
class SrcPrivate { | ||
public: | ||
SrcPrivate(){}; | ||
|
||
void add(int v){ | ||
val += v; | ||
} | ||
|
||
void substract(int v){ | ||
val -= v; | ||
} | ||
|
||
private: | ||
int val; | ||
} | ||
|
||
// target class | ||
class Src { | ||
// method defined inside the class | ||
void add(SrcPrivate p, int v){ | ||
|
||
p.add(v) + 10; | ||
|
||
} | ||
|
||
// method defined outside the class | ||
void substract(SrcPrivate p, int v); | ||
|
||
// we won't tuch this method | ||
void untouched_print(int v){ | ||
std::cout << "The value is:\t" << v << std::endl; | ||
} | ||
} | ||
|
||
void Src::substract(SrcPrivate p, int v){ | ||
p.substract(v) - 10; | ||
} | ||
|
||
// simple function | ||
void foo(int &v){ | ||
v -= 10; | ||
} | ||
|
||
namespace ns { | ||
// function in namespace | ||
void bar(int &v){ | ||
v += 10; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
import unittest, pathlib | ||
from pathlib import Path | ||
import shutil | ||
import subprocess, os, filecmp | ||
import unittest | ||
|
||
|
||
class test_basics(unittest.TestCase): | ||
def setUp(self): | ||
self.srcin = 'data/src.h.in' | ||
self.destin = 'data/dest.h.in' | ||
self.src = 'data/tmp/src.h' | ||
self.dest = 'data/tmp/dest.h' | ||
|
||
def tearDown(self): | ||
h5File = self.seisContainer.getH5File() | ||
|
||
seisContainer = None | ||
p = h5geo.SeisParam() | ||
FILE_NAME = None | ||
SEIS_NAME1 = None | ||
SEIS_NAME2 = None | ||
this_dir = os.path.dirname(__file__) | ||
data_dir = this_dir + '/data' | ||
tmp_dir = data_dir + '/tmp' | ||
src = tmp_dir + '/src.h' | ||
dest = tmp_dir + '/dest.h' | ||
srcin = data_dir + '/src.h.in' | ||
destin = data_dir + '/dest.h.in' | ||
|
||
def test_createContainer(self): | ||
self.assertTrue(os.path.isfile(self.FILE_NAME)) | ||
|
||
def test_createSeisWithDifferentCreateFlags(self): | ||
seis = self.seisContainer.createSeis(self.SEIS_NAME1, self.p, h5geo.CreationType.OPEN_OR_CREATE) | ||
self.assertFalse(seis is None) | ||
def setUp(self): | ||
shutil.rmtree(self.tmp_dir, ignore_errors=True) | ||
Path(self.tmp_dir).mkdir(parents=True, exist_ok=True) | ||
shutil.copy(self.srcin, self.src) | ||
shutil.copy(self.destin, self.dest) | ||
|
||
seis = self.seisContainer.createSeis(self.SEIS_NAME1, self.p, h5geo.CreationType.CREATE_OR_OVERWRITE) | ||
self.assertFalse(seis is None) | ||
# def tearDown(self): | ||
# shutil.rmtree(self.tmp_dir, ignore_errors=True) | ||
|
||
seis = self.seisContainer.createSeis(self.SEIS_NAME1, self.p, h5geo.CreationType.CREATE_UNDER_NEW_NAME) | ||
self.assertFalse(seis is None) | ||
def test_basics(self): | ||
subprocess.run(['editcpp', '--src-file', self.src, '--dest-file', self.dest, '--oldfile-keep', '-std=c++03']) | ||
|
||
seis = self.seisContainer.createSeis(self.SEIS_NAME1, self.p, h5geo.CreationType.OPEN_OR_CREATE) | ||
self.assertFalse(seis is None) | ||
with open(self.dest) as f: | ||
with open(self.destin) as fin: | ||
self.assertTrue(f != fin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel" | ||
] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
from setuptools import setup | ||
import setuptools | ||
|
||
setup( | ||
setuptools.setup( | ||
name='cppguts', | ||
version='0.1.0', | ||
packages=['cppguts'], | ||
packages=setuptools.find_packages(), | ||
url='https://github.com/tierra-colada/cppguts', | ||
license='MIT', | ||
author='kerim khemrev', | ||
author_email='[email protected]', | ||
description='python package aimed at C++ source code correction', | ||
download_url='https://github.com/tierra-colada/cppguts/archive/refs/tags/v0.1.0.tar.gz', | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'Environment :: Console', | ||
'Intended Audience :: Developers', | ||
'Topic :: Software Development :: Build Tools', | ||
'Programming Language :: Python :: 3.6', | ||
'Topic :: Software Development :: Code Generators', | ||
'License :: OSI Approved :: MIT License', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
], | ||
keywords='c cpp c-parser cpp-parser c-editor cpp-editor c-generator cpp-generator', | ||
entry_points={ | ||
'console_scripts': ['editcpp=cppguts.editcpp:main', | ||
'dumpcpp=cppguts.dumpcpp:main'] | ||
}, | ||
python_requires='>=3', | ||
install_requires=[ | ||
'libclang', | ||
], | ||
include_package_data=True # important to copy MANIFEST.in files | ||
) |