Skip to content

Commit

Permalink
Rename ClassBuilder::build_*() -> *()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Dec 13, 2021
1 parent f49350b commit 20bb625
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions examples/array_export/src/lib.rs
Expand Up @@ -14,28 +14,28 @@ impl ExportsArrays {

fn register(builder: &ClassBuilder<Self>) {
builder
.build_property::<VariantArray>("single_array")
.property::<VariantArray>("single_array")
.with_setter(ExportsArrays::set_single_array)
.done();

builder
.build_property::<VariantArray>("single_array_range")
.property::<VariantArray>("single_array_range")
.with_setter(ExportsArrays::set_single_array_range)
.with_hint(ArrayHint::with_element_hint::<i64>(IntHint::Range(
RangeHint::new(-5, 5),
)))
.done();

builder
.build_property::<VariantArray>("double_array")
.property::<VariantArray>("double_array")
.with_setter(ExportsArrays::set_double_array)
.with_hint(ArrayHint::with_element_hint::<VariantArray>(
ArrayHint::new(),
))
.done();

builder
.build_property::<VariantArray>("double_array_range")
.property::<VariantArray>("double_array_range")
.with_setter(ExportsArrays::set_double_array_range)
.with_hint(ArrayHint::with_element_hint::<VariantArray>(
ArrayHint::with_element_hint::<i64>(IntHint::Range(RangeHint::new(-5, 5))),
Expand Down
4 changes: 2 additions & 2 deletions examples/spinning_cube/src/lib.rs
Expand Up @@ -15,7 +15,7 @@ struct RustTest {

fn register_properties(builder: &ClassBuilder<RustTest>) {
builder
.build_property::<String>("test/test_enum")
.property::<String>("test/test_enum")
.with_hint(StringHint::Enum(EnumHint::new(vec![
"Hello".into(),
"World".into(),
Expand All @@ -25,7 +25,7 @@ fn register_properties(builder: &ClassBuilder<RustTest>) {
.done();

builder
.build_property("test/test_flags")
.property("test/test_flags")
.with_hint(IntHint::Flags(EnumHint::new(vec![
"A".into(),
"B".into(),
Expand Down
2 changes: 1 addition & 1 deletion gdnative-async/src/rt/bridge.rs
Expand Up @@ -135,7 +135,7 @@ impl Method<SignalBridge> for OnSignalFn {
impl NativeClassMethods for SignalBridge {
fn register(builder: &ClassBuilder<Self>) {
builder
.build_method("_on_signal", OnSignalFn)
.method("_on_signal", OnSignalFn)
.done_stateless();
}
}
4 changes: 2 additions & 2 deletions gdnative-async/src/rt/func_state.rs
Expand Up @@ -169,10 +169,10 @@ impl StaticArgsMethod<FuncState> for ResumeFn {
impl NativeClassMethods for FuncState {
fn register(builder: &ClassBuilder<Self>) {
builder
.build_method("is_valid", StaticArgs::new(IsValidFn))
.method("is_valid", StaticArgs::new(IsValidFn))
.done_stateless();
builder
.build_method("resume", StaticArgs::new(ResumeFn))
.method("resume", StaticArgs::new(ResumeFn))
.done_stateless();
}
}
8 changes: 4 additions & 4 deletions gdnative-core/src/export/class_builder.rs
Expand Up @@ -76,7 +76,7 @@ impl<C: NativeClass> ClassBuilder<C> {
///
/// fn my_register(builder: &ClassBuilder<MyType>) {
/// builder
/// .build_method("my_method", MyMethod)
/// .method("my_method", MyMethod)
/// .with_rpc_mode(RpcMode::RemoteSync)
/// .done();
/// }
Expand All @@ -95,7 +95,7 @@ impl<C: NativeClass> ClassBuilder<C> {
/// ```
///
#[inline]
pub fn build_method<'a, F: Method<C>>(
pub fn method<'a, F: Method<C>>(
&'a self,
name: &'a str,
method: F,
Expand Down Expand Up @@ -128,7 +128,7 @@ impl<C: NativeClass> ClassBuilder<C> {
///
/// fn my_register(builder: &ClassBuilder<MyType>) {
/// builder
/// .build_property("foo")
/// .property("foo")
/// .with_default(5)
/// .with_hint((-10..=30).into())
/// .with_getter(MyType::get_foo)
Expand All @@ -138,7 +138,7 @@ impl<C: NativeClass> ClassBuilder<C> {
/// }
/// ```
#[inline]
pub fn build_property<'a, T>(&'a self, name: &'a str) -> PropertyBuilder<'a, C, T>
pub fn property<'a, T>(&'a self, name: &'a str) -> PropertyBuilder<'a, C, T>
where
T: Export,
{
Expand Down
4 changes: 2 additions & 2 deletions gdnative-derive/src/lib.rs
Expand Up @@ -50,7 +50,7 @@ mod variant;
/// impl gdnative::export::NativeClassMethods for Foo {
/// fn register(builder: &ClassBuilder<Self>) {
/// use gdnative::export::*;
/// builder.build_method("foo", gdnative::export::godot_wrap_method!(Foo, fn foo(&self, _owner: &Reference, bar: i64) -> i64))
/// builder.method("foo", gdnative::export::godot_wrap_method!(Foo, fn foo(&self, _owner: &Reference, bar: i64) -> i64))
/// .with_rpc_mode(RpcMode::Disabled)
/// .done_stateless();
/// }
Expand Down Expand Up @@ -177,7 +177,7 @@ pub fn profiled(meta: TokenStream, input: TokenStream) -> TokenStream {
/// }
/// fn my_register_function(builder: &ClassBuilder<Foo>) {
/// builder.add_signal(Signal { name: "foo", args: &[] });
/// builder.build_property::<f32>("bar")
/// builder.property::<f32>("bar")
/// .with_getter(|_, _| 42.0)
/// .with_hint(FloatHint::Range(RangeHint::new(0.0, 100.0)))
/// .done();
Expand Down
2 changes: 1 addition & 1 deletion gdnative-derive/src/methods.rs
Expand Up @@ -133,7 +133,7 @@ pub(crate) fn derive_methods(item_impl: ItemImpl) -> TokenStream2 {
fn #name ( #( #args )* ) -> #ret_ty
);

#builder.build_method(#name_string, method)
#builder.method(#name_string, method)
.with_rpc_mode(#rpc)
.done_stateless();
}
Expand Down
2 changes: 1 addition & 1 deletion gdnative-derive/src/native_script.rs
Expand Up @@ -79,7 +79,7 @@ pub(crate) fn derive_native_class(derive_input: &DeriveInput) -> Result<TokenStr

let label = config.path.unwrap_or_else(|| format!("{}", ident));
quote!({
builder.build_property(#label)
builder.property(#label)
#with_default
#with_hint
#with_usage
Expand Down
2 changes: 1 addition & 1 deletion test/src/test_async.rs
Expand Up @@ -94,6 +94,6 @@ impl AsyncMethod<AsyncMethods> for ResumeAddFn {

fn register_methods(builder: &ClassBuilder<AsyncMethods>) {
builder
.build_method("resume_add", Async::new(ResumeAddFn))
.method("resume_add", Async::new(ResumeAddFn))
.done();
}
8 changes: 4 additions & 4 deletions test/src/test_register.rs
Expand Up @@ -61,7 +61,7 @@ impl NativeClass for RegisterProperty {
}
fn register_properties(builder: &ClassBuilder<Self>) {
builder
.build_property("value")
.property("value")
.with_default(42)
.with_setter(RegisterProperty::set_value)
.with_getter(RegisterProperty::get_value)
Expand Down Expand Up @@ -155,15 +155,15 @@ where

fn register_methods(builder: &ClassBuilder<AdvancedMethods>) {
builder
.build_method("add_ints", StaticArgs::new(StatefulMixin { d: 42 }))
.method("add_ints", StaticArgs::new(StatefulMixin { d: 42 }))
.done();

builder
.build_method("add_floats", StaticArgs::new(StatefulMixin { d: 4.0 }))
.method("add_floats", StaticArgs::new(StatefulMixin { d: 4.0 }))
.done();

builder
.build_method(
.method(
"add_vectors",
StaticArgs::new(StatefulMixin {
d: Vector2::new(1.0, 2.0),
Expand Down

0 comments on commit 20bb625

Please sign in to comment.