cpp

Coverage Report

Created: 2022-11-10 11:34

/home/andy/git/oilshell/oil/cpp/leaky_core.h
Line
Count
Source (jump to first uncovered line)
1
// leaky_core.h: Replacement for core/*.py
2
3
#ifndef LEAKY_CORE_H
4
#define LEAKY_CORE_H
5
6
#include <signal.h>  // sighandler_t
7
#include <termios.h>
8
9
#include "_gen/frontend/syntax.asdl.h"
10
#include "mycpp/runtime.h"
11
12
// Hacky forward declaration
13
namespace comp_ui {
14
class _IDisplay;
15
};
16
17
namespace pyos {
18
19
const int TERM_ICANON = ICANON;
20
const int TERM_ECHO = ECHO;
21
const int EOF_SENTINEL = 256;
22
const int NEWLINE_CH = 10;
23
const int UNTRAPPED_SIGWINCH = -1;
24
const int kMaxSignalsInFlight = 1024;
25
26
Tuple2<int, int> WaitPid();
27
Tuple2<int, int> Read(int fd, int n, List<Str*>* chunks);
28
Tuple2<int, int> ReadByte(int fd);
29
Str* ReadLine();
30
Dict<Str*, Str*>* Environ();
31
int Chdir(Str* dest_dir);
32
Str* GetMyHomeDir();
33
Str* GetHomeDir(Str* user_name);
34
35
class ReadError {
36
 public:
37
0
  explicit ReadError(int err_num_) : err_num(err_num_) {
38
0
  }
39
  int err_num;
40
};
41
42
Str* GetUserName(int uid);
43
Str* OsType();
44
Tuple3<double, double, double> Time();
45
void PrintTimes();
46
bool InputAvailable(int fd);
47
48
class TermState {
49
 public:
50
0
  TermState(int fd, int mask) {
51
0
    assert(0);
52
0
  }
53
0
  void Restore() {
54
0
    assert(0);
55
0
  }
56
};
57
58
class SignalHandler {
59
 public:
60
  SignalHandler();
61
  void Update(int sig_num);
62
  List<int>* TakeSignalQueue();
63
64
  List<int>* signal_queue_;
65
  int last_sig_num_;
66
  int sigwinch_num_;
67
};
68
69
void Sigaction(int sig_num, sighandler_t handler);
70
71
void RegisterSignalInterest(int sig_num);
72
73
List<int>* TakeSignalQueue();
74
75
int LastSignal();
76
77
void SetSigwinchCode(int code);
78
79
void InitShell();
80
81
}  // namespace pyos
82
83
namespace pyutil {
84
85
bool IsValidCharEscape(int c);
86
Str* ChArrayToString(List<int>* ch_array);
87
88
class _ResourceLoader {
89
 public:
90
  virtual Str* Get(Str* path);
91
};
92
93
_ResourceLoader* GetResourceLoader();
94
95
void CopyFile(Str* in_path, Str* out_path);
96
97
Str* GetVersion(_ResourceLoader* loader);
98
99
Str* ShowAppVersion(Str* app_name, _ResourceLoader* loader);
100
101
Str* strerror(IOError_OSError* e);
102
103
Str* BackslashEscape(Str* s, Str* meta_chars);
104
105
}  // namespace pyutil
106
107
#endif  // LEAKY_CORE_H