Commit e3867e5f authored by Simon Boyé's avatar Simon Boyé

Vitelotte: updated include guard to make them consistent + added a utility to check their validity.

parent f95231f5
#ifndef _ELEMENT_BUILDER_BASE_H_
#define _ELEMENT_BUILDER_BASE_H_
#ifndef _VITELOTTE_ELEMENT_BUILDER_BASE_
#define _VITELOTTE_ELEMENT_BUILDER_BASE_
#include <string>
......
#ifndef _FEM_SOLVER_H_
#define _FEM_SOLVER_H_
#ifndef _VITELOTTE_FEM_SOLVER_
#define _VITELOTTE_FEM_SOLVER_
#include <cassert>
......
#ifndef _FEM_UTILS_H_
#define _FEM_UTILS_H_
#ifndef _VITELOTTE_FEM_UTILS_
#define _VITELOTTE_FEM_UTILS_
#include <Eigen/Core>
......
#ifndef _FV_ELEMENT_BUILDER_H_
#define _FV_ELEMENT_BUILDER_H_
#ifndef _VITELOTTE_FV_ELEMENT_BUILDER_
#define _VITELOTTE_FV_ELEMENT_BUILDER_
#include <Eigen/Core>
......
#ifndef _LINEAR_ELEMENT_BUILDER_H_
#define _LINEAR_ELEMENT_BUILDER_H_
#ifndef _VITELOTTE_LINEAR_ELEMENT_BUILDER_
#define _VITELOTTE_LINEAR_ELEMENT_BUILDER_
#include <Eigen/Core>
......
#ifndef _MORLEY_ELEMENT_BUILDER_H_
#define _MORLEY_ELEMENT_BUILDER_H_
#ifndef _VITELOTTE_MORLEY_ELEMENT_BUILDER_
#define _VITELOTTE_MORLEY_ELEMENT_BUILDER_
#include <Eigen/Core>
......
#ifndef _QUADRATIC_ELEMENT_BUILDER_H_
#define _QUADRATIC_ELEMENT_BUILDER_H_
#ifndef _VITELOTTE_QUADRATIC_ELEMENT_BUILDER_
#define _VITELOTTE_QUADRATIC_ELEMENT_BUILDER_
#include <Eigen/Core>
......
#ifndef _SINGULAR_ELEMENT_DECORATOR_H_
#define _SINGULAR_ELEMENT_DECORATOR_H_
#ifndef _VITELOTTE_SINGULAR_ELEMENT_DECORATOR_
#define _VITELOTTE_SINGULAR_ELEMENT_DECORATOR_
#include <vector>
......
#ifndef VGMESH_H
#define VGMESH_H
#ifndef _VITELOTTE_VG_MESH_
#define _VITELOTTE_VG_MESH_
#include <cassert>
......
#ifndef _MVGREADER_H_
#define _MVGREADER_H_
#ifndef _VITELOTTE_MVG_READER_
#define _VITELOTTE_MVG_READER_
#include <cassert>
......
#ifndef _MVGWRITER_H_
#define _MVGWRITER_H_
#ifndef _VITELOTTE_MVG_WRITER_
#define _VITELOTTE_MVG_WRITER_
#include <cassert>
......
#ifndef _VG_MESH_GL2_RENDERER_BASE_H_
#define _VG_MESH_GL2_RENDERER_BASE_H_
#ifndef _VITELOTTE_VG_MESH_GL2_RENDERER_
#define _VITELOTTE_VG_MESH_GL2_RENDERER_
#include <Eigen/Dense>
......
#ifndef _VG_MESH_RENDERER_BASE_H_
#define _VG_MESH_RENDERER_BASE_H_
#ifndef _VITELOTTE_VG_MESH_RENDERER_
#define _VITELOTTE_VG_MESH_RENDERER_
#include <Eigen/Dense>
......
#ifndef _MACROS_H_
#define _MACROS_H_
#ifndef _PATATE_COMMON_GL_UTILS_MACROS_
#define _PATATE_COMMON_GL_UTILS_MACROS_
#include <stdlib.h>
......
#ifndef _SHADER_H_
#define _SHADER_H_
#ifndef _PATATE_COMMON_GL_UTILS_SHADER_
#define _PATATE_COMMON_GL_UTILS_SHADER_
#include <cstdio>
#include <cstring>
......
#ifndef _OBJREADER_H_
#define _OBJREADER_H_
#ifndef _PATATE_COMMON_SURFACE_MESH_OBJ_READER_
#define _PATATE_COMMON_SURFACE_MESH_OBJ_READER_
#include <stdexcept>
......
#ifndef _OBJWRITER_H_
#define _OBJWRITER_H_
#ifndef _PATATE_COMMON_SURFACE_MESH_OBJ_WRITER_
#define _PATATE_COMMON_SURFACE_MESH_OBJ_WRITER_
#include <stdexcept>
......
......@@ -17,8 +17,8 @@
//=============================================================================
#ifndef SURFACE_MESH_PROPERTIES_H
#define SURFACE_MESH_PROPERTIES_H
#ifndef _PATATE_COMMON_SURFACE_MESH_PROPERTIES_
#define _PATATE_COMMON_SURFACE_MESH_PROPERTIES_
//== INCLUDES =================================================================
......
......@@ -17,8 +17,8 @@
//=============================================================================
#ifndef SURFACE_MESH_H
#define SURFACE_MESH_H
#ifndef _PATATE_COMMON_SURFACE_MESH_SURFACE_MESH_
#define _PATATE_COMMON_SURFACE_MESH_SURFACE_MESH_
//== INCLUDES =================================================================
......
......@@ -6,6 +6,7 @@
#ifndef _PATATE_GRENAILLE_
#define _PATATE_GRENAILLE_
// First inclue Eigen Core
#include <Eigen/Core>
......
#!/usr/bin/python3
from sys import argv
from os.path import basename, dirname, splitext
from re import compile
from io import StringIO
guard_re = compile(r'#ifndef\s+(.*)')
guard_re2 = compile(r'#define\s+(.*)')
def extract_guard(filename):
f = open(filename)
it = iter(f)
for line in it:
m = guard_re.match(line)
if m:
nl = next(it)
m2 = guard_re2.match(nl)
if not m2 or m2.group(1) != m.group(1):
print('\033[32mError:\033[0m file "{}" has inconsistent include guard.'.format(filename))
return m.group(1)
return None
def print_all_caps_from_camel_case(toprint, out):
skip = True
for c in toprint:
if c.isupper() and not skip:
out.write('_')
skip = True
else:
skip = False
out.write(c.upper())
def guard_from_filename(filename):
guard = StringIO('')
guard.write('_')
d = dirname(filename)
if d == 'Patate':
guard.write('PATATE')
elif d.startswith('Patate/common/'):
print_all_caps_from_camel_case(d.replace('/', '_'), guard)
else:
print_all_caps_from_camel_case(basename(dirname(d)), guard)
guard.write('_')
name, ext = splitext(basename(filename))
print_all_caps_from_camel_case(name, guard)
guard.write('_')
return guard.getvalue()
current = extract_guard(argv[1])
theorical = guard_from_filename(argv[1])
if current == theorical:
print('\033[32m{}\033[0m: {}'.format(argv[1], current))
else:
print('\033[31m{}\033[0m: {} - {}'.format(argv[1], current, theorical))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment