Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Commit 7cbad1e

Browse files
committed
ioreg: Initial commit
1 parent 1bcc62d commit 7cbad1e

File tree

5 files changed

+491
-0
lines changed

5 files changed

+491
-0
lines changed

ioreg/builder.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Zinc, the bare metal stack for rust.
2+
// Copyright 2014 Ben Gamari <[email protected]>
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
use std::gc::{Gc, GC};
17+
use syntax::abi;
18+
use syntax::ast::TokenTree;
19+
use syntax::ast;
20+
use syntax::ast_util::empty_generics;
21+
use syntax::codemap::{Span, DUMMY_SP};
22+
use syntax::ext::base::ExtCtxt;
23+
use syntax::ext::build::AstBuilder;
24+
use syntax::ext::quote::rt::{ToTokens, ExtParseUtils};
25+
use syntax::parse::token::InternedString;
26+
27+
use node;
28+
29+
pub struct Builder;
30+
31+
impl Builder {
32+
pub fn emit_items(&self, cx: &mut ExtCtxt) -> Vec<Gc<ast::Item>> {
33+
Vec::new()
34+
}
35+
}
36+
37+
pub fn build_ioreg(cx: &mut ExtCtxt, ioreg: &Gc<node::IoReg>) -> Builder {
38+
Builder
39+
}

ioreg/ioreg.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Zinc, the bare metal stack for rust.
2+
// Copyright 2014 Ben Gamari <[email protected]>
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
//! ioreg crate
17+
18+
#![feature(quote)]
19+
#![crate_id="ioreg"]
20+
#![crate_type="rlib"]
21+
22+
extern crate syntax;
23+
24+
pub mod node;
25+
pub mod parser;
26+
pub mod builder;

ioreg/node.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Zinc, the bare metal stack for rust.
2+
// Copyright 2014 Ben Gamari <[email protected]>
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
use syntax::codemap::Span;
17+
18+
pub struct EnumValue {
19+
pub name: String,
20+
pub name_span: Span,
21+
pub value: uint,
22+
pub value_span: Span,
23+
}
24+
25+
pub enum FieldType {
26+
PrimitiveType(String),
27+
/// An enum
28+
EnumType(Vec<EnumValue>),
29+
/// A structured type larger than a machine word
30+
NestedType(String),
31+
/// A struct
32+
StructType(Vec<FieldOrPadding>),
33+
}
34+
35+
pub struct Field {
36+
pub name: String,
37+
pub name_span: Span,
38+
39+
pub read_only: bool,
40+
pub ty: FieldType,
41+
42+
pub width: uint,
43+
pub width_span: Span,
44+
45+
pub count: uint,
46+
pub count_span: Span,
47+
}
48+
49+
pub enum FieldOrPadding {
50+
Field(Field),
51+
Padding(uint),
52+
}
53+
54+
pub struct IoReg {
55+
pub name: String,
56+
pub name_span: Span,
57+
pub fields: Vec<FieldOrPadding>,
58+
}

0 commit comments

Comments
 (0)