New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove deprecated symbols from v0.9 #828
Conversation
Note: I did not remove the type aliases for First, Second, it makes it harder to know which instantiations are valid for Now, I could rename them to the Godot equivalents, to make sure they are "pool" arrays. For example However, I'm not sure if we would win that much. We have to consider that in GDScript, long type names are less of a problem due to dynamic typing. Plus, for I added documentation for now, to make the relation to the Godot pool types clear. Let me know what you think -- it could also possibly be renamed later. |
Regarding We might also want to builderize signal registration before the release, so we won't need to repeat this later. |
20bb625
to
e3c4dee
Compare
Since the only remaining methods are the builders for property, method and signals, definitely a good idea! Implemented.
I agree. Pushed the changes -- I also added some convenience constructors for - builder.add_signal(Signal {
- name: "tick_with_data",
- args: &[SignalArgument {
- name: "data",
- default: Variant::new(100),
- export_info: ExportInfo::new(VariantType::I64),
- usage: PropertyUsage::DEFAULT,
- }],
- });
+ builder
+ .signal("tick_with_data")
+ .arg(SignalArgument::with_default("data", Variant::new(100)))
+ .done(); or: - builder.add_signal(Signal {
- name: "completed",
- args: &[SignalArgument {
- name: "value",
- default: Variant::nil(),
- export_info: ExportInfo::new(VariantType::Nil),
- usage: PropertyUsage::DEFAULT,
- }],
- });
-
- builder.add_signal(Signal {
- name: "resumable",
- args: &[],
- });
+ builder
+ .signal("completed")
+ .arg(SignalArgument::untyped("value"))
+ .done();
+ builder.signal("resumable").done(); I might need a second pair of eyes on whether I understood the [Edit] Especially because signals are still untyped in GDScript, is the |
509ef11
to
1c01399
Compare
gdnative-core/src/export/signal.rs
Outdated
pub(super) fn new(class_builder: &'a ClassBuilder<C>, name: &str) -> Self { | ||
Self { | ||
class_builder, | ||
name: GodotString::from(name), | ||
args: vec![], | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should just make name
a type parameter then, if we just convert it to GodotString
? Same with ClassBuilder::signal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably mean name: impl Into<GodotString>
? Yes, that's a good idea.
The new()
method is not public, so conversion could also happen in ClassBuilder::signal()
, and new()
would directly take GodotString
by value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. if
new()
,untyped()
andwith_default()
constructors make sense. I haven't managed to find any documentation...[Edit] Especially because signals are still untyped in GDScript, is the
ExportInfo
purely informational? Does the type appear in the editor or some other context?
I think they make sense. IIRC the ExportInfo
is only there for the editor (GDScript code generation, animations maybe?). I don't believe they are checked.
gdnative-core/src/export/signal.rs
Outdated
default: Variant::nil(), | ||
export_info: ExportInfo::new(VariantType::Nil), | ||
usage: PropertyUsage::DEFAULT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this works. I think you'd need PropertyUsage::NIL_IS_VARIANT
(which is not exposed to GDNative) for this to work completely, but then again the argument types are not checked, so it might not matter anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, we had this code in impl NativeClass for FuncState
, so I assumed there's a special meaning with nil and default.
Do you remember what the intention was there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no intention. It was just necessary to provide a value for all the fields. Arbitrary values are ok for the FuncState
signals, since the latter would likely never show up in the editor. I was just unsure what such values could mean for signals that might.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Then maybe we can go with untyped()
which expresses the intention. If we find that another implementation fits better, we could change it transparently, and user code gets "auto-fixed".
This could potentially be simplified to something like: builder
.signal("tick_with_data")
.arg("data".default(100))
.done();
builder
.signal("completed")
.arg("value")
.done(); using |
I'm not sure if we should pollute the One thing I was considering, is renaming builder
.signal("completed")
.param(SignalParam::untyped("value"))
.done(); Or have separate builder
.signal("completed")
.param_untyped("value")
.param("my_int", VariantType::I64)
.param_default("my_string", Variant::new("default"))
.done(); A builder for the arg/param itself would likely not make things much more concise. But I also think we shouldn't overdo it with ergonomics here; this is still a rarely-used API. I'd rather enable an |
939deff
to
500b8a2
Compare
bors try |
tryBuild succeeded: |
383f155
to
34f5a1d
Compare
Signal API is now like this: fn my_register(builder: &ClassBuilder<MyType>) {
// Add signal without parameters
builder
.signal("jumped")
.done();
// Add another signal with 1 parameter (untyped)
builder
.signal("fired")
.with_param_untyped("weapon_type")
.done();
// Add third signal with int + String parameters, the latter with a default value "Kerosene"
builder
.signal("used_jetpack")
.with_param("fuel_spent", VariantType::I64)
.with_param_default("fuel_type", Variant::new("Kerosene"))
.done();
} Edit: reflect latest API |
34f5a1d
to
50be1db
Compare
Changes: * ClassBuilder * Remove add_method() * Remove add_method_advanced() -- now private * Remove add_method_with_rpc_mode() * Rename add_property() -> build_property() * Remove ScriptMethod, ScriptMethodFn, ScriptMethodAttributes * Color * Remove rgb(), rgba() * PoolArray type aliases * Add name of Godot equivalent + API link
Makes the relation to PoolArray clearer.
Consistent with standard Vec::leak(), Box::leak() etc.
cb3b360
to
432616d
Compare
432616d
to
305b57f
Compare
The builders might need another look (e.g. consistency in string parameters, I added |
bors r+ |
Build succeeded: |
Changes:
PoolArray
type aliases: document name of Godot equivalent + API linkClassBuilder
add_method()
add_method_advanced()
-- now privateadd_method_with_rpc_mode()
add_property()
->property()
build_method()
->method()
signal()
SignalBuilder
+with_param*()
methodsScriptMethod
,ScriptMethodFn
,ScriptMethodAttributes
Color::rgb()
,Color::rgba()
Reference::init_ref()
(unsound to call directly)FloatHint::Enum
(has no effect)Element
->PoolElement
SignalArgument
->SignalParam
String::forget()
->leak()
Variant::forget()
->leak()
#[must_use]
to avoid forgetting buildingClassBuilder
; it's not a builder in that sense