Skip to content

Commit

Permalink
Associated consts are stable now, apparently
Browse files Browse the repository at this point in the history
We still can't use associated consts for Readable::fixed_size because
we need to be able to propigate optional-ness for parameterized types
and the kinds of expressions allowed in constant contexts isn't
expressive enough.
  • Loading branch information
aprilwade committed Oct 15, 2018
1 parent 4716882 commit 160a38a
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 78 deletions.
12 changes: 6 additions & 6 deletions structs/src/scly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ macro_rules! build_scly_property {
match *self {
SclyProperty::Unknown { object_type, .. } => object_type,
$(SclyProperty::$name(_) =>
<scly_props::$name as SclyPropertyData>::object_type(),)*
<scly_props::$name as SclyPropertyData>::OBJECT_TYPE,)*
}
}

Expand All @@ -110,7 +110,7 @@ macro_rules! build_scly_property {
};
*self = if false {
return
} $(else if object_type == <scly_props::$name as SclyPropertyData>::object_type() {
} $(else if object_type == <scly_props::$name as SclyPropertyData>::OBJECT_TYPE {
SclyProperty::$name(reader.read(()))
})* else {
return
Expand All @@ -123,7 +123,7 @@ macro_rules! build_scly_property {
match *self {
SclyProperty::$name(_) => true,
SclyProperty::Unknown { object_type, .. } =>
object_type == <scly_props::$name as SclyPropertyData>::object_type(),
object_type == <scly_props::$name as SclyPropertyData>::OBJECT_TYPE,
_ => false,
}
}
Expand All @@ -133,7 +133,7 @@ macro_rules! build_scly_property {
match *self {
SclyProperty::$name(ref inst) => Some(Cow::Borrowed(inst)),
SclyProperty::Unknown { ref data, object_type, .. } => {
if object_type == <scly_props::$name as SclyPropertyData>::object_type() {
if object_type == <scly_props::$name as SclyPropertyData>::OBJECT_TYPE {
Some(Cow::Owned(data.clone().read(())))
} else {
None
Expand All @@ -151,7 +151,7 @@ macro_rules! build_scly_property {
SclyProperty::$name(ref mut inst) => return Some(inst),
_ => return None,
};
if object_type != <scly_props::$name as SclyPropertyData>::object_type() {
if object_type != <scly_props::$name as SclyPropertyData>::OBJECT_TYPE {
return None
}
*self = SclyProperty::$name(data.read(()));
Expand Down Expand Up @@ -221,7 +221,7 @@ build_scly_property!(

pub trait SclyPropertyData
{
fn object_type() -> u8;
const OBJECT_TYPE: u8;
}


Expand Down
5 changes: 1 addition & 4 deletions structs/src/scly_props/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Actor<'a>
{
fn object_type() -> u8
{
0x0
}
const OBJECT_TYPE: u8 = 0x0;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/dock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Dock<'a>
{
fn object_type() -> u8
{
0x0B
}
const OBJECT_TYPE: u8 = 0x0B;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Effect<'a>
{
fn object_type() -> u8
{
0x7
}
const OBJECT_TYPE: u8 = 0x7;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/hud_memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@ auto_struct! {

impl<'a> SclyPropertyData for HudMemo<'a>
{
fn object_type() -> u8
{
0x17
}
const OBJECT_TYPE: u8 = 0x17;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/memory_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,5 @@ auto_struct! {

impl<'a> SclyPropertyData for MemoryRelay<'a>
{
fn object_type() -> u8
{
0x13
}
const OBJECT_TYPE: u8 = 0x13;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/pickup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Pickup<'a>
{
fn object_type() -> u8
{
0x11
}
const OBJECT_TYPE: u8 = 0x11;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/platorm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Platform<'a>
{
fn object_type() -> u8
{
0x8
}
const OBJECT_TYPE: u8 = 0x8;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/player_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,5 @@ auto_struct! {

impl<'a> SclyPropertyData for PlayerActor<'a>
{
fn object_type() -> u8
{
0x4c
}
const OBJECT_TYPE: u8 = 0x4c;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/player_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@ auto_struct! {

impl<'a> SclyPropertyData for PlayerHint<'a>
{
fn object_type() -> u8
{
0x3E
}
const OBJECT_TYPE: u8 = 0x3E;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/point_of_interest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ auto_struct! {

impl<'a> SclyPropertyData for PointOfInterest<'a>
{
fn object_type() -> u8
{
0x42
}
const OBJECT_TYPE: u8 = 0x42;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Relay<'a>
{
fn object_type() -> u8
{
0x15
}
const OBJECT_TYPE: u8 = 0x15;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Sound<'a>
{
fn object_type() -> u8
{
0x9
}
const OBJECT_TYPE: u8 = 0x9;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/spawn_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,5 @@ auto_struct! {

impl<'a> SclyPropertyData for SpawnPoint<'a>
{
fn object_type() -> u8
{
0x0F
}
const OBJECT_TYPE: u8 = 0x0F;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/special_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@ auto_struct! {

impl<'a> SclyPropertyData for SpecialFunction<'a>
{
fn object_type() -> u8
{
0x3A
}
const OBJECT_TYPE: u8 = 0x3A;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/streamed_audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ auto_struct! {

impl<'a> SclyPropertyData for StreamedAudio<'a>
{
fn object_type() -> u8
{
0x61
}
const OBJECT_TYPE: u8 = 0x61;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Timer<'a>
{
fn object_type() -> u8
{
0x5
}
const OBJECT_TYPE: u8 = 0x5;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@ auto_struct! {

impl<'a> SclyPropertyData for Trigger<'a>
{
fn object_type() -> u8
{
0x04
}
const OBJECT_TYPE: u8 = 0x04;
}
5 changes: 1 addition & 4 deletions structs/src/scly_props/world_transporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@ auto_struct! {

impl<'a> SclyPropertyData for WorldTransporter<'a>
{
fn object_type() -> u8
{
0x062
}
const OBJECT_TYPE: u8 = 0x062;
}

0 comments on commit 160a38a

Please sign in to comment.