Skip to content

Commit

Permalink
feat: update idl
Browse files Browse the repository at this point in the history
  • Loading branch information
technobaboo committed Mar 10, 2024
1 parent 4d7479a commit adbfd6e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 117 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ pub fn codegen_drawable_protocol(_input: proc_macro::TokenStream) -> proc_macro:
pub fn codegen_input_protocol(_input: proc_macro::TokenStream) -> proc_macro::TokenStream {
codegen_protocol(INPUT_PROTOCOL)
}
#[proc_macro]
pub fn codegen_items_protocol(_input: proc_macro::TokenStream) -> proc_macro::TokenStream {
codegen_protocol(ITEM_PROTOCOL)
}

fn codegen_protocol(protocol: &'static str) -> proc_macro::TokenStream {
let protocol = Protocol::parse(protocol).unwrap();
Expand Down Expand Up @@ -462,12 +466,13 @@ fn generate_argument_decl(argument: &Argument, owned_values: bool) -> TokenStrea
}
fn argument_type_option_name(argument_type: &ArgumentType) -> String {
match argument_type {
ArgumentType::Empty => "Empty".to_string(),
ArgumentType::Bool => "Bool".to_string(),
ArgumentType::Int => "Int".to_string(),
ArgumentType::UInt => "UInt".to_string(),
ArgumentType::Float => "Float".to_string(),
ArgumentType::Vec2 => "Vec2".to_string(),
ArgumentType::Vec3 => "Vec3".to_string(),
ArgumentType::Vec2(_) => "Vec2".to_string(),
ArgumentType::Vec3(_) => "Vec3".to_string(),
ArgumentType::Quat => "Quat".to_string(),
ArgumentType::Color => "Color".to_string(),
ArgumentType::String => "String".to_string(),
Expand All @@ -488,12 +493,19 @@ fn generate_argument_type(
owned: bool,
) -> TokenStream {
let _type = match argument_type {
ArgumentType::Empty => quote!(()),
ArgumentType::Bool => quote!(bool),
ArgumentType::Int => quote!(i32),
ArgumentType::UInt => quote!(u32),
ArgumentType::Float => quote!(f32),
ArgumentType::Vec2 => quote!(mint::Vector2<f32>),
ArgumentType::Vec3 => quote!(mint::Vector3<f32>),
ArgumentType::Vec2(c) => {
let component = generate_argument_type(c, false, true);
quote!(mint::Vector2<#component>)
}
ArgumentType::Vec3(c) => {
let component = generate_argument_type(c, false, true);
quote!(mint::Vector3<#component>)
}
ArgumentType::Quat => quote!(mint::Quaternion<f32>),
ArgumentType::Color => quote!(stardust_xr::values::Color),
ArgumentType::Bytes => {
Expand Down
10 changes: 7 additions & 3 deletions src/nodes/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ impl PulseSender {
self.aliases
.add(receiver.uid.clone() + "-field", &rx_field_alias);

let _ =
pulse_sender_client::new_receiver(&tx_node, &receiver.uid, &rx_alias, &rx_field_alias);
let _ = pulse_sender_client::create_receiver(
&tx_node,
&receiver.uid,
&rx_alias,
&rx_field_alias,
);
}

fn handle_drop_receiver(&self, receiver: &PulseReceiver) {
Expand All @@ -128,7 +132,7 @@ impl PulseSender {
let Some(tx_node) = self.node.upgrade() else {
return;
};
let _ = pulse_sender_client::drop_receiver(&tx_node, uid);
let _ = pulse_sender_client::destroy_receiver(&tx_node, uid);
}
}
impl Aspect for PulseSender {
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/input/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl InputMethod {
.add(handler.uid.clone() + "-field", &rx_field_alias);
}

let _ = input_method_client::new_handler(&method_node, &handler.uid, &handler_node);
let _ = input_method_client::create_handler(&method_node, &handler.uid, &handler_node);
}
pub(super) fn handle_drop_handler(&self, handler: &InputHandler) {
let uid = handler.uid.as_str();
Expand All @@ -147,7 +147,7 @@ impl InputMethod {
return;
};

let _ = input_method_client::drop_handler(&tx_node, &uid);
let _ = input_method_client::destroy_handler(&tx_node, &uid);
}
}
impl Aspect for InputMethod {
Expand Down
97 changes: 0 additions & 97 deletions src/nodes/items/environment.rs

This file was deleted.

9 changes: 0 additions & 9 deletions src/nodes/items/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pub mod camera;
mod environment;
pub mod panel;

use self::camera::CameraItem;
use self::environment::{EnvironmentItem, ITEM_TYPE_INFO_ENVIRONMENT};
use self::panel::{PanelItemTrait, ITEM_TYPE_INFO_PANEL};
use super::fields::Field;
use super::spatial::{parse_transform, Spatial};
Expand Down Expand Up @@ -182,14 +180,12 @@ impl Drop for Item {

pub enum ItemType {
Camera(CameraItem),
Environment(EnvironmentItem),
Panel(Arc<dyn PanelItemTrait>),
}
impl ItemType {
fn serialize_start_data(&self, id: &str) -> Result<Message> {
match self {
ItemType::Camera(c) => c.serialize_start_data(id),
ItemType::Environment(e) => e.serialize_start_data(id),
ItemType::Panel(p) => p.serialize_start_data(id),
}
}
Expand Down Expand Up @@ -437,18 +433,13 @@ impl Drop for ItemAcceptor {
pub fn create_interface(client: &Arc<Client>) -> Result<()> {
let node = Node::create_parent_name(client, "", "item", false);
node.add_local_signal("create_camera_item", camera::create_camera_item_flex);
node.add_local_signal(
"create_environment_item",
environment::create_environment_item_flex,
);
node.add_local_signal("register_item_ui", register_item_ui_flex);
node.add_local_signal("create_item_acceptor", create_item_acceptor_flex);
node.add_to_scenegraph().map(|_| ())
}

fn type_info(name: &str) -> Result<&'static TypeInfo> {
match name {
"environment" => Ok(&ITEM_TYPE_INFO_ENVIRONMENT),
#[cfg(feature = "wayland")]
"panel" => Ok(&ITEM_TYPE_INFO_PANEL),
_ => Err(eyre!("Invalid item type")),
Expand Down

0 comments on commit adbfd6e

Please sign in to comment.