Skip to content

Commit

Permalink
Merge pull request #133 from Ecordonnier/eco/clang17
Browse files Browse the repository at this point in the history
Fix clang17++ compilation
  • Loading branch information
giuseppe committed Apr 11, 2024
2 parents f76be64 + 86650dc commit c715dcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/ocispec/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def handle_single_file(args, srcpath, gen_ref, schemapath):
History: 2019-06-17
"""
if not os.path.exists(schemapath.name) or not os.path.exists(srcpath.name):
print('Path %s is not exist' % schemapath.name)
print('Path %s does not exist' % schemapath.name)
sys.exit(1)

if os.path.isdir(schemapath.name):
Expand All @@ -754,7 +754,7 @@ def handle_single_file(args, srcpath, gen_ref, schemapath):
reflection(schema_info, gen_ref)
print("\033[1;34mReflection:\033[0m\t%-60s \033[1;32mSuccess\033[0m" % (target_file))
else:
# only parse files in current direcotory
# only parse files in current directory
for target_file in os.listdir(schemapath.name):
fullpath = os.path.join(schemapath.name, target_file)
if fullpath.endswith(JSON_SUFFIX) and os.path.isfile(fullpath):
Expand All @@ -767,7 +767,7 @@ def handle_single_file(args, srcpath, gen_ref, schemapath):
reflection(schema_info, gen_ref)
print("\033[1;34mReflection:\033[0m\t%-60s \033[1;32mSuccess\033[0m" % (schemapath.name))
else:
print('File %s is not ends with .json' % schemapath.name)
print('File %s does not end with .json' % schemapath.name)


def handle_files(args, srcpath):
Expand Down Expand Up @@ -817,7 +817,7 @@ def main():

root_path = os.path.realpath(args.root)
if not os.path.exists(root_path):
print('Root %s is not exist' % args.root)
print('Root %s does not exist' % args.root)
sys.exit(1)

MyRoot.root_path = root_path
Expand Down
18 changes: 6 additions & 12 deletions src/ocispec/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import os
import sys

cxx_reserved_keywords = ["class", "delete", "explicit", "friend", "mutable", "new",
"operator", "private", "protected", "public", "throw", "try", "virtual"]

def append_separator(substr):
'''
Description: append only '_' at last position of subStr
Expand All @@ -45,6 +48,9 @@ def conv_to_c_style(name):
'''
if name is None or name == "":
return ""
# replace C++ reserved keywords (the generated C headers can be included in C++ applications)
if name in cxx_reserved_keywords:
name = '_' + name
name = name.replace('.', '_').replace('-', '_').replace('/', '_')
substr = []
preindex = 0
Expand Down Expand Up @@ -243,9 +249,6 @@ def __init__(self, name, leaf=None):
def __repr__(self):
return self.name

def __str__(self):
return self.name

def append(self, leaf):
'''
Description: append name
Expand Down Expand Up @@ -283,9 +286,6 @@ def __repr__(self):
% (self.name, self.typ, self.subtyp)
return "name:(%s) type:(%s)" % (self.name, self.typ)

def __str__(self):
return self.__repr__(self)


class FilePath(object):
'''
Expand All @@ -302,9 +302,6 @@ def __repr__(self):
return "{name:(%s) dirname:(%s) basename:(%s)}" \
% (self.name, self.dirname, self.basename)

def __str__(self):
return self.__repr__(self)


class SchemaInfo(object):
'''
Expand All @@ -326,6 +323,3 @@ def __init__(self, name, header, source, prefix, filesdir, refs=None):
def __repr__(self):
return "{name:(%s) header:(%s) source:(%s) prefix:(%s)}" \
% (self.name, self.header, self.source, self.prefix)

def __str__(self):
return self.__repr__(self)

0 comments on commit c715dcd

Please sign in to comment.