Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uuid header #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/allocator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_ALLOCATOR_H
#define KMC_C90_COMPILER_ALLOCATOR_H
#ifndef INCLUDE_GUARD_UUID_369AE7CB_59C4_44F9_827B_3680E4BE4CE3
#define INCLUDE_GUARD_UUID_369AE7CB_59C4_44F9_827B_3680E4BE4CE3

#include "utility.h"

Expand All @@ -10,4 +10,4 @@ void* allocate_container(AllocatorRef allocator);
void* allocate_element(AllocatorRef allocator, size_t count);
void deallocate(AllocatorRef allocator, void* ptr);

#endif /* KMC_C90_COMPILER_ALLOCATOR_H */
#endif /* INCLUDE_GUARD_UUID_369AE7CB_59C4_44F9_827B_3680E4BE4CE3 */
6 changes: 3 additions & 3 deletions src/allocator_impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_ALLOCATOR_IMPL_H
#define KMC_C90_COMPILER_ALLOCATOR_IMPL_H
#ifndef INCLUDE_GUARD_UUID_733C42B7_9635_4796_A825_357B2A199BA7
#define INCLUDE_GUARD_UUID_733C42B7_9635_4796_A825_357B2A199BA7

#include "utility.h"

Expand All @@ -10,4 +10,4 @@ struct Allocator {
void (*deallocator_)(void* ptr, void* manager);
};

#endif /* KMC_C90_COMPILER_ALLOCATOR_IMPL_H */
#endif /* INCLUDE_GUARD_UUID_733C42B7_9635_4796_A825_357B2A199BA7 */
6 changes: 3 additions & 3 deletions src/ast.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef KMC_C90_COMPILER_AST_H
#define KMC_C90_COMPILER_AST_H
#ifndef INCLUDE_GUARD_UUID_1634E4AC_1406_46C3_9240_865975749754
#define INCLUDE_GUARD_UUID_1634E4AC_1406_46C3_9240_865975749754

enum AstTag {
AST_IDENTIFIER
};

#endif /* KMC_C90_COMPILER_AST_H */
#endif /* INCLUDE_GUARD_UUID_1634E4AC_1406_46C3_9240_865975749754 */
6 changes: 3 additions & 3 deletions src/memory_pool.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_MEMORY_POOL_H
#define KMC_C90_COMPILER_MEMORY_POOL_H
#ifndef INCLUDE_GUARD_UUID_CE8F872C_1C85_4BD9_BA55_DCCB9DFCA5FD
#define INCLUDE_GUARD_UUID_CE8F872C_1C85_4BD9_BA55_DCCB9DFCA5FD

#include "utility.h"

Expand All @@ -16,4 +16,4 @@ void memory_pool_dtor(MemoryPoolRef* ppool);
/* allocate 'size' memory from pool */
void* palloc_impl(MemoryPoolRef pool, size_t size, size_t alignment);

#endif /* KMC_C90_COMPILER_MEMORY_POOL_H */
#endif /* INCLUDE_GUARD_UUID_CE8F872C_1C85_4BD9_BA55_DCCB9DFCA5FD */
6 changes: 3 additions & 3 deletions src/sexpr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_SEXPR_H
#define KMC_C90_COMPILER_SEXPR_H
#ifndef INCLUDE_GUARD_UUID_DC32CCE0_A68D_4F17_8621_17C2E13F96F3
#define INCLUDE_GUARD_UUID_DC32CCE0_A68D_4F17_8621_17C2E13F96F3

#include "ast.h"
#include "stdstring.h"
Expand Down Expand Up @@ -43,4 +43,4 @@ StringRef sexpr_get_symbol(SexprRef sexpr);
SexprRef sexpr_make_ast(enum AstTag ast);
enum AstTag sexpr_get_ast(SexprRef sexpr);

#endif /* KMC_C90_COMPILER_SEXPR_H */
#endif /* INCLUDE_GUARD_UUID_DC32CCE0_A68D_4F17_8621_17C2E13F96F3 */
6 changes: 3 additions & 3 deletions src/sexpr_pool.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_SEXPR_POOL_H
#define KMC_C90_COMPILER_SEXPR_POOL_H
#ifndef INCLUDE_GUARD_UUID_DD55EAEA_2431_4469_A0F8_24CDD9BF0180
#define INCLUDE_GUARD_UUID_DD55EAEA_2431_4469_A0F8_24CDD9BF0180

#include "allocator.h"
#include "memory_pool.h"
Expand All @@ -10,4 +10,4 @@ void sexpr_finalize_pool(void);

AllocatorRef sexpr_symbol_allocator(void);

#endif /* KMC_C90_COMPILER_SEXPR_POOL_H */
#endif /* INCLUDE_GUARD_UUID_DD55EAEA_2431_4469_A0F8_24CDD9BF0180 */
6 changes: 3 additions & 3 deletions src/stdstring.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_STDSTRING_H
#define KMC_C90_COMPILER_STDSTRING_H
#ifndef INCLUDE_GUARD_UUID_AC04F0D5_11C0_431B_A82E_4E56DA9456AF
#define INCLUDE_GUARD_UUID_AC04F0D5_11C0_431B_A82E_4E56DA9456AF

#include "allocator.h"
#include "utility.h"
Expand Down Expand Up @@ -114,4 +114,4 @@ size_t string_find_first_of(StringRef self, const char* str);
/* behavior is undefined if str is NULL */
size_t string_find_first_not_of(StringRef self, const char* str);

