Strip "new_" prefix from constructor functions #372

Merged
jwharm merged 2 commits from new-functions into main 2026-06-14 17:49:00 +02:00
Owner

Java-GI has, since a long time, renamed constructors from "new_with_some_property" to "with_some_property", stripping the "new_" prefix. However, there are also some functions (static methods in Java) that act as factories for new instances, that use this naming scheme. With this PR, these functions are also renamed.

Because in some cases, the "new_" prefix actually improves the name, only functions starting with the following prefixes are renamed:

  • new_for_...
  • new_with_...
  • new_build_...
  • new_take_... and new_take
  • new_from_...

Warning: The old methods are removed! Generating deprecated fallbacks would be a rather large change, and even though this could break some existing code, the fix will be very simple.

The following methods will been renamed with this change:

Namespace Enclosing type Old function name New function name
Gdk Pixbuf newFromStreamAsync fromStreamAsync
Gdk Pixbuf newFromStreamAtScaleAsync fromStreamAtScaleAsync
Gio File newBuildFilename buildFilename
Gio File newBuildFilenamev buildFilenamev
Gio File newForCommandLineArg forCommandLineArg
Gio File newForCommandLineArgAndCwd forCommandLineArgAndCwd
Gio File newForPath forPath
Gio File newForUri forUri
Gio Icon newForString forString
GLib PathBuf newFromPath fromPath
GstAudio AudioChannelMixer newWithMatrix withMatrix
GstBase BitWriter newWithData withData
GstBase BitWriter newWithSize withSize
GstBase ByteWriter newWithData withData
GstBase ByteWriter newWithSize withSize
GstBase QueueArray newForStruct forStruct
GstBase VecDequeue newForStruct forStruct
GstVideo VideoConverter newWithPool withPool
Java-GI has, since a long time, renamed constructors from "new_with_some_property" to "with_some_property", stripping the "new_" prefix. However, there are also some functions (static methods in Java) that act as factories for new instances, that use this naming scheme. With this PR, these functions are also renamed. Because in some cases, the "new_" prefix actually improves the name, only functions starting with the following prefixes are renamed: - `new_for_...` - `new_with_...` - `new_build_...` - `new_take_...` and `new_take` - `new_from_...` **Warning:** The old methods are removed! Generating deprecated fallbacks would be a rather large change, and even though this could break some existing code, the fix will be very simple. The following methods will been renamed with this change: | Namespace | Enclosing type | Old function name | New function name | | --------- | ----------------- | -------------------------- | ----------------------- | | Gdk | Pixbuf | newFromStreamAsync | fromStreamAsync | | Gdk | Pixbuf | newFromStreamAtScaleAsync | fromStreamAtScaleAsync | | Gio | File | newBuildFilename | buildFilename | | Gio | File | newBuildFilenamev | buildFilenamev | | Gio | File | newForCommandLineArg | forCommandLineArg | | Gio | File | newForCommandLineArgAndCwd | forCommandLineArgAndCwd | | Gio | File | newForPath | forPath | | Gio | File | newForUri | forUri | | Gio | Icon | newForString | forString | | GLib | PathBuf | newFromPath | fromPath | | GstAudio | AudioChannelMixer | newWithMatrix | withMatrix | | GstBase | BitWriter | newWithData | withData | | GstBase | BitWriter | newWithSize | withSize | | GstBase | ByteWriter | newWithData | withData | | GstBase | ByteWriter | newWithSize | withSize | | GstBase | QueueArray | newForStruct | forStruct | | GstBase | VecDequeue | newForStruct | forStruct | | GstVideo | VideoConverter | newWithPool | withPool |
jwharm force-pushed new-functions from e8009d276c to b649c9adb8 2026-06-14 17:48:28 +02:00 Compare
jwharm merged commit 6867fbfcf5 into main 2026-06-14 17:49:00 +02:00
jwharm deleted branch new-functions 2026-06-14 17:49:00 +02:00
Sign in to join this conversation.
No description provided.