comp.lang.ada
 help / color / mirror / Atom feed
From: Daniel <danielnorberto@gmail.com>
Subject: Re: Visibility issue
Date: Wed, 16 Sep 2020 03:23:43 -0700 (PDT)	[thread overview]
Message-ID: <28481dfd-7127-4106-bcfd-f085ffbf228fn@googlegroups.com> (raw)
In-Reply-To: <rjse0b$1d3c$1@gioia.aioe.org>

El miércoles, 16 de septiembre de 2020 a las 9:14:23 UTC+2, Dmitry A. Kazakov escribió:

> That is OK, but the hidden part needs to be constructed in some way. Your 
> requirements are silent about how. There exist only two possibilities, 
> it is either generated internally or else provided by the client 
> externally in some form, e.g. as parameters for the constructing function.
The Requirements are not constraining how to construct the API handle in both sides (Client, API and Internal). Im lucky with that. :)
Let's try to set and construct all hidden part details from Internal side, not from user side. I will add Just a public Registering type because it will be a limited pool of callbacks and users needs to Identify them.

What needs to know the user?
  -the implementation of the callback procedure it self
  -A number that identify this procedure (they are constrained to lets say just 12 procedures)

What needs to know and access the Internal package side?
   - A hidden part of Handle_type with dirty details about buffer pointers that needs to be set before triggering the procedure.
  - The callback procedure from a pool implemented in the same Internal package hierarchy that previously set the user.

Let me expose a simplification using the 3 parts: Client, API, Implementing.

-- USER SIDE: ---
procedure mycallback6 (S: in out Handle) is
begin
---call to public Handle functions
   ada.text_io.Put_Line(S.public_for_users);
end mycallback6;

procedure Initialize is
MyUserCallbackRegister : Register_type := (mycallback'Access , 6);
begin
null;
end Initialize;

-- API SIDE: ---------
package API.Callbacks
--Manage the callback:
type Handle is tagged private
type pointer_to_Procedure is access procedure (Self : API.CAllbacks.Handle );
function public_for_users(S: in out Handle) return string;
--Manage registering the callback
type Register_type is private;
function Register_Callback ( cp: CallbackProcedure , ID: Natural ) return Register_type ;
private
type Handle is tagged record
Usefull_for_Implementing_side : Pointer_To_buffer_type;
Register : Register_type; 
end record;
end package API.Callbacks;
type Register_type is Natural;

with Internal.Pool;
package body API.Callbacks is
function Register_Callback ( cp: CallbackProcedure , ID: Natural ) return Register_type  is
begin
   Internal.CallbacksPool.Set( cp, ID);
  return Register_type'(ID);
end Register_Callback;

----- IMPLEMENTING SIDE: --------
with API.Callbacks;
with Buffer_Stuff;
package body Internal.CallbacksPool is

task body InteranalCaller6 is
MyInternalHandle : API.Handle;
callbackprocedure: API.CallbackProcedure := Get_from_pool_of_callbacks (6);
begin
-- I need to set here the private part of MyInternalHandle defined in API.Handle before triggering and I Can't. :(
-- If I want to set this private part with a function, the only way is to make it public and accessible for users too.
 MyInternalHandle := ????
--Later I trigger:
 callbackprocedure (MyInternalHandle);
end InteranalCaller6 ;

end Internal.CallbacksPool;
-----------------------------------

So, here comes my options:
-- Set MyInternalHandle with a public function visible to users in API and tryng to explain them with education that they can't use it.
-- Implement the Internal details in API package hierarchy extending API.Handle
-- Saying to who give me this requirements I can't do it using Ada (and probably any other language)
-- Some other magic idea to implement this totally different :)

  reply	other threads:[~2020-09-16 10:23 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 10:37 Visibility issue Daniel
2020-09-11 11:51 ` Maxim Reznik
2020-09-11 20:11   ` Daniel
2020-09-11 14:23 ` Jeffrey R. Carter
2020-09-11 20:17   ` Daniel
2020-09-11 22:36     ` Jeffrey R. Carter
2020-09-14 10:47       ` Daniel
2020-09-14 16:10         ` Jeffrey R. Carter
2020-09-15 19:11           ` Daniel
2020-09-15 20:03             ` Jeffrey R. Carter
2020-09-11 21:05 ` Dmitry A. Kazakov
2020-09-14 11:33   ` Daniel
2020-09-14 14:42     ` Dmitry A. Kazakov
2020-09-15 19:35       ` Daniel
2020-09-16  7:14         ` Dmitry A. Kazakov
2020-09-16 10:23           ` Daniel [this message]
2020-09-16 10:58             ` Dmitry A. Kazakov
2020-09-16 14:35               ` Daniel
2020-09-16 14:49                 ` Jeffrey R. Carter
2020-09-16 15:05                 ` Dmitry A. Kazakov
2020-09-16 20:09                   ` Daniel
2020-09-16 21:48                     ` Simon Wright
2020-09-17 13:31                       ` Daniel
2020-09-17 15:00                         ` Dmitry A. Kazakov
2020-09-17 15:32                           ` Daniel
2020-09-17 16:47                             ` Dmitry A. Kazakov
2020-09-18  8:05                         ` Simon Wright
2020-09-14 16:18 ` Simon Wright
2020-09-17 15:58 ` Jere
2020-09-17 16:10 ` Jere
2020-09-18  8:08   ` Simon Wright
2020-09-17 21:47 ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox