summaryrefslogtreecommitdiffstats
path: root/edify/expr.h
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-10-11 07:52:18 +0200
committerTao Bao <tbao@google.com>2016-10-13 08:29:59 +0200
commit39119ad8ecd00a9c19fb173c78cb4a8d22a4540a (patch)
treeb7c6d625baefc3521fe46c794d8d82fe99535229 /edify/expr.h
parentMerge "updater: Kill the duplicate PrintSha1() in install.cpp." (diff)
downloadandroid_bootable_recovery-39119ad8ecd00a9c19fb173c78cb4a8d22a4540a.tar
android_bootable_recovery-39119ad8ecd00a9c19fb173c78cb4a8d22a4540a.tar.gz
android_bootable_recovery-39119ad8ecd00a9c19fb173c78cb4a8d22a4540a.tar.bz2
android_bootable_recovery-39119ad8ecd00a9c19fb173c78cb4a8d22a4540a.tar.lz
android_bootable_recovery-39119ad8ecd00a9c19fb173c78cb4a8d22a4540a.tar.xz
android_bootable_recovery-39119ad8ecd00a9c19fb173c78cb4a8d22a4540a.tar.zst
android_bootable_recovery-39119ad8ecd00a9c19fb173c78cb4a8d22a4540a.zip
Diffstat (limited to 'edify/expr.h')
-rw-r--r--edify/expr.h40
1 files changed, 7 insertions, 33 deletions
diff --git a/edify/expr.h b/edify/expr.h
index f045d9386..cd6139a18 100644
--- a/edify/expr.h
+++ b/edify/expr.h
@@ -21,11 +21,6 @@
#include <string>
#include "error_code.h"
-#include "yydefs.h"
-
-#define MAX_STRING_LEN 1024
-
-typedef struct Expr Expr;
struct State {
State(const std::string& script, void* cookie);
@@ -56,14 +51,15 @@ struct State {
#define VAL_STRING 1 // data will be NULL-terminated; size doesn't count null
#define VAL_BLOB 2
-typedef struct {
+struct Value {
int type;
ssize_t size;
char* data;
-} Value;
+};
-typedef Value* (*Function)(const char* name, State* state,
- int argc, Expr* argv[]);
+struct Expr;
+
+using Function = Value* (*)(const char* name, State* state, int argc, Expr* argv[]);
struct Expr {
Function fn;
@@ -100,43 +96,21 @@ Value* EqualityFn(const char* name, State* state, int argc, Expr* argv[]);
Value* InequalityFn(const char* name, State* state, int argc, Expr* argv[]);
Value* SequenceFn(const char* name, State* state, int argc, Expr* argv[]);
-// Convenience function for building expressions with a fixed number
-// of arguments.
-Expr* Build(Function fn, YYLTYPE loc, int count, ...);
-
// Global builtins, registered by RegisterBuiltins().
Value* IfElseFn(const char* name, State* state, int argc, Expr* argv[]);
Value* AssertFn(const char* name, State* state, int argc, Expr* argv[]);
Value* AbortFn(const char* name, State* state, int argc, Expr* argv[]);
-
-// For setting and getting the global error string (when returning
-// NULL from a function).
-void SetError(const char* message); // makes a copy
-const char* GetError(); // retains ownership
-void ClearError();
-
-
-typedef struct {
- const char* name;
- Function fn;
-} NamedFunction;
-
// Register a new function. The same Function may be registered under
// multiple names, but a given name should only be used once.
-void RegisterFunction(const char* name, Function fn);
+void RegisterFunction(const std::string& name, Function fn);
// Register all the builtins.
void RegisterBuiltins();
-// Call this after all calls to RegisterFunction() but before parsing
-// any scripts to finish building the function table.
-void FinishRegistration();
-
// Find the Function for a given name; return NULL if no such function
// exists.
-Function FindFunction(const char* name);
-
+Function FindFunction(const std::string& name);
// --- convenience functions for use in functions ---