Skip to content

Commit

Permalink
Cleanup Ice.php (#2465)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Jul 11, 2024
1 parent e648d24 commit 56d7676
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 269 deletions.
310 changes: 44 additions & 266 deletions php/lib/Ice.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,271 +3,49 @@
// Copyright (c) ZeroC, Inc. All rights reserved.
//

//
// Definitions for IcePHP
//
namespace
{
//
// These symbols are defined by the extension but must be declared global
// here to ensure they are visible to scripts regardless of the scope in
// which we are currently executing.
//
global $IcePHP__t_bool;
global $IcePHP__t_byte;
global $IcePHP__t_short;
global $IcePHP__t_int;
global $IcePHP__t_long;
global $IcePHP__t_float;
global $IcePHP__t_double;
global $IcePHP__t_string;
}

namespace Ice
{
//
// Exceptions.
//
class Exception extends \Exception
{
}

class LocalException extends Exception
{
}

abstract class UserException extends Exception
{
abstract public function ice_id();
}

class Value
{
public $_ice_slicedData;

public static function ice_staticId()
{
return "::Ice::Object";
}

public function ice_id()
{
return "::Ice::Object";
}

public function ice_getSlicedData()
{
return $this->_ice_slicedData;
}
}

class ObjectPrxHelper
{
public static function checkedCast($proxy, $facetOrContext=null, $context=null)
{
return $proxy->ice_checkedCast('::Ice::Object', $facetOrContext, $context);
}

public static function uncheckedCast($proxy, $facet=null)
{
return $proxy->ice_uncheckedCast('::Ice::Object', $facet);
}

public static function ice_staticId()
{
return '::Ice::Object';
}
}

global $Ice__t_Value;
global $Ice__t_ObjectSeq;
global $Ice__t_ObjectPrx;
global $Ice__t_ObjectProxySeq;

$Ice__t_Value = IcePHP_defineClass('::Ice::Object', "\\Ice\\Value", -1, false, null, null);
$Ice__t_ObjectSeq = IcePHP_defineSequence('::Ice::ObjectSeq', $Ice__t_Value);
$Ice__t_ObjectPrx = IcePHP_defineProxy('::Ice::Object', null, null);
$Ice__t_ObjectProxySeq = IcePHP_defineSequence('::Ice::ObjectProxySeq', $Ice__t_ObjectPrx);

class UnknownSlicedValue extends Value
{
public $unknownTypeId;

public function __construct()
{
}

public function ice_id()
{
return $this->unknownTypeId;
}
}

global $Ice__t_UnknownSlicedValue;
$Ice__t_UnknownSlicedValue = IcePHP_defineClass('::Ice::UnknownSlicedValue', "\\Ice\\UnknownSlicedValue", -1, false,
$Ice__t_Value, null);

interface ValueFactory
{
public function create($id);
}

class InitializationData
{
public function __construct($properties=null, $logger=null)
{
$this->properties = $properties;
$this->logger = $logger;
}

public $properties;
public $logger;
}

class SlicedData
{
public $slices;
}

class SliceInfo
{
public $typeId;
public $compactId;
public $bytes;
public $instances;
public $hasOptionalMembers;
public $isLastSlice;
}

class FormatType
{
const DefaultFormat = 0;
const CompactFormat = 1;
const SlicedFormat = 2;
}
}

namespace
{
//
// Include certain generated files.
//
require_once 'Ice/BuiltinSequences.php';
require_once 'Ice/CompressBatch.php';
require_once 'Ice/ConnectionClose.php';
require_once 'Ice/EndpointSelectionType.php';
require_once 'Ice/EndpointTypes.php';
require_once 'Ice/LocalExceptions.php';
require_once 'Ice/Locator.php';
require_once 'Ice/Metrics.php';
require_once 'Ice/Process.php';
require_once 'Ice/RemoteLogger.php';
require_once 'Ice/Router.php';
require_once 'Ice/ToStringMode.php';
require_once 'Ice/Version.php';

global $Ice_Protocol_1_0;
global $Ice_Encoding_1_0;
global $Ice_Encoding_1_1;

$Ice_Protocol_1_0 = new Ice\ProtocolVersion(1, 0);
$Ice_Encoding_1_0 = new Ice\EncodingVersion(1, 0);
$Ice_Encoding_1_1 = new Ice\EncodingVersion(1, 1);

IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_isA', 2, 0, array(array($IcePHP__t_string)), null,
array($IcePHP__t_bool), null);
IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_ping', 2, 0, null, null, null, null);
IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_id', 2, 0, null, null, array($IcePHP__t_string), null);
IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_ids', 2, 0, null, null, array($Ice__t_StringSeq), null);
}

