-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema-parser.cpp
More file actions
36 lines (29 loc) · 1 KB
/
schema-parser.cpp
File metadata and controls
36 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <kj/exception.h>
#include "schema-parser.h"
#include "parsed-schema.h"
namespace capnp_php {
SchemaParser::SchemaParser()
: Php::Base(),
parser(new capnp::SchemaParser())
{
}
SchemaParser::~SchemaParser() {
delete parser;
}
Php::Value SchemaParser::parseDiskFile(Php::Parameters ¶ms) {
std::string display_name = params[0];
std::string disk_path = params[1];
kj::ArrayPtr<::kj::StringPtr> importpaths;
if(params.size() > 2) {
Php::Array paths = params[2];
}
try {
auto schema = parser->parseDiskFile(display_name, disk_path, importpaths);
return Php::Object("\\CAPNP\\ParsedSchema",
new ParsedSchema(schema, this));
} catch(const kj::Exception& ex) {
throw Php::Exception(ex.getDescription());
}
return Php::Value();
}
}