You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 627 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
OK, I have realized how errorcheck(fn) attribute works for abstract
types. But now there is another crazy idea :-)
Suppose I have the following .IDL definition
typedef [abstract] void* TYPE;
TYPE create_object();
void process_object( TYPE t );
...
void delete_object( TYPE t );
create_object() allocates some memory and other resources that should be
freed when the object is no longer needed. This job is done by
delete_object(), which should be explicitly called. If not, we are in
trouble:
let obj = create_object () in
begin
process_object obj;
...
(* no delete_object -- object is not destructed properly! *)
end
What I propose:
Let's allow optional "fn" parameter to "abstract" attribute, that will
specify finalizer function:
typedef [abstract(delete_object)] void* TYPE;
TYPE create_object();
void process_object( TYPE t );
...
finaliser function should have type "void fn(TYPE)"
Having such attribute, camlidl allocates custom block with the appropriate
finalizer, that will be called when the block (i.e. object) is
garbage-collected. So abstract camlidl types will be safe as any OCaml
types.
What do you think of this?
Hope to hear from you soon,
Dmitry
The text was updated successfully, but these errors were encountered:
Original bug ID: 627
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
OK, I have realized how errorcheck(fn) attribute works for abstract
types. But now there is another crazy idea :-)
Suppose I have the following .IDL definition
typedef [abstract] void* TYPE;
TYPE create_object();
void process_object( TYPE t );
...
void delete_object( TYPE t );
create_object() allocates some memory and other resources that should be
freed when the object is no longer needed. This job is done by
delete_object(), which should be explicitly called. If not, we are in
trouble:
let obj = create_object () in
begin
process_object obj;
...
(* no delete_object -- object is not destructed properly! *)
end
What I propose:
Let's allow optional "fn" parameter to "abstract" attribute, that will
specify finalizer function:
typedef [abstract(delete_object)] void* TYPE;
TYPE create_object();
void process_object( TYPE t );
...
finaliser function should have type "void fn(TYPE)"
Having such attribute, camlidl allocates custom block with the appropriate
finalizer, that will be called when the block (i.e. object) is
garbage-collected. So abstract camlidl types will be safe as any OCaml
types.
What do you think of this?
Hope to hear from you soon,
Dmitry
The text was updated successfully, but these errors were encountered: