mirror of
https://github.com/AdaCore/PolyORB.git
synced 2026-02-12 13:01:15 -08:00
Fixed bugs in code generation.
Ensured that the echo and all_types clients compile and work. Added random example. [Imported from Perforce change 1292 at 2006-12-01 18:46:05] Subversion-branch: /trunk/adabroker Subversion-revision: 31897
This commit is contained in:
@@ -52,6 +52,14 @@ examples/echo/server.adb
|
||||
examples/generic/genericserver.adb
|
||||
examples/generic/genericserver.ads
|
||||
examples/generic/header.txt
|
||||
examples/random/IOR
|
||||
examples/random/broca.opt
|
||||
examples/random/client.adb
|
||||
examples/random/header.txt
|
||||
examples/random/random-impl.adb
|
||||
examples/random/random-impl.ads
|
||||
examples/random/random.idl
|
||||
examples/random/server.adb
|
||||
examples/report.adb
|
||||
examples/report.ads
|
||||
idlac/Makefile.am
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
BROCA_ADASOCKET = $(BROCA_TOP)/adasockets/src
|
||||
GNATMAKE = gnatmake
|
||||
ADA_FLAGS = -O2 -g -i -m -gnatafg -gnatwu -gnatwl -I$(BROCA_ADASOCKET)
|
||||
ADA_FLAGS = -O2 -g -i -m -gnataf -gnatwu -gnatwl -I$(BROCA_ADASOCKET)
|
||||
BROCA_FLAGS = $(ADA_FLAGS) -I$(BROCA_TOP)/src -I..
|
||||
|
||||
ADABROKER = $(BROCA_TOP)/adabroker/adabroker
|
||||
ADABROKER = $(BROCA_TOP)/idlac/idlac
|
||||
|
||||
LibPattern = lib%.a
|
||||
|
||||
|
||||
@@ -9,27 +9,4 @@ echo.adb\
|
||||
echo.ads\
|
||||
echo_idl_file.ads
|
||||
|
||||
|
||||
BROCA_FLAGS += -I../generic
|
||||
|
||||
all:: client server
|
||||
|
||||
#client:: $(CORBA_LIB_DEPEND) $(GENERATED_FILES) client.adb
|
||||
client:: $(GENERATED_FILES) force
|
||||
$(GNATMAKE) $(BROCA_FLAGS) -i client.adb
|
||||
|
||||
#server:: $(CORBA_LIB_DEPEND) $(GENERATED_FILES) server.adb ../generic/genericserver.ads ../generic/genericserver.adb
|
||||
server:: $(GENERATED_FILES) force
|
||||
$(GNATMAKE) $(BROCA_FLAGS) -i server.adb
|
||||
|
||||
$(GENERATED_FILES):: $(IDL_INTERFACE).idl
|
||||
@echo Not mapping IDL contract...
|
||||
|
||||
stubs:: $(IDL_INTERFACE).idl
|
||||
$(ADABROKER) -i $(IDL_INTERFACE).idl
|
||||
|
||||
force::
|
||||
|
||||
clean::
|
||||
-rm -f b~*.ad[sb] *.o *.ali *~ server client $(GENERATED_FILES)
|
||||
|
||||
include ../generic/dir.mk
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
with Ada.Text_IO;
|
||||
with Echo.Skel;
|
||||
pragma Elaborate (Echo.Skel);
|
||||
|
||||
package body Echo.Impl is
|
||||
|
||||
|
||||
@@ -26,20 +26,19 @@
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
with Echo.Skel;
|
||||
with CORBA;
|
||||
with PortableServer;
|
||||
|
||||
package Echo.Impl is
|
||||
-- My own implementation of echo object.
|
||||
-- This is simply used to define the operations.
|
||||
|
||||
type Object is new Echo.Skel.Object with record
|
||||
type Object is new PortableServer.Servant_Base with record
|
||||
Msg : CORBA.String;
|
||||
end record;
|
||||
|
||||
type Object_Acc is access Object;
|
||||
|
||||
private
|
||||
function EchoString (Self : access Object; Mesg : in CORBA.String)
|
||||
return CORBA.String;
|
||||
|
||||
|
||||
@@ -6,11 +6,9 @@ BROCA_FLAGS += -I../../generic
|
||||
|
||||
all:: client server
|
||||
|
||||
#client:: $(CORBA_LIB_DEPEND) $(GENERATED_FILES) client.adb
|
||||
client:: $(GENERATED_FILES) force
|
||||
$(GNATMAKE) $(BROCA_FLAGS) -i client.adb
|
||||
|
||||
#server:: $(CORBA_LIB_DEPEND) $(GENERATED_FILES) server.adb ../generic/genericserver.ads ../generic/genericserver.adb
|
||||
server:: $(GENERATED_FILES) force
|
||||
$(GNATMAKE) $(BROCA_FLAGS) -i server.adb
|
||||
|
||||
@@ -18,9 +16,6 @@ $(GENERATED_FILES):: $(IDL_INTERFACE).idl
|
||||
@echo Mapping IDL contract...
|
||||
$(ADABROKER) $(IDL_INTERFACE).idl
|
||||
|
||||
stubs:: $(IDL_INTERFACE).idl
|
||||
$(ADABROKER) -i $(IDL_INTERFACE).idl
|
||||
|
||||
force::
|
||||
|
||||
clean::
|
||||
|
||||
3
broca/examples/random/GNUmakefile
Normal file
3
broca/examples/random/GNUmakefile
Normal file
@@ -0,0 +1,3 @@
|
||||
BROCA_TOP=../..
|
||||
BROCA_CURRENT=example/random
|
||||
include $(BROCA_TOP)/config/config.mk
|
||||
1
broca/examples/random/IOR
Normal file
1
broca/examples/random/IOR
Normal file
@@ -0,0 +1 @@
|
||||
IOR:000000000000000f49444c3a52616e646f6d3a312e3000000000000100000000000000500001000000000016706c616e7874792e6473672e63732e7463642e69650006220000002c3a5c706c616e7874792e6473672e63732e7463642e69653a52616e646f6d3a303a3a49523a52616e646f6d00
|
||||
22
broca/examples/random/README
Normal file
22
broca/examples/random/README
Normal file
@@ -0,0 +1,22 @@
|
||||
About the "random" example
|
||||
==========================
|
||||
|
||||
Random.org offers true random numbers to anyone on the internet.
|
||||
If you want to know how the numbers are made and what it is that
|
||||
makes them true, read the introduction to randomness and random numbers.
|
||||
|
||||
Among other means, these random numbers are made available to
|
||||
the community through a CORBA object with a well-known IOR
|
||||
(see file IOR in this directory). The random example contains
|
||||
a client for this service, and also a server implementation
|
||||
that implements the same interface.
|
||||
|
||||
Beware however that, unlike random.org's numbers, the numbers
|
||||
generated by the AdaBroker server implementation are /not/ truly
|
||||
random in any sense. Random.org carefully craft their numbers using
|
||||
real entropy generators, while we simply use the Ada runtime to
|
||||
generate a pseudo-random sequence.
|
||||
|
||||
For more information about random.org, please go to:
|
||||
<URL:http://www.random.org/>.
|
||||
|
||||
38
broca/examples/random/broca.opt
Normal file
38
broca/examples/random/broca.opt
Normal file
@@ -0,0 +1,38 @@
|
||||
broca.exceptions
|
||||
broca.flags
|
||||
broca.giop
|
||||
broca.iiop
|
||||
broca.inet_server
|
||||
broca.ior
|
||||
broca.locks
|
||||
broca.marshalling
|
||||
broca.object
|
||||
broca.orb
|
||||
broca.poa
|
||||
broca.refs
|
||||
broca.repository
|
||||
broca.rootpoa
|
||||
broca.sequences
|
||||
broca.server
|
||||
broca.stream
|
||||
broca.vararray
|
||||
corba.forward
|
||||
corba.object
|
||||
corba.orb
|
||||
corba.sequences.unbounded
|
||||
corba
|
||||
portableserver.adapteractivator.impl
|
||||
portableserver.adapteractivator
|
||||
portableserver.poa
|
||||
portableserver.poamanager
|
||||
portableserver.servantactivator
|
||||
portableserver.servantlocator
|
||||
portableserver.servantmanager.impl
|
||||
portableserver
|
||||
broca
|
||||
broca.types
|
||||
corba.sequences
|
||||
portableserver.servantactivator.impl
|
||||
portableserver.servantlocator.impl
|
||||
portableserver.servantmanager
|
||||
|
||||
78
broca/examples/random/client.adb
Normal file
78
broca/examples/random/client.adb
Normal file
@@ -0,0 +1,78 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- ADABROKER COMPONENTS --
|
||||
-- --
|
||||
-- C L I E N T --
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- $LastChangedRevision$
|
||||
-- --
|
||||
-- Copyright (C) 1999 ENST Paris University, France. --
|
||||
-- --
|
||||
-- AdaBroker is free software; you can redistribute it and/or modify it --
|
||||
-- under terms of the GNU General Public License as published by the Free --
|
||||
-- Software Foundation; either version 2, or (at your option) any later --
|
||||
-- version. AdaBroker is distributed in the hope that it will be useful, --
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
|
||||
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
|
||||
-- License for more details. You should have received a copy of the GNU --
|
||||
-- General Public License distributed with AdaBroker; see file COPYING. If --
|
||||
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
|
||||
-- Boston, MA 02111-1307, USA. --
|
||||
-- --
|
||||
-- AdaBroker is maintained by ENST Paris University. --
|
||||
-- (email: broker@inf.enst.fr) --
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
-- Random client.
|
||||
with Ada.Command_Line;
|
||||
with Text_IO; use Text_IO;
|
||||
with CORBA; use CORBA;
|
||||
with CORBA.ORB;
|
||||
with Random;
|
||||
|
||||
procedure Client is
|
||||
IOR : CORBA.String;
|
||||
myRandom : Random.Ref;
|
||||
Result : CORBA.Long;
|
||||
|
||||
begin
|
||||
|
||||
if Ada.Command_Line.Argument_Count < 1 then
|
||||
Put_Line ("usage : client <IOR_string_from_server>");
|
||||
return;
|
||||
end if;
|
||||
|
||||
-- transforms the Ada string into CORBA.String
|
||||
IOR := CORBA.To_CORBA_String (Ada.Command_Line.Argument (1));
|
||||
|
||||
-- getting the CORBA.Object
|
||||
CORBA.ORB.String_To_Object (IOR, myRandom);
|
||||
|
||||
-- checking if it worked
|
||||
if Random.Is_Nil (myRandom) then
|
||||
Put_Line ("main : cannot invoke on a nil reference");
|
||||
return;
|
||||
end if;
|
||||
|
||||
Put_Line("Here are some true random numbers:");
|
||||
|
||||
for I in 1 .. 10 loop
|
||||
Result := Random.Lrand48(myRandom);
|
||||
Put (CORBA.Long'Image (Result) & " ");
|
||||
end loop;
|
||||
|
||||
exception
|
||||
when E : CORBA.Transient =>
|
||||
declare
|
||||
Memb : System_Exception_Members;
|
||||
begin
|
||||
Get_Members (E, Memb);
|
||||
Put ("received exception transient, minor");
|
||||
Put (Unsigned_Long'Image (Memb.Minor));
|
||||
Put (", completion status: ");
|
||||
Put_Line (Completion_Status'Image (Memb.Completed));
|
||||
end;
|
||||
end Client;
|
||||
12
broca/examples/random/dir.mk
Normal file
12
broca/examples/random/dir.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
IDL_INTERFACE = random
|
||||
|
||||
GENERATED_FILES =\
|
||||
random-skel.adb\
|
||||
random-skel.ads\
|
||||
random-stream.adb\
|
||||
random-stream.ads\
|
||||
random.adb\
|
||||
random.ads\
|
||||
random_idl_file.ads
|
||||
|
||||
include ../generic/dir.mk
|
||||
23
broca/examples/random/header.txt
Normal file
23
broca/examples/random/header.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- ADABROKER COMPONENTS --
|
||||
-- --
|
||||
XXXXXX
|
||||
-- --
|
||||
-- Copyright (C) 1999 ENST Paris University, France. --
|
||||
-- --
|
||||
-- AdaBroker is free software; you can redistribute it and/or modify it --
|
||||
-- under terms of the GNU General Public License as published by the Free --
|
||||
-- Software Foundation; either version 2, or (at your option) any later --
|
||||
-- version. AdaBroker is distributed in the hope that it will be useful, --
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
|
||||
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
|
||||
-- License for more details. You should have received a copy of the GNU --
|
||||
-- General Public License distributed with AdaBroker; see file COPYING. If --
|
||||
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
|
||||
-- Boston, MA 02111-1307, USA. --
|
||||
-- --
|
||||
-- AdaBroker is maintained by ENST Paris University. --
|
||||
-- (email: broker@inf.enst.fr) --
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
61
broca/examples/random/random-impl.adb
Normal file
61
broca/examples/random/random-impl.adb
Normal file
@@ -0,0 +1,61 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- ADABROKER COMPONENTS --
|
||||
-- --
|
||||
-- E C H O . I M P L --
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- $LastChangedRevision$
|
||||
-- --
|
||||
-- Copyright (C) 1999 ENST Paris University, France. --
|
||||
-- --
|
||||
-- AdaBroker is free software; you can redistribute it and/or modify it --
|
||||
-- under terms of the GNU General Public License as published by the Free --
|
||||
-- Software Foundation; either version 2, or (at your option) any later --
|
||||
-- version. AdaBroker is distributed in the hope that it will be useful, --
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
|
||||
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
|
||||
-- License for more details. You should have received a copy of the GNU --
|
||||
-- General Public License distributed with AdaBroker; see file COPYING. If --
|
||||
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
|
||||
-- Boston, MA 02111-1307, USA. --
|
||||
-- --
|
||||
-- AdaBroker is maintained by ENST Paris University. --
|
||||
-- (email: broker@inf.enst.fr) --
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
with Ada.Text_IO;
|
||||
with Ada.Numerics.Discrete_Random;
|
||||
pragma Elaborate (Ada.Numerics.Discrete_Random);
|
||||
with Random.Skel;
|
||||
pragma Elaborate (Random.Skel);
|
||||
|
||||
package body Random.Impl is
|
||||
|
||||
type l48 is range 0 .. 2 ** 31 - 1;
|
||||
package l48_Random is new Ada.Numerics.Discrete_Random (l48);
|
||||
l48_Gen : l48_Random.Generator;
|
||||
|
||||
function lrand48 (Self : access Object)
|
||||
return CORBA.Long is
|
||||
begin
|
||||
return CORBA.Long (l48_Random.Random (l48_Gen));
|
||||
end lrand48;
|
||||
|
||||
type m48 is range - 2 ** 31 .. 2 ** 31 - 1;
|
||||
package m48_Random is new Ada.Numerics.Discrete_Random (m48);
|
||||
m48_Gen : m48_Random.Generator;
|
||||
|
||||
function mrand48 (Self : access Object)
|
||||
return CORBA.Long is
|
||||
begin
|
||||
return CORBA.Long (m48_Random.Random (m48_Gen));
|
||||
end mrand48;
|
||||
|
||||
begin
|
||||
l48_Random.Reset (l48_Gen);
|
||||
m48_Random.Reset (m48_Gen);
|
||||
end Random.Impl;
|
||||
|
||||
43
broca/examples/random/random-impl.ads
Normal file
43
broca/examples/random/random-impl.ads
Normal file
@@ -0,0 +1,43 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- ADABROKER COMPONENTS --
|
||||
-- --
|
||||
-- E C H O . I M P L --
|
||||
-- --
|
||||
-- S p e c --
|
||||
-- --
|
||||
-- $LastChangedRevision$
|
||||
-- --
|
||||
-- Copyright (C) 1999 ENST Paris University, France. --
|
||||
-- --
|
||||
-- AdaBroker is free software; you can redistribute it and/or modify it --
|
||||
-- under terms of the GNU General Public License as published by the Free --
|
||||
-- Software Foundation; either version 2, or (at your option) any later --
|
||||
-- version. AdaBroker is distributed in the hope that it will be useful, --
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
|
||||
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
|
||||
-- License for more details. You should have received a copy of the GNU --
|
||||
-- General Public License distributed with AdaBroker; see file COPYING. If --
|
||||
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
|
||||
-- Boston, MA 02111-1307, USA. --
|
||||
-- --
|
||||
-- AdaBroker is maintained by ENST Paris University. --
|
||||
-- (email: broker@inf.enst.fr) --
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
with CORBA;
|
||||
with PortableServer;
|
||||
|
||||
package Random.Impl is
|
||||
|
||||
type Object is new PortableServer.Servant_Base with null record;
|
||||
|
||||
type Object_Acc is access Object;
|
||||
|
||||
function lrand48 (Self : access Object)
|
||||
return CORBA.Long;
|
||||
function mrand48 (Self : access Object)
|
||||
return CORBA.Long;
|
||||
|
||||
end Random.Impl;
|
||||
14
broca/examples/random/random.idl
Normal file
14
broca/examples/random/random.idl
Normal file
@@ -0,0 +1,14 @@
|
||||
// This interface was copied from http://random.org/corba.html, where you can
|
||||
// also find the current IOR of the server.
|
||||
// See client.cc for details.
|
||||
|
||||
// IDL
|
||||
interface Random {
|
||||
|
||||
// return non-negative long integer in the interval [0, 2^31)
|
||||
long lrand48();
|
||||
|
||||
// return signed long integer in the interval [-2^31, 2^31)
|
||||
long mrand48();
|
||||
};
|
||||
|
||||
39
broca/examples/random/server.adb
Normal file
39
broca/examples/random/server.adb
Normal file
@@ -0,0 +1,39 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- ADABROKER COMPONENTS --
|
||||
-- --
|
||||
-- S E R V E R --
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- $LastChangedRevision$
|
||||
-- --
|
||||
-- Copyright (C) 1999 ENST Paris University, France. --
|
||||
-- --
|
||||
-- AdaBroker is free software; you can redistribute it and/or modify it --
|
||||
-- under terms of the GNU General Public License as published by the Free --
|
||||
-- Software Foundation; either version 2, or (at your option) any later --
|
||||
-- version. AdaBroker is distributed in the hope that it will be useful, --
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
|
||||
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
|
||||
-- License for more details. You should have received a copy of the GNU --
|
||||
-- General Public License distributed with AdaBroker; see file COPYING. If --
|
||||
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
|
||||
-- Boston, MA 02111-1307, USA. --
|
||||
-- --
|
||||
-- AdaBroker is maintained by ENST Paris University. --
|
||||
-- (email: broker@inf.enst.fr) --
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
with Random.Impl;
|
||||
with GenericServer; use GenericServer;
|
||||
|
||||
procedure Server is
|
||||
begin
|
||||
|
||||
Repository_Id := new String'("IDL:Random:1.0");
|
||||
My_Obj := new Random.Impl.Object;
|
||||
GenericServer.Main (My_Obj);
|
||||
|
||||
end Server;
|
||||
@@ -751,7 +751,7 @@ package body Ada_Be.Idl2Ada is
|
||||
NL (CU);
|
||||
PL (CU, Ada_Name (Node) & " : exception;");
|
||||
PL (CU, Ada_Name (Node) & "_" & T_Repository_Id
|
||||
& " : constant CORBA.Repository_Id");
|
||||
& " : constant CORBA.RepositoryId");
|
||||
PL (CU, " := CORBA.To_CORBA_String ("""
|
||||
& Idl_Repository_Id (Node) & """);");
|
||||
NL (CU);
|
||||
@@ -1274,9 +1274,9 @@ package body Ada_Be.Idl2Ada is
|
||||
NL (CU);
|
||||
PL (CU, "-- Marshall exception");
|
||||
PL (CU, "Marshall");
|
||||
PL (CU, " (Reply_Buffer,");
|
||||
PL (CU, " (Reply_Buffer, CORBA.String (");
|
||||
PL (CU, " " & Ada_Full_Name (E_Node)
|
||||
& "_" & T_Repository_Id & ");");
|
||||
& "_" & T_Repository_Id & "));");
|
||||
Add_With_Stream (CU, Members_Type (E_Node));
|
||||
PL (CU, "Marshall (Reply_Buffer, " & T_Members & ");");
|
||||
PL (CU, "return;");
|
||||
@@ -1556,10 +1556,12 @@ package body Ada_Be.Idl2Ada is
|
||||
|
||||
PL (CU, "declare");
|
||||
II (CU);
|
||||
PL (CU,
|
||||
T_Exception_Repo_Id & " : constant CORBA.String");
|
||||
PL (CU, " := Unmarshall (" & T_Handler &
|
||||
".Buffer'Access);");
|
||||
PL (CU, T_Exception_Repo_Id
|
||||
& " : constant CORBA.RepositoryId");
|
||||
PL (CU, " := CORBA.RepositoryId");
|
||||
PL (CU, " (CORBA.String'");
|
||||
PL (CU, " (Unmarshall (" & T_Handler &
|
||||
".Buffer'Access)));");
|
||||
DI (CU);
|
||||
PL (CU, "begin");
|
||||
II (CU);
|
||||
@@ -1571,7 +1573,7 @@ package body Ada_Be.Idl2Ada is
|
||||
PL (CU, "if CORBA.""="" ("
|
||||
& T_Exception_Repo_Id & ",");
|
||||
PL (CU, " " & Ada_Full_Name (E_Node)
|
||||
& "_" & T_Repository_Id & " then");
|
||||
& "_" & T_Repository_Id & ") then");
|
||||
II (CU);
|
||||
PL (CU, "declare");
|
||||
II (CU);
|
||||
|
||||
Reference in New Issue
Block a user