namespace Ice
{
$Protocol_1_0 = new ProtocolVersion(1, 0);
$Encoding_1_0 = new EncodingVersion(1, 0);
$Encoding_1_1 = new EncodingVersion(1, 1);

//
// 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;
}
}

namespace
{
function Ice_proxyIdentityCompare($lhs, $rhs)
{
return Ice\proxyIdentityCompare($lhs, $rhs);
}

function Ice_proxyIdentityEqual($lhs, $rhs)
{
return Ice\proxyIdentityEqual($lhs, $rhs);
}

function Ice_proxyIdentityAndFacetCompare($lhs, $rhs)
{
return Ice\proxyIdentityAndFacetCompare($lhs, $rhs);
}
// These symbols are defined by the extension but must be declared global here to ensure they are visible to scripts
// regardless of the scope in which we are currently executing.
global $IcePHP__t_bool;
global $IcePHP__t_byte;
global $IcePHP__t_short;
global $IcePHP__t_int;
global $IcePHP__t_long;
global $IcePHP__t_float;
global $IcePHP__t_double;
global $IcePHP__t_string;

global $Ice_Protocol_1_0;
global $Ice_Encoding_1_0;
global $Ice_Encoding_1_1;

require_once 'Ice/Exception.php';
require_once 'Ice/Proxy.php';
require_once 'Ice/Value.php';

require_once 'Ice/BuiltinSequences.php';
require_once 'Ice/CompressBatch.php';
require_once 'Ice/ConnectionClose.php';
require_once 'Ice/EndpointSelectionType.php';
require_once 'Ice/EndpointTypes.php';
require_once 'Ice/Identity.php';
require_once 'Ice/InitializationData.php';
require_once 'Ice/LocalExceptions.php';
require_once 'Ice/Locator.php';
require_once 'Ice/Metrics.php';
require_once 'Ice/Process.php';
require_once 'Ice/RemoteLogger.php';
require_once 'Ice/Router.php';
require_once 'Ice/ToStringMode.php';
require_once 'Ice/Version.php';

$Ice_Protocol_1_0 = new Ice\ProtocolVersion(1, 0);
$Ice_Encoding_1_0 = new Ice\EncodingVersion(1, 0);
$Ice_Encoding_1_1 = new Ice\EncodingVersion(1, 1);

IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_isA', 2, 0, array(array($IcePHP__t_string)), null,
array($IcePHP__t_bool), null);
IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_ping', 2, 0, null, null, null, null);
IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_id', 2, 0, null, null, array($IcePHP__t_string), null);
IcePHP_defineOperation($Ice__t_ObjectPrx, 'ice_ids', 2, 0, null, null, array($Ice__t_StringSeq), null);

function Ice_proxyIdentityAndFacetEqual($lhs, $rhs)
{
return Ice\proxyIdentityAndFacetEqual($lhs, $rhs);
}
}
?>
17 changes: 17 additions & 0 deletions php/lib/Ice/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

namespace Ice;

class Exception extends \Exception {}

class LocalException extends Exception {}

abstract class UserException extends Exception
{
abstract public function ice_id();
}

?>
20 changes: 20 additions & 0 deletions php/lib/Ice/InitializationData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

namespace Ice;

class InitializationData
{
public function __construct($properties=null, $logger=null)
{
$this->properties = $properties;
$this->logger = $logger;
}

public $properties;
public $logger;
}

?>
Loading

0 comments on commit 56d7676

Please sign in to comment.