#endif /* KMC_C90_COMPILER_STDSTRING_H */
#endif /* INCLUDE_GUARD_UUID_AC04F0D5_11C0_431B_A82E_4E56DA9456AF */
6 changes: 3 additions & 3 deletions src/stdstring_impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_STDSTRING_IMPL_H
#define KMC_C90_COMPILER_STDSTRING_IMPL_H
#ifndef INCLUDE_GUARD_UUID_5C5CF2B9_E7DB_49BB_94B3_F1C9EEE856D8
#define INCLUDE_GUARD_UUID_5C5CF2B9_E7DB_49BB_94B3_F1C9EEE856D8

#include "allocator.h"
#include "stdstring.h"
Expand All @@ -11,4 +11,4 @@ struct String {
AllocatorRef allocator_;
};

#endif /* KMC_C90_COMPILER_STDSTRING_IMPL_H */
#endif /* INCLUDE_GUARD_UUID_5C5CF2B9_E7DB_49BB_94B3_F1C9EEE856D8 */
6 changes: 3 additions & 3 deletions src/use_vector.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef KMC_C90_COMPILER_USE_VECTOR_H
#define KMC_C90_COMPILER_USE_VECTOR_H
#ifndef INCLUDE_GUARD_UUID_C9D4FBB0_D15A_468E_8F63_191FED23FD6B
#define INCLUDE_GUARD_UUID_C9D4FBB0_D15A_468E_8F63_191FED23FD6B

#include "vector.h"

#endif /* KMC_C90_COMPILER_USE_VECTOR_H */
#endif /* INCLUDE_GUARD_UUID_C9D4FBB0_D15A_468E_8F63_191FED23FD6B */
6 changes: 3 additions & 3 deletions src/utility.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_UTILITY_H
#define KMC_C90_COMPILER_UTILITY_H
#ifndef INCLUDE_GUARD_UUID_F5C18B91_A046_4615_A62F_B79EE7AED603
#define INCLUDE_GUARD_UUID_F5C18B91_A046_4615_A62F_B79EE7AED603

#include <stddef.h>

Expand Down Expand Up @@ -59,4 +59,4 @@ void memory_move(void* dst, const void* src, size_t size, size_t count);

END_EXTERN_C

#endif /* KMC_C90_COMPILER_UTILITY_H */
#endif /* INCLUDE_GUARD_UUID_F5C18B91_A046_4615_A62F_B79EE7AED603 */
6 changes: 3 additions & 3 deletions src/vector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_VECTOR_H
#define KMC_C90_COMPILER_VECTOR_H
#ifndef INCLUDE_GUARD_UUID_7DB59410_A810_40B5_BB5F_19CB9E822A40
#define INCLUDE_GUARD_UUID_7DB59410_A810_40B5_BB5F_19CB9E822A40

#include "utility.h"
#include "allocator.h"
Expand Down Expand Up @@ -83,4 +83,4 @@

#include "vector_impl.h"

#endif /* KMC_C90_COMPILER_VECTOR_H */
#endif /* INCLUDE_GUARD_UUID_7DB59410_A810_40B5_BB5F_19CB9E822A40 */
6 changes: 3 additions & 3 deletions src/vector_impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_VECTOR_IMPL_H
#define KMC_C90_COMPILER_VECTOR_IMPL_H
#ifndef INCLUDE_GUARD_UUID_E601D647_8BA3_4262_B950_FE4DD1C72D12
#define INCLUDE_GUARD_UUID_E601D647_8BA3_4262_B950_FE4DD1C72D12
#include "allocator_impl.h"
#include <assert.h>

Expand Down Expand Up @@ -252,4 +252,4 @@
} \
} \

#endif /* KMC_C90_COMPILER_VECTOR_IMPL_H */
#endif /* INCLUDE_GUARD_UUID_E601D647_8BA3_4262_B950_FE4DD1C72D12 */
6 changes: 3 additions & 3 deletions tests/vector_test/use_vector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KMC_C90_COMPILER_USE_VECTOR_H
#define KMC_C90_COMPILER_USE_VECTOR_H
#ifndef INCLUDE_GUARD_UUID_9515325F_50B2_4EC8_95E3_8B38BFCD1FDE
#define INCLUDE_GUARD_UUID_9515325F_50B2_4EC8_95E3_8B38BFCD1FDE

#include "utility.h"
#include "vector.h"
Expand All @@ -8,4 +8,4 @@ BEGIN_EXTERN_C
DECLARE_VECTOR(int)
END_EXTERN_C

#endif /* KMC_C90_COMPILER_USE_VECTOR_H */
#endif /* INCLUDE_GUARD_UUID_9515325F_50B2_4EC8_95E3_8B38BFCD1FDE */
22 changes: 22 additions & 0 deletions uuid-header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

which uuidgen >/dev/null 2>&1 && {
uuidcmd='uuidgen -r'
} || {
uuidcmd='uuid -v4'
}

for filename in "$@"
do
uuid=$(${uuidcmd} | tr '[a-f-]' '[A-F_]')
macro="INCLUDE_GUARD_UUID_${uuid}"
ifndef="#ifndef ${macro}"
define="#define ${macro}"
endif="#endif /* ${macro} */"
cat <<EOF >"${filename}"
${ifndef}
${define}

${endif}
EOF
done