jak-project/common/goos/ParseHelpers.h
water111 09142d1712
Support "game count" and v4 objects (#140)
* generate object, but not supported in linker yet

* add link and tests

* update types
2020-11-24 20:48:38 -05:00

30 lines
782 B
C++

#pragma once
#include <optional>
#include <string>
#include <vector>
#include <unordered_map>
#include "Object.h"
namespace goos {
bool get_va(const goos::Object& rest, std::string* err_string, goos::Arguments* result);
bool va_check(
const goos::Arguments& args,
const std::vector<std::optional<goos::ObjectType>>& unnamed,
const std::unordered_map<std::string, std::pair<bool, std::optional<goos::ObjectType>>>& named,
std::string* err_string);
template <typename T>
void for_each_in_list(const goos::Object& list, T f) {
const goos::Object* iter = &list;
while (iter->is_pair()) {
auto lap = iter->as_pair();
f(lap->car);
iter = &lap->cdr;
}
assert(iter->is_empty_list());
}
int list_length(const goos::Object& list);
} // namespace goos