vlib: remove functions and fields, deprecated before 2023-03-20

* remove []int.reduce in favour of arrays.fold
  * remove datatypes.Set.equal in favour of datatypes.Set.==
  * remove datatypes.Set.difference in favour of datatypes.Set.-
  * remove gg.Context.set_cfg in favour of gg.Context.set_text_cfg
  * remove gg.Context.timage_pip in favour of gg.Context.pipeline.alpha
  * remove os.is_writable_folder in favour of os.ensure_folder_is_writable

  Discovered with `v run cmd/tools/show_ancient_deprecations.v 180`
This commit is contained in:
Delyan Angelov 2023-09-16 14:11:44 +03:00
parent 255e72456b
commit 7ffa8c13bf
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
6 changed files with 4 additions and 47 deletions

View file

@ -968,20 +968,6 @@ pub fn copy(mut dst []u8, src []u8) int {
return min return min
} }
// reduce executes a given reducer function on each element of the array,
// resulting in a single output value.
// NOTE: It exists as a method on `[]int` types only.
// See also `arrays.reduce` for same name or `arrays.fold` for same functionality.
[deprecated: 'use arrays.fold instead, this function has less flexibility than arrays.fold']
[deprecated_after: '2022-10-11']
pub fn (a []int) reduce(iter fn (int, int) int, accum_start int) int {
mut accum_ := accum_start
for i in a {
accum_ = iter(accum_, i)
}
return accum_
}
// grow_cap grows the array's capacity by `amount` elements. // grow_cap grows the array's capacity by `amount` elements.
// Internally, it does this by copying the entire array to // Internally, it does this by copying the entire array to
// a new memory location (creating a clone). // a new memory location (creating a clone).

View file

@ -46,12 +46,6 @@ pub fn (mut set Set[T]) clear() {
set.elements = map[T]u8{} set.elements = map[T]u8{}
} }
// equal checks whether the two given sets are equal (i.e. contain all and only the same elements).
[deprecated: 'use set1[T] == set2[T] instead']
pub fn (l Set[T]) equal(r Set[T]) bool {
return l == r
}
// == checks whether the two given sets are equal (i.e. contain all and only the same elements). // == checks whether the two given sets are equal (i.e. contain all and only the same elements).
pub fn (l Set[T]) == (r Set[T]) bool { pub fn (l Set[T]) == (r Set[T]) bool {
if l.elements.len != r.elements.len { if l.elements.len != r.elements.len {
@ -114,12 +108,6 @@ pub fn (l Set[T]) intersection(r Set[T]) Set[T] {
return set return set
} }
// difference returns the difference of sets.
[deprecated: 'use set1[T] - set2[T] instead']
pub fn (l Set[T]) difference(r Set[T]) Set[T] {
return l - r
}
// - returns the difference of sets. // - returns the difference of sets.
pub fn (l Set[T]) - (r Set[T]) Set[T] { pub fn (l Set[T]) - (r Set[T]) Set[T] {
mut set := l mut set := l

View file

@ -168,7 +168,6 @@ pub mut:
height int height int
clear_pass gfx.PassAction clear_pass gfx.PassAction
window sapp.Desc window sapp.Desc
timage_pip sgl.Pipeline [deprecated: 'Use `Context.pipeline.alpha` instead!']
pipeline &PipelineContainer = unsafe { nil } pipeline &PipelineContainer = unsafe { nil }
config Config config Config
user_data voidptr user_data voidptr
@ -259,10 +258,6 @@ fn gg_init_sokol_window(user_data voidptr) {
ctx.pipeline = &PipelineContainer{} ctx.pipeline = &PipelineContainer{}
ctx.pipeline.init_pipeline() ctx.pipeline.init_pipeline()
// Keep the old pipeline for now, cuz v ui used it.
ctx.timage_pip = ctx.pipeline.alpha
//
if ctx.config.init_fn != unsafe { nil } { if ctx.config.init_fn != unsafe { nil } {
$if android { $if android {
// NOTE on Android sokol can emit resize events *before* the init function is // NOTE on Android sokol can emit resize events *before* the init function is

View file

@ -147,12 +147,6 @@ pub fn (ctx &Context) set_text_cfg(cfg gx.TextCfg) {
ctx.ft.fons.vert_metrics(&ascender, &descender, &lh) ctx.ft.fons.vert_metrics(&ascender, &descender, &lh)
} }
// set_cfg sets the current text configuration
[deprecated: 'use set_text_cfg() instead']
pub fn (ctx &Context) set_cfg(cfg gx.TextCfg) {
ctx.set_text_cfg(cfg)
}
// draw_text draws the string in `text_` starting at top-left position `x`,`y`. // draw_text draws the string in `text_` starting at top-left position `x`,`y`.
// Text settings can be provided with `cfg`. // Text settings can be provided with `cfg`.
pub fn (ctx &Context) draw_text(x int, y int, text_ string, cfg gx.TextCfg) { pub fn (ctx &Context) draw_text(x int, y int, text_ string, cfg gx.TextCfg) {

View file

@ -920,9 +920,3 @@ pub fn config_dir() !string {
} }
return error('Cannot find config directory') return error('Cannot find config directory')
} }
[deprecated: 'use os.ensure_folder_is_writable instead']
pub fn is_writable_folder(folder string) !bool {
ensure_folder_is_writable(folder)!
return true
}

View file

@ -38,15 +38,15 @@ fn test_flag_result() {
} }
fn test_array_sym() { fn test_array_sym() {
var := [1, 2] var := ['abc', 'def']
typ := reflection.type_of(var) typ := reflection.type_of(var)
assert typ.sym.kind == .array assert typ.sym.kind == .array
assert typ.sym.language == .v assert typ.sym.language == .v
assert typ.sym.methods.len > 0 assert typ.sym.methods.len > 0
assert typ.sym.methods.filter(it.name == 'reduce').len > 0 assert typ.sym.methods.filter(it.name == 'join').len > 0
assert typ.sym.name == '[]int' assert typ.sym.name == '[]string'
assert (typ.sym.info as reflection.Array).nr_dims == 1 assert (typ.sym.info as reflection.Array).nr_dims == 1
assert (typ.sym.info as reflection.Array).elem_type == typeof[int]().idx assert (typ.sym.info as reflection.Array).elem_type == typeof[string]().idx
} }
fn test_sumtype_sym() { fn test_sumtype_sym() {