mycpp-examples

Coverage Report

Created: 2022-07-15 02:23

/home/uke/oil/mycpp/common.h
Line
Count
Source (jump to first uncovered line)
1
// common.h
2
//
3
// A grab bag of definitions needed in multiple places.
4
5
#ifndef COMMON_H
6
#define COMMON_H
7
8
#include <cstdarg>  // va_list, etc.
9
#include <cstdio>   // vprintf
10
11
// TODO(Jesse): Put NotImplemented on a compile-time switch such that we cannot
12
// make a release build if we're not finished implementing the interpreter.
13
// ie.
14
//
15
// #if OIL_INTERNAL
16
//   #define NotImplemented() assert(!"Not Implemented")
17
// #else
18
//   #define NotImplemented() NOT IMPLENTED !!! // Intentionally a compile error
19
// #endif
20
//
21
//
22
0
#define NotImplemented() assert(!"Not Implemented")
23
0
#define InvalidCodePath() assert(!"Invalid Code Path")
24
25
// Prevent silent copies
26
27
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
28
  TypeName(TypeName&) = delete;            \
29
  void operator=(TypeName) = delete;
30
31
// log() is for hand-written code, not generated
32
33
0
inline void log(const char* fmt, ...) {
34
0
  va_list args;
35
0
  va_start(args, fmt);
36
0
  vprintf(fmt, args);
37
0
  va_end(args);
38
0
  puts("");
39
0
}
40
41
namespace common {}  // namespace common
42
43
#endif  // COMMON_H