2019-02-14 08:37:02 -08:00
class @beta Efl.Io.Buffer extends Efl.Object implements Efl.Io.Reader, Efl.Io.Writer, Efl.Io.Closer, Efl.Io.Sizer, Efl.Io.Positioner {
2016-08-13 00:50:29 -07:00
[[Generic In-memory buffer of data to be used as I/O.
This class offers both input and output, which can be used at
the same time since @Efl.Io.Reader.read and @Efl.Io.Writer.write
use different offsets/position internally.
One can get temporary direct access to internal buffer with
2016-12-19 08:46:37 -08:00
@.slice or steal the buffer with @.binbuf_steal.
2016-08-13 00:50:29 -07:00
A fixed sized buffer can be implemented by setting @.limit
followed by @.preallocate
]]
methods {
preallocate {
[[Immediately pre-allocate a buffer of at least a given size.]]
params {
2016-11-01 06:13:42 -07:00
@in size: size; [[Amount of bytes to pre-allocate.]]
2016-08-13 00:50:29 -07:00
}
}
2016-12-19 10:49:29 -08:00
adopt_readonly {
[[Adopt a read-only slice as buffer's backing store.
The slice memory will not be copied and must remain
2017-12-22 02:41:11 -08:00
alive during the buffer's lifetime. Usually this is
2016-12-19 10:49:29 -08:00
guaranteed by some global static-const memory or some
parent object and this buffer being a view of that -- be
aware of parent memory remaining alive, such as
"slice,changed" events.
]]
params {
@in slice: const(Eina.Slice); [[Slice to adopt as read-only]]
}
}
adopt_readwrite {
[[Adopt a read-write slice as buffer's backing store.
The slice memory will not be copied and must remain
2017-12-22 02:41:11 -08:00
alive during the buffer's lifetime. Usually this is
2016-12-19 10:49:29 -08:00
guaranteed by some global static memory or some
parent object and this buffer being a view of that -- be
aware of parent memory remaining alive, such as
"slice,changed" events.
The memory will be disposed using free() and reallocated
using realloc().
]]
params {
@in slice: Eina.Rw_Slice; [[Slice to adopt as read-write]]
}
}
2016-08-13 00:50:29 -07:00
@property limit {
[[Limit how big the buffer can grow.
This affects both @.preallocate and how buffer grows
when @Efl.Io.Writer.write is called.
2017-12-22 02:41:11 -08:00
If you want a buffer of an exact size always set the
limit before any further calls that can expand it.
2016-08-13 00:50:29 -07:00
]]
get { }
set {
[[Constructor-only property to set buffer limit. 0 is unlimited]]
}
values {
size: size; [[Defines a maximum buffer size, or 0 to allow unlimited amount of bytes]]
}
}
@property position_read {
[[The position used by @Efl.Io.Reader.read.
Note that @Efl.Io.Positioner.seek or
@Efl.Io.Positioner.position.set will affect this property
and @.position_write.
@Efl.Io.Positioner.position.get will return the greatest
of @.position_read and @.position_write.
]]
get { }
set {
2016-11-01 06:13:42 -07:00
return: bool (false); [[$true if setting the position succeeded, $false otherwise]]
2016-08-13 00:50:29 -07:00
}
values {
2016-11-01 06:13:42 -07:00
position: uint64; [[Position in buffer]]
2016-08-13 00:50:29 -07:00
}
}
@property position_write {
[[The position used by @Efl.Io.Writer.write.
Note that @Efl.Io.Positioner.seek or
@Efl.Io.Positioner.position.set will affect this property
and @.position_read.
@Efl.Io.Positioner.position.get will return the greatest
of @.position_read and @.position_write.
]]
get { }
set {
2016-11-01 06:13:42 -07:00
return: bool (false); [[$true if setting the position succeeded, $false otherwise]]
2016-08-13 00:50:29 -07:00
}
values {
2016-11-01 06:13:42 -07:00
position: uint64; [[Position in buffer]]
2016-08-13 00:50:29 -07:00
}
}
2016-12-19 08:46:37 -08:00
@property slice {
2016-08-13 00:50:29 -07:00
[[Get a temporary access to buffer's internal memory.
The memory pointed by slice may be changed by other
methods of this class. The event "reallocated" will be
called in those situations.
]]
2016-12-19 08:46:37 -08:00
get { }
values {
slice: Eina.Slice; [[Slice of the current buffer, may be invalidated if @Efl.Io.Writer.write, @Efl.Io.Closer.close or @Efl.Io.Sizer.resize are called. It is the full slice, not a partial one starting at current position.]]
2016-08-13 00:50:29 -07:00
}
}
binbuf_steal {
[[Steals the internal buffer memory and returns it as a binbuf.
The returned memory must be freed with eina_binbuf_free().
2016-12-19 10:49:29 -08:00
On failure, for example a read-only backing store was
adopted with @.adopt_readonly, NULL is returned.
2016-08-13 00:50:29 -07:00
]]
2019-05-26 08:41:22 -07:00
return: ptr(Eina.Binbuf) @owned @no_unused; [[Binbuf]]
2016-08-13 00:50:29 -07:00
}
}
events {
efl: Add missing event types
Summary:
All events must have a type now, otherwise bindings don't know how to handle
the event_info field.
Most of the missing event types were actually "void" (no event_info present).
Some struct definitions had to be moved to eo instead of h files, so they
are available to bindings. Some have not, and are marked with FIXME.
Some namespaces have been fixed (like Efl_Event_Cb -> Efl.Event_Cb).
In general, there are hundreds of changed files, but mostly to add a type which
was not present before, so there's no harm done.
Also, A lot of FIXMEs have been added which should be, like, fixed.
For example, some events can send different types of event_info, which is
very inconvenient (and error prone).
Test Plan: make with c# bindings works, make check and make examples work too.
Reviewers: cedric, q66, lauromoura
Subscribers: zmike
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D6169
2018-05-11 08:20:40 -07:00
position_read,changed: void; [[Notifies @.position_read changed]]
position_write,changed: void; [[Notifies @.position_write changed]]
reallocated: void; [[Notifies the internal buffer was reallocated, thus whatever was returned by @.slice becomes invalid]]
2016-08-13 00:50:29 -07:00
}
implements {
Efl.Object.finalize;
Efl.Object.destructor;
Efl.Io.Reader.read;
2016-12-27 07:06:19 -08:00
Efl.Io.Reader.can_read { get; set; }
Efl.Io.Reader.eos { get; set; }
2016-08-13 00:50:29 -07:00
Efl.Io.Writer.write;
2016-12-27 07:06:19 -08:00
Efl.Io.Writer.can_write { get; set; }
2016-08-13 00:50:29 -07:00
Efl.Io.Closer.close;
2016-12-27 07:06:19 -08:00
Efl.Io.Closer.closed { get; }
2017-01-11 07:35:03 -08:00
Efl.Io.Closer.close_on_exec { get; set; }
2018-04-17 16:17:29 -07:00
Efl.Io.Closer.close_on_invalidate { get; set; }
2016-08-13 00:50:29 -07:00
Efl.Io.Sizer.resize;
2016-12-27 07:06:19 -08:00
Efl.Io.Sizer.size { get; }
2016-08-13 00:50:29 -07:00
Efl.Io.Positioner.seek;
2016-12-27 07:06:19 -08:00
Efl.Io.Positioner.position { get; }
2016-08-13 00:50:29 -07:00
}
}