diff options
author | Mark Spruiell <mes@zeroc.com> | 2009-06-23 17:47:58 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2009-06-23 17:47:58 -0700 |
commit | a2e794a1366fcd71f04496c206869ffa158547ac (patch) | |
tree | 4c9d6554f3dc658aeaa76892aeecfc3d7eb56b61 /php/lib | |
parent | Add x64 configurations to C++ projects (diff) | |
download | ice-a2e794a1366fcd71f04496c206869ffa158547ac.tar.bz2 ice-a2e794a1366fcd71f04496c206869ffa158547ac.tar.xz ice-a2e794a1366fcd71f04496c206869ffa158547ac.zip |
PHP changes:
- static translation
- more traditional language mapping (multiple communicators, etc.)
- support for registered (persistent) communicators
- support for PHP namespaces (PHP 5.3 or later)
Diffstat (limited to 'php/lib')
-rw-r--r-- | php/lib/.gitignore | 7 | ||||
-rw-r--r-- | php/lib/Glacier2.php | 13 | ||||
-rw-r--r-- | php/lib/Ice.php | 177 | ||||
-rw-r--r-- | php/lib/IceBox.php | 12 | ||||
-rw-r--r-- | php/lib/IceGrid.php | 19 | ||||
-rw-r--r-- | php/lib/IcePatch2.php | 12 | ||||
-rw-r--r-- | php/lib/IceStorm.php | 12 | ||||
-rw-r--r-- | php/lib/Ice_ns.php | 186 | ||||
-rw-r--r-- | php/lib/Makefile | 142 | ||||
-rw-r--r-- | php/lib/Makefile.mak | 123 |
10 files changed, 702 insertions, 1 deletions
diff --git a/php/lib/.gitignore b/php/lib/.gitignore index 39af5887579..337b0d0e758 100644 --- a/php/lib/.gitignore +++ b/php/lib/.gitignore @@ -1 +1,6 @@ -# Dummy file, so that git retains this otherwise empty directory. +Glacier2 +Ice +IceBox +IceGrid +IcePatch2 +IceStorm diff --git a/php/lib/Glacier2.php b/php/lib/Glacier2.php new file mode 100644 index 00000000000..dea4a62062e --- /dev/null +++ b/php/lib/Glacier2.php @@ -0,0 +1,13 @@ +<?php +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +require 'Glacier2/Router.php'; +require 'Glacier2/PermissionsVerifier.php'; +?> diff --git a/php/lib/Ice.php b/php/lib/Ice.php new file mode 100644 index 00000000000..e301c9d1ffe --- /dev/null +++ b/php/lib/Ice.php @@ -0,0 +1,177 @@ +<?php +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +// +// Exceptions. +// +abstract class Ice_Exception extends Exception +{ + public function __construct($message = '') + { + parent::__construct($message); + } + + abstract public function ice_name(); +} + +abstract class Ice_UserException extends Ice_Exception +{ + public function __construct($message = '') + { + parent::__construct($message); + } +} + +abstract class Ice_LocalException extends Ice_Exception +{ + public function __construct($message = '') + { + parent::__construct($message); + } +} + +interface Ice_Object +{ + public function ice_isA($id); + public function ice_ping(); + public function ice_ids(); + public function ice_id(); + + // + // No need to define these here; the marshaling code will invoke them if defined by a subclass. + // + //public function ice_preMarshal(); + //public function ice_postUnmarshal(); +} + +abstract class Ice_ObjectImpl implements Ice_Object +{ + public function ice_isA($id) + { + return array_search($id, ice_ids()); + } + + public function ice_ping() + { + } + + public function ice_ids() + { + return array(ice_id()); + } + + public function ice_id() + { + return "::Ice::Object"; + } +} + +$Ice__t_Object = IcePHP_defineClass('::Ice::Object', "Ice_Object", true, null, null, null); +$Ice__t_ObjectSeq = IcePHP_defineSequence('::Ice::ObjectSeq', $Ice__t_Object, true, 4); +$Ice__t_LocalObject = IcePHP_defineClass('::Ice::LocalObject', "Ice_LocalObject", true, null, null, null); +$Ice__t_ObjectPrx = IcePHP_defineProxy($Ice__t_Object); +$Ice__t_ObjectProxySeq = IcePHP_defineSequence('::Ice::ObjectProxySeq', $Ice__t_ObjectPrx, true, 2); + +interface Ice_ObjectFactory +{ + public function create($id); + public function destroy(); +} + +class Ice_InitializationData +{ + public function __construct($properties=null, $logger=null) + { + $this->properties = $properties; + $this->logger = $logger; + } + + public $properties; + public $logger; +} + +$Ice_sliceChecksums = array(); + +// +// Include certain generated files. +// +require 'Ice/BuiltinSequences.php'; +require 'Ice/EndpointTypes.php'; +require 'Ice/LocalException.php'; +require 'Ice/Locator.php'; +require 'Ice/ObjectFactory.php'; +require 'Ice/Process.php'; +require 'Ice/Router.php'; + +IcePHP_defineOperation($Ice__t_Object, 'ice_isA', 0, 0, array($IcePHP__t_string), null, $IcePHP__t_bool, null); +IcePHP_defineOperation($Ice__t_Object, 'ice_ping', 0, 0, null, null, null, null); +IcePHP_defineOperation($Ice__t_Object, 'ice_id', 0, 0, null, null, $IcePHP__t_string, null); +IcePHP_defineOperation($Ice__t_Object, 'ice_ids', 0, 0, null, null, $Ice__t_StringSeq, null); + +// +// Proxy comparison functions. +// +function Ice_proxyIdentityCompare($lhs, $rhs) +{ + if(($lhs != null && !($lhs instanceof Ice_ObjectPrx)) || ($rhs != null && !($rhs instanceof Ice_ObjectPrx))) + { + throw new InvalidArgumentException('argument is not a proxy'); + } + if($lhs == null && $rhs == null) + { + return 0; + } + elseif($lhs == null && $rhs != null) + { + return -1; + } + elseif($lhs != null && $rhs == null) + { + return 1; + } + else + { + $lid = $lhs->ice_getIdentity(); + $rid = $rhs->ice_getIdentity(); + if($lid < $rid) + { + return -1; + } + elseif($lid > $rid) + { + return 1; + } + else + { + return 0; + } + } +} + +function Ice_proxyIdentityEqual($lhs, $rhs) +{ + return Ice_proxyIdentityCompare($lhs, $rhs) == 0; +} + +function Ice_proxyIdentityAndFacetCompare($lhs, $rhs) +{ + $n = Ice_proxyIdentityCompare($lhs, $rhs); + if($n == 0 && $lhs != null && $rhs != null) + { + $n = strcmp($lhs->ice_getFacet(), $rhs->ice_getFacet()); + } + return $n; +} + +function Ice_proxyIdentityAndFacetEqual($lhs, $rhs) +{ + return Ice_proxyIdentityAndFacetCompare($lhs, $rhs) == 0; +} +?> diff --git a/php/lib/IceBox.php b/php/lib/IceBox.php new file mode 100644 index 00000000000..15501980f30 --- /dev/null +++ b/php/lib/IceBox.php @@ -0,0 +1,12 @@ +<?php +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +require 'IceBox/IceBox.php'; +?> diff --git a/php/lib/IceGrid.php b/php/lib/IceGrid.php new file mode 100644 index 00000000000..fc42e00c418 --- /dev/null +++ b/php/lib/IceGrid.php @@ -0,0 +1,19 @@ +<?php +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +require 'IceGrid/Admin.php'; +require 'IceGrid/Descriptor.php'; +require 'IceGrid/FileParser.php'; +require 'IceGrid/Locator.php'; +require 'IceGrid/Observer.php'; +require 'IceGrid/Query.php'; +require 'IceGrid/Registry.php'; +require 'IceGrid/UserAccountMapper.php'; +?> diff --git a/php/lib/IcePatch2.php b/php/lib/IcePatch2.php new file mode 100644 index 00000000000..93a990aa73f --- /dev/null +++ b/php/lib/IcePatch2.php @@ -0,0 +1,12 @@ +<?php +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +require 'IcePatch2/FileServer.php'; +?> diff --git a/php/lib/IceStorm.php b/php/lib/IceStorm.php new file mode 100644 index 00000000000..8a396345124 --- /dev/null +++ b/php/lib/IceStorm.php @@ -0,0 +1,12 @@ +<?php +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +require 'IceStorm/IceStorm.php'; +?> diff --git a/php/lib/Ice_ns.php b/php/lib/Ice_ns.php new file mode 100644 index 00000000000..12c4d3159fd --- /dev/null +++ b/php/lib/Ice_ns.php @@ -0,0 +1,186 @@ +<?php +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +namespace Ice +{ + // + // Exceptions. + // + abstract class Exception extends \Exception + { + public function __construct($message = '') + { + parent::__construct($message); + } + + abstract public function ice_name(); + } + + abstract class UserException extends Exception + { + public function __construct($message = '') + { + parent::__construct($message); + } + } + + abstract class LocalException extends Exception + { + public function __construct($message = '') + { + parent::__construct($message); + } + } + + interface Object + { + public function ice_isA($id); + public function ice_ping(); + public function ice_ids(); + public function ice_id(); + + // + // No need to define these here; the marshaling code will invoke them if defined by a subclass. + // + //public function ice_preMarshal(); + //public function ice_postUnmarshal(); + } + + abstract class ObjectImpl implements Object + { + public function ice_isA($id) + { + return array_search($id, ice_ids()); + } + + public function ice_ping() + { + } + + public function ice_ids() + { + return array(ice_id()); + } + + public function ice_id() + { + return "::Ice::Object"; + } + } + + $Ice__t_Object = IcePHP_defineClass('::Ice::Object', "Ice\\Object", true, null, null, null); + $Ice__t_ObjectSeq = IcePHP_defineSequence('::Ice::ObjectSeq', $Ice__t_Object, true, 4); + $Ice__t_LocalObject = IcePHP_defineClass('::Ice::LocalObject', "Ice\\LocalObject", true, null, null, null); + $Ice__t_ObjectPrx = IcePHP_defineProxy($Ice__t_Object); + $Ice__t_ObjectProxySeq = IcePHP_defineSequence('::Ice::ObjectProxySeq', $Ice__t_ObjectPrx, true, 2); + + interface ObjectFactory + { + public function create($id); + public function destroy(); + } + + class InitializationData + { + public function __construct($properties=null, $logger=null) + { + $this->properties = $properties; + $this->logger = $logger; + } + + public $properties; + public $logger; + } + + $Ice_sliceChecksums = array(); +} + +namespace +{ +// +// Include certain generated files. +// +require 'Ice/BuiltinSequences.php'; +require 'Ice/EndpointTypes.php'; +require 'Ice/LocalException.php'; +require 'Ice/Locator.php'; +require 'Ice/ObjectFactory.php'; +require 'Ice/Process.php'; +require 'Ice/Router.php'; + +IcePHP_defineOperation($Ice__t_Object, 'ice_isA', 0, 0, array($IcePHP__t_string), array(), $IcePHP__t_bool, null); +IcePHP_defineOperation($Ice__t_Object, 'ice_ping', 0, 0, null, null, null, null); +IcePHP_defineOperation($Ice__t_Object, 'ice_id', 0, 0, null, null, $IcePHP__t_string, null); +IcePHP_defineOperation($Ice__t_Object, 'ice_ids', 0, 0, null, null, $Ice__t_StringSeq, null); +} + +namespace Ice +{ + // + // Proxy comparison functions. + // + function proxyIdentityCompare($lhs, $rhs) + { + if(($lhs != null && !($lhs instanceof ObjectPrx)) || ($rhs != null && !($rhs instanceof ObjectPrx))) + { + throw new InvalidArgumentException('argument is not a proxy'); + } + if($lhs == null && $rhs == null) + { + return 0; + } + elseif($lhs == null && $rhs != null) + { + return -1; + } + elseif($lhs != null && $rhs == null) + { + return 1; + } + else + { + $lid = $lhs->ice_getIdentity(); + $rid = $rhs->ice_getIdentity(); + if($lid < $rid) + { + return -1; + } + elseif($lid > $rid) + { + return 1; + } + else + { + return 0; + } + } + } + + function proxyIdentityEqual($lhs, $rhs) + { + return proxyIdentityCompare($lhs, $rhs) == 0; + } + + function proxyIdentityAndFacetCompare($lhs, $rhs) + { + $n = proxyIdentityCompare($lhs, $rhs); + if($n == 0 && $lhs != null && $rhs != null) + { + $n = strcmp($lhs->ice_getFacet(), $rhs->ice_getFacet()); + } + return $n; + } + + function proxyIdentityAndFacetEqual($lhs, $rhs) + { + return proxyIdentityAndFacetCompare($lhs, $rhs) == 0; + } +} +?> diff --git a/php/lib/Makefile b/php/lib/Makefile new file mode 100644 index 00000000000..4124ea83ca2 --- /dev/null +++ b/php/lib/Makefile @@ -0,0 +1,142 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = .. + +include $(top_srcdir)/config/Make.rules + +# +# IMPORTANT: If you add or remove Slice files, you also need to check Ice.php! +# +ICE_SRCS = Ice/LocalException.php \ + Ice/Communicator.php \ + Ice/CommunicatorF.php \ + Ice/Logger.php \ + Ice/LoggerF.php \ + Ice/BuiltinSequences.php \ + Ice/ObjectAdapterF.php \ + Ice/Properties.php \ + Ice/PropertiesF.php \ + Ice/ObjectFactory.php \ + Ice/ObjectFactoryF.php \ + Ice/Identity.php \ + Ice/Current.php \ + Ice/ImplicitContextF.php \ + Ice/ImplicitContext.php \ + Ice/Router.php \ + Ice/RouterF.php \ + Ice/Plugin.php \ + Ice/PluginF.php \ + Ice/Locator.php \ + Ice/LocatorF.php \ + Ice/StatsF.php \ + Ice/Stats.php \ + Ice/Process.php \ + Ice/ProcessF.php \ + Ice/FacetMap.php \ + Ice/Connection.php \ + Ice/ConnectionF.php \ + Ice/SliceChecksumDict.php \ + Ice/Endpoint.php \ + Ice/EndpointF.php \ + Ice/EndpointTypes.php + +# +# IMPORTANT: If you add or remove Slice files, you also need to check Glacier2.php! +# +GLACIER2_SRCS = Glacier2/RouterF.php \ + Glacier2/Router.php \ + Glacier2/Session.php \ + Glacier2/PermissionsVerifierF.php \ + Glacier2/PermissionsVerifier.php \ + Glacier2/SSLInfo.php + +# +# IMPORTANT: If you add or remove Slice files, you also need to check IceBox.php! +# +ICEBOX_SRCS = IceBox/IceBox.php + +# +# IMPORTANT: If you add or remove Slice files, you also need to check IceGrid.php! +# +ICEGRID_SRCS = IceGrid/Admin.php \ + IceGrid/Descriptor.php \ + IceGrid/Exception.php \ + IceGrid/FileParser.php \ + IceGrid/Locator.php \ + IceGrid/Observer.php \ + IceGrid/Query.php \ + IceGrid/Registry.php \ + IceGrid/Session.php \ + IceGrid/UserAccountMapper.php + +# +# IMPORTANT: If you add or remove Slice files, you also need to check IcePatch2.php! +# +ICEPATCH2_SRCS = IcePatch2/FileInfo.php \ + IcePatch2/FileServer.php + +# +# IMPORTANT: If you add or remove Slice files, you also need to check IceStorm.php! +# +ICESTORM_SRCS = IceStorm/IceStorm.php + +ALL_SRCS = $(ICE_SRCS) \ + $(GLACIER2_SRCS) \ + $(ICEBOX_SRCS) \ + $(ICEGRID_SRCS) \ + $(ICEPATCH2_SRCS) \ + $(ICESTORM_SRCS) + +MODULES = Glacier2 Ice IceBox IceGrid IcePatch2 IceStorm +ifeq ("$(USE_NAMESPACES)","yes") +MODULE_SRCS = Glacier2.php Ice_ns.php IceBox.php IceGrid.php IcePatch2.php IceStorm.php +else +MODULE_SRCS = Glacier2.php Ice.php IceBox.php IceGrid.php IcePatch2.php IceStorm.php +endif + +all:: $(ALL_SRCS) + +Ice/%.php: $(slicedir)/Ice/%.ice + @mkdir -p $(notdir $(<D)) + $(SLICE2PHP) --output-dir $(notdir $(<D)) --ice $(SLICE2PHPFLAGS) $< + +Glacier2/%.php: $(slicedir)/Glacier2/%.ice + @mkdir -p $(notdir $(<D)) + $(SLICE2PHP) --output-dir $(notdir $(<D)) --ice $(SLICE2PHPFLAGS) $< + +IceBox/%.php: $(slicedir)/IceBox/%.ice + @mkdir -p $(notdir $(<D)) + $(SLICE2PHP) --output-dir $(notdir $(<D)) --ice $(SLICE2PHPFLAGS) $< + +IceGrid/%.php: $(slicedir)/IceGrid/%.ice + @mkdir -p $(notdir $(<D)) + $(SLICE2PHP) --output-dir $(notdir $(<D)) --ice $(SLICE2PHPFLAGS) $< + +IcePatch2/%.php: $(slicedir)/IcePatch2/%.ice + @mkdir -p $(notdir $(<D)) + $(SLICE2PHP) --output-dir $(notdir $(<D)) --ice $(SLICE2PHPFLAGS) $< + +IceStorm/%.php: $(slicedir)/IceStorm/%.ice + @mkdir -p $(notdir $(<D)) + $(SLICE2PHP) --output-dir $(notdir $(<D)) --ice $(SLICE2PHPFLAGS) $< + +install:: $(ALL_SRCS) + @echo "Installing generated code" + @for i in $(MODULES) ; \ + do \ + $(INSTALL_DATA) -r $$i $(install_phpdir) ; \ + done + @for i in $(MODULE_SRCS) ; \ + do \ + $(INSTALL_DATA) $$i $(install_phpdir) ; \ + done + +clean:: + rm -rf $(MODULES) diff --git a/php/lib/Makefile.mak b/php/lib/Makefile.mak new file mode 100644 index 00000000000..6bdc68f9c02 --- /dev/null +++ b/php/lib/Makefile.mak @@ -0,0 +1,123 @@ +# **********************************************************************
+#
+# Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ..
+
+!include $(top_srcdir)\config\Make.rules.mak
+
+#
+# IMPORTANT: If you add or remove Slice files, you also need to check Ice.php!
+#
+ICE_SRCS = Ice\LocalException.php \
+ Ice\Communicator.php \
+ Ice\CommunicatorF.php \
+ Ice\Logger.php \
+ Ice\LoggerF.php \
+ Ice\BuiltinSequences.php \
+ Ice\ObjectAdapterF.php \
+ Ice\Properties.php \
+ Ice\PropertiesF.php \
+ Ice\ObjectFactory.php \
+ Ice\ObjectFactoryF.php \
+ Ice\Identity.php \
+ Ice\Current.php \
+ Ice\ImplicitContextF.php \
+ Ice\ImplicitContext.php \
+ Ice\Router.php \
+ Ice\RouterF.php \
+ Ice\Plugin.php \
+ Ice\PluginF.php \
+ Ice\Locator.php \
+ Ice\LocatorF.php \
+ Ice\StatsF.php \
+ Ice\Stats.php \
+ Ice\Process.php \
+ Ice\ProcessF.php \
+ Ice\FacetMap.php \
+ Ice\Connection.php \
+ Ice\ConnectionF.php \
+ Ice\SliceChecksumDict.php \
+ Ice\Endpoint.php \
+ Ice\EndpointF.php \
+ Ice\EndpointTypes.php
+
+#
+# IMPORTANT: If you add or remove Slice files, you also need to check Glacier2.php!
+#
+GLACIER2_SRCS = Glacier2\RouterF.php \
+ Glacier2\Router.php \
+ Glacier2\Session.php \
+ Glacier2\PermissionsVerifierF.php \
+ Glacier2\PermissionsVerifier.php \
+ Glacier2\SSLInfo.php
+
+#
+# IMPORTANT: If you add or remove Slice files, you also need to check IceBox.php!
+#
+ICEBOX_SRCS = IceBox\IceBox.php
+
+#
+# IMPORTANT: If you add or remove Slice files, you also need to check IceGrid.php!
+#
+ICEGRID_SRCS = IceGrid\Admin.php \
+ IceGrid\Descriptor.php \
+ IceGrid\Exception.php \
+ IceGrid\FileParser.php \
+ IceGrid\Locator.php \
+ IceGrid\Observer.php \
+ IceGrid\Query.php \
+ IceGrid\Registry.php \
+ IceGrid\Session.php \
+ IceGrid\UserAccountMapper.php
+
+#
+# IMPORTANT: If you add or remove Slice files, you also need to check IcePatch2.php!
+#
+ICEPATCH2_SRCS = IcePatch2\FileInfo.php \
+ IcePatch2\FileServer.php
+
+#
+# IMPORTANT: If you add or remove Slice files, you also need to check IceStorm.php!
+#
+ICESTORM_SRCS = IceStorm\IceStorm.php
+
+ALL_SRCS = $(ICE_SRCS) \
+ $(GLACIER2_SRCS) \
+ $(ICEBOX_SRCS) \
+ $(ICEGRID_SRCS) \
+ $(ICEPATCH2_SRCS) \
+ $(ICESTORM_SRCS)
+
+MODULES = Glacier2 Ice IceBox IceGrid IcePatch2 IceStorm
+!if "$(USE_NAMESPACES)" == "yes"
+MODULE_SRCS = Glacier2.php Ice_ns.php IceBox.php IceGrid.php IcePatch2.php IceStorm.php
+!else
+MODULE_SRCS = Glacier2.php Ice.php IceBox.php IceGrid.php IcePatch2.php IceStorm.php
+!endif
+
+all:: $(ALL_SRCS)
+
+$(MODULES):
+ -mkdir $@
+
+$(ALL_SRCS): $(MODULES) {$(slicedir)}$*.ice
+ -$(SLICE2PHP) $(SLICE2PHPFLAGS) --output-dir $(*D) --ice $(slicedir)\$*.ice
+
+install::
+ @echo "Installing generated code"
+ @for %i in ( $(MODULES) ) do \
+ @if not exist $(install_phpdir)\%i \
+ mkdir $(install_phpdir)\%i
+ @for %i in ( $(MODULES) ) do \
+ copy %i\* $(install_phpdir)\%i
+ @for %i in ( $(MODULE_SRCS) ) do \
+ copy %i $(install_phpdir)
+
+clean::
+ -rmdir /S /Q $(MODULES)
|