YSTest: Dependency.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

Dependency.h
浏览该文件的文档.
1 /*
2 © 2015-2020 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef NPL_INC_Dependency_h_
29 #define NPL_INC_Dependency_h_
30
31 #include "YModules.h"
32 #include YFM_NPL_NPLA1 // for string, vector, REPLContext, ystdex::invoke,
33 // YSLib::unique_ptr;
34 #include <istream> // for std::istream;
35 #include <ystdex/scope_guard.hpp> // for ystdex::guard;
36
37 namespace NPL
38 {
39
41 enum class DepsEventType : yimpl(size_t)
42 {
43 General,
44 Search,
45 Build,
46 Command,
47 DepsCheck,
48 Max
49 };
50
51
53
54 YF_API vector<string>
56 DecomposeMakefileDepList(std::streambuf&);
58 YF_API vector<string>
59 DecomposeMakefileDepList(std::istream&);
61
67 YF_API bool
68 FilterMakefileDependencies(vector<string>&);
69
70
78
79
84 YF_API YB_NONNULL(1, 2) void
86 InstallFile(const char*, const char*);
87 inline PDefH(void, InstallFile, const string& dst, const string& src)
88 ImplExpr(InstallFile(dst.c_str(), src.c_str()))
90
92
93 YF_API void
95 InstallDirectory(const string&, const string&);
96 YB_NONNULL(1, 2) inline PDefH(void, InstallDirectory, const char* dst,
97 const char* src)
98 ImplExpr(InstallDirectory(string(dst), string(src)))
100
101
114 YF_API YB_NONNULL(1, 2) void
116 InstallHardLink(const char*, const char*);
117 inline PDefH(void, InstallHardLink, const string& dst, const string& src)
118 ImplExpr(InstallHardLink(dst.c_str(), src.c_str()))
120
122
123 YF_API YB_NONNULL(1, 2) void
125 InstallSymbolicLink(const char*, const char*);
126 inline PDefH(void, InstallSymbolicLink, const string& dst, const string& src)
127 ImplExpr(InstallSymbolicLink(dst.c_str(), src.c_str()))
129
130
135
137 YF_API YB_NONNULL(1, 2) void
138 InstallExecutable(const char*, const char*);
139 inline PDefH(void, InstallExecutable, const string& dst, const string& src)
140 ImplExpr(InstallExecutable(dst.c_str(), src.c_str()))
142
143
145 namespace A1
146 {
147
153 YB_ATTR_nodiscard YF_API YB_NONNULL(1) YSLib::unique_ptr<std::istream>
154 OpenFile(const char*);
155
157
158 YB_ATTR_nodiscard YF_API YSLib::unique_ptr<std::istream>
160 OpenUnique(REPLContext&, string);
161
162
169 YB_NONNULL(2) YF_API void
170 PreloadExternal(REPLContext&, const char*);
171
173
174
178 YF_API ReductionStatus
179 ReduceToLoadExternal(TermNode&, ContextNode&, REPLContext&);
180
185 YF_API ReductionStatus
186 RelayToLoadExternal(ContextNode&, TermNode&, REPLContext&);
188
189
190 namespace Forms
191 {
192
197 template<typename _fCallable>
198 void
199 InvokeIn(ContextNode& ctx, _fCallable&& f)
200 {
201 ystdex::guard<EnvironmentSwitcher> gd(ctx,
202 NPL::SwitchToFreshEnvironment(ctx, ValueObject(ctx.WeakenRecord())));
203
204 ystdex::invoke(f);
205 }
206
213 template<typename _fCallable>
214 shared_ptr<Environment>
215 GetModuleFor(ContextNode& ctx, _fCallable&& f)
216 {
217 ystdex::guard<EnvironmentSwitcher> gd(ctx,
218 NPL::SwitchToFreshEnvironment(ctx, ValueObject(ctx.WeakenRecord())));
219
220 ystdex::invoke(f);
221 ctx.GetRecordRef().Frozen = true;
222 return ctx.ShareRecord();
223 }
224
226
227
231 template<typename _fCallable>
232 inline void
233 LoadModule(ContextNode& ctx, string_view module_name, _fCallable&& f)
234 {
235 ctx.GetRecordRef().Define(module_name,
236 Forms::GetModuleFor(ctx, yforward(f)));
237 }
238
244 template<typename _fCallable>
245 inline void
246 LoadModuleChecked(ContextNode& ctx, string_view module_name, _fCallable&& f)
247 {
248 ctx.GetRecordRef().DefineChecked(module_name,
249 Forms::GetModuleFor(ctx, yforward(f)));
250 }
252
253
267 YF_API void
268 LoadGroundContext(REPLContext&);
269
284 YF_API void
285 LoadModule_std_environments(REPLContext&);
286
294 YF_API void
295 LoadModule_std_promises(REPLContext&);
296
302 YF_API void
303 LoadModule_std_strings(REPLContext&);
304
310 YF_API void
311 LoadModule_std_io(REPLContext&);
312
320 YF_API void
321 LoadModule_std_system(REPLContext&);
322
329 YF_API void
330 LoadModule_SHBuild(REPLContext&);
332
333
349 YF_API void
350 LoadStandardContext(REPLContext&);
351
352 } // namespace Forms;
353
354 } // namespace A1;
355
356 } // namespace NPL;
357
358 #endif
359
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
NPL::A1::OpenUnique
YSLib::unique_ptr< std::istream > OpenUnique(REPLContext &context, string filename)
Definition: Dependency.cpp:231
ystdex::invoke
invoke_result_t< _fCallable, _tParams... > invoke(_fCallable &&f, _tParams &&... args)
调用可调用对象。
Definition: invoke.hpp:538
NPL::A1::OpenFile
YSLib::unique_ptr< std::istream > OpenFile(const char *filename)
Definition: Dependency.cpp:224
NPL::DepsEventType::General
@ General
NPL::A1::Forms::LoadModule_SHBuild
void LoadModule_SHBuild(REPLContext &context)
Definition: Dependency.cpp:1232
NPL::DepsEventType::Command
@ Command
NPL::string_view
YB_ATTR_nodiscard ctx string_view
Definition: NPLA.h:3020
NPL::DepsEventType
DepsEventType
Definition: Dependency.h:42
NPL::InstallDirectory
YF_API const char src const string InstallDirectory
Definition: Dependency.h:96
NPL::DepsEventType::DepsCheck
@ DepsCheck
NPL::InstallExecutable
src void InstallExecutable(const char *, const char *)
Definition: Dependency.cpp:215
YF_API
#define YF_API
Definition: Platform.h:56
NPL::InstallHardLink
YF_API const char src const string const char const char *src void InstallHardLink(const char *, const char *)
Definition: Dependency.cpp:192
NPL::DepsEventType::Max
@ Max
CHRLib::f
f(d, s)
NPL::DepsEventType::Search
@ Search
NPL::FilterMakefileDependencies
YF_API bool FilterMakefileDependencies(vector< string > &)
过滤 GCC 兼容编译器 -MMD 选项生成的 Makefile 项列表并选取依赖项。
Definition: Dependency.cpp:153
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
NPL::ImplExpr
YF_API const char src const string const char const char *src ImplExpr(InstallDirectory(string(dst), string(src))) YF_API YB_NONNULL(1
安装硬链接：创建硬链接，失败则安装文件。
YSLib::ValueObject
值类型对象类。
Definition: YObject.h:1068
YSLib::Drawing::src
src
Definition: YGDI.h:442
NPL::DecomposeMakefileDepList
YF_API vector< string > DecomposeMakefileDepList(std::streambuf &)
从内容为 GCC 兼容编译器 -MMD 选项生成的 Makefile 的流中分解路径。
Definition: Dependency.cpp:71
scope_guard.hpp
作用域守卫。
NPL::ContextNode::WeakenRecord
const ynothrow ynothrow WeakenRecord
Definition: NPLA.h:2873
NPL::A1::Forms::LoadModule_std_strings
void LoadModule_std_strings(REPLContext &context)
Definition: Dependency.cpp:1075
NPL::PDefH
PDefH(void, LiftTermRef, TermNode &term, const TermNode &tm) ImplExpr(NPL PDefH(void, LiftMoved, TermNode &term, const TermReference &ref, bool move) ImplExpr(LiftTermOrCopy(term
提升项引用：使用第二参数指定的项的内容引用替换第一个项的内容。
Definition: NPLA.h:1735
NPL
Definition: NPL/Configuration.h:35
NPL::YB_NONNULL
YF_API YB_NONNULL(1, 2) void InstallFile(const char *
安装文件：复制单个文件。
NPL::InstallSymbolicLink
src void InstallSymbolicLink(const char *, const char *)
Definition: Dependency.cpp:205
NPL::A1::ReduceToLoadExternal
ReductionStatus ReduceToLoadExternal(TermNode &term, ContextNode &ctx, REPLContext &context)
Definition: Dependency.cpp:249
YModules.h
YSLib 用户界面模块配置文件。
NPL::A1::Forms::LoadStandardContext
void LoadStandardContext(REPLContext &context)
Definition: Dependency.cpp:1387
NPL::ContextNode
上下文节点。
Definition: NPLA.h:2385
NPL::A1::Forms::LoadModule_std_environments
void LoadModule_std_environments(REPLContext &context)
Definition: Dependency.cpp:1017
NPL::A1::Forms::LoadModule_std_system
void LoadModule_std_system(REPLContext &context)
Definition: Dependency.cpp:1179
NPL::A1::RelayToLoadExternal
ReductionStatus RelayToLoadExternal(ContextNode &ctx, TermNode &term, REPLContext &context)
Definition: Dependency.cpp:258
NPL::ContextNode::ShareRecord
ShareRecord
Definition: NPLA.h:2861
NPL::c_str
YF_API const char src c_str())) YF_API void InstallDirectory(const string &
安装目录：复制目录树。
Definition: Dependency.h:140
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
NPL::DepsEventType::Build
@ Build
NPL::A1::Forms::LoadModule_std_io
void LoadModule_std_io(REPLContext &context)
Definition: Dependency.cpp:1146
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:96
NPL::A1::PreloadExternal
void PreloadExternal(REPLContext &context, const char *filename)
Definition: Dependency.cpp:242
NPL::InstallFile
void InstallFile(const char *dst, const char *src)
Definition: Dependency.cpp:166
NPL::A1::Forms::LoadGroundContext
void LoadGroundContext(REPLContext &context)
Definition: Dependency.cpp:1009
NPL::yimpl
yimpl(using) Reducer
规约器：和绑定上下文以外参数的求值遍的处理器具有等价签名的多态函数。
NPL::ContextNode::GetRecordRef
!current Environment::BindingMap GetRecordRef().GetMapRef()) DefGetter(const ynothrow
NPL::ReductionStatus
ReductionStatus
规约状态：某个项上的一遍规约可能的中间结果。
Definition: NPLA.h:1520
NPL::A1::Forms::LoadModule_std_promises
void LoadModule_std_promises(REPLContext &context)
Definition: Dependency.cpp:1043
ystdex::guard
作用域守卫：析构时调用保存的函数对象或引用。
Definition: scope_guard.hpp:48