Skip to content

Commit

Permalink
Fix Ruby and PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Apr 19, 2024
1 parent de618bf commit d804580
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 410 deletions.
61 changes: 0 additions & 61 deletions php/lib/IceLocal/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,67 +63,6 @@ public function heartbeat($con);
$Ice__t_HeartbeatCallback = IcePHP_defineClass('::Ice::HeartbeatCallback', '\\Ice\\HeartbeatCallback', -1, true, null, null);
}

namespace Ice
{
global $Ice__t_ACMClose;
class ACMClose
{
const CloseOff = 0;
const CloseOnIdle = 1;
const CloseOnInvocation = 2;
const CloseOnInvocationAndIdle = 3;
const CloseOnIdleForceful = 4;
}

$Ice__t_ACMClose = IcePHP_defineEnum('::Ice::ACMClose', array('CloseOff', 0, 'CloseOnIdle', 1, 'CloseOnInvocation', 2, 'CloseOnInvocationAndIdle', 3, 'CloseOnIdleForceful', 4));
}

namespace Ice
{
global $Ice__t_ACMHeartbeat;
class ACMHeartbeat
{
const HeartbeatOff = 0;
const HeartbeatOnDispatch = 1;
const HeartbeatOnIdle = 2;
const HeartbeatAlways = 3;
}

$Ice__t_ACMHeartbeat = IcePHP_defineEnum('::Ice::ACMHeartbeat', array('HeartbeatOff', 0, 'HeartbeatOnDispatch', 1, 'HeartbeatOnIdle', 2, 'HeartbeatAlways', 3));
}

namespace Ice
{
global $Ice__t_ACM;
class ACM
{
public function __construct($timeout=0, $close=\Ice\ACMClose::CloseOff, $heartbeat=\Ice\ACMHeartbeat::HeartbeatOff)
{
$this->timeout = $timeout;
$this->close = $close;
$this->heartbeat = $heartbeat;
}

public function __toString(): string
{
global $Ice__t_ACM;
return IcePHP_stringify($this, $Ice__t_ACM);
}

public $timeout;
public $close;
public $heartbeat;
}

global $IcePHP__t_int;
global $Ice__t_ACMClose;
global $Ice__t_ACMHeartbeat;
$Ice__t_ACM = IcePHP_defineStruct('::Ice::ACM', '\\Ice\\ACM', array(
array('timeout', $IcePHP__t_int),
array('close', $Ice__t_ACMClose),
array('heartbeat', $Ice__t_ACMHeartbeat)));
}

namespace Ice
{
global $Ice__t_ConnectionClose;
Expand Down
127 changes: 13 additions & 114 deletions php/src/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,103 +175,6 @@ ZEND_METHOD(Ice_Connection, heartbeat)
}
}

ZEND_BEGIN_ARG_INFO_EX(Ice_Connection_setACM_arginfo, 1, ZEND_RETURN_VALUE, static_cast<zend_ulong>(3))
ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, close)
ZEND_ARG_INFO(0, heartbeat)
ZEND_END_ARG_INFO()

ZEND_METHOD(Ice_Connection, setACM)
{
Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis());
assert(_this);

zval* t;
zval* c;
zval* h;
if (zend_parse_parameters(ZEND_NUM_ARGS(), const_cast<char*>("zzz"), &t, &c, &h) != SUCCESS)
{
RETURN_NULL();
}

optional<int32_t> timeout;
optional<Ice::ACMClose> close;
optional<Ice::ACMHeartbeat> heartbeat;

if (!isUnset(t))
{
if (Z_TYPE_P(t) != IS_LONG)
{
invalidArgument("value for 'timeout' argument must be Unset or an integer");
RETURN_NULL();
}
timeout = static_cast<int32_t>(Z_LVAL_P(t));
}

if (!isUnset(c))
{
if (Z_TYPE_P(c) != IS_LONG)
{
invalidArgument("value for 'close' argument must be Unset or an enumerator of ACMClose");
RETURN_NULL();
}
close = static_cast<Ice::ACMClose>(Z_LVAL_P(c));
}

if (!isUnset(h))
{
if (Z_TYPE_P(h) != IS_LONG)
{
invalidArgument("value for 'heartbeat' argument must be Unset or an enumerator of ACMHeartbeat");
RETURN_NULL();
}
heartbeat = static_cast<Ice::ACMHeartbeat>(Z_LVAL_P(h));
}

try
{
_this->setACM(timeout, close, heartbeat);
}
catch (...)
{
throwException(current_exception());
RETURN_NULL();
}
}

ZEND_METHOD(Ice_Connection, getACM)
{
if (ZEND_NUM_ARGS() > 0)
{
WRONG_PARAM_COUNT;
}

Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis());
assert(_this);

try
{
Ice::ACM acm = _this->getACM();

zend_class_entry* acmClass = idToClass("::Ice::ACM");

if (object_init_ex(return_value, const_cast<zend_class_entry*>(acmClass)) != SUCCESS)
{
runtimeError("unable to initialize object of type %s", acmClass->name);
RETURN_NULL();
}

add_property_long(return_value, "timeout", static_cast<long>(acm.timeout));
add_property_long(return_value, "close", static_cast<long>(acm.close));
add_property_long(return_value, "heartbeat", static_cast<long>(acm.heartbeat));
}
catch (...)
{
throwException(current_exception());
RETURN_NULL();
}
}

ZEND_METHOD(Ice_Connection, type)
{
if (ZEND_NUM_ARGS() > 0)
Expand Down Expand Up @@ -440,23 +343,19 @@ static zend_function_entry _connectionClassMethods[] = {
__toString,
ice_to_string_arginfo,
ZEND_ACC_PUBLIC) ZEND_ME(Ice_Connection, close, Ice_Connection_close_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getEndpoint, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, flushBatchRequests, Ice_Connection_flushBatchRequests_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, heartbeat, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, setACM, Ice_Connection_setACM_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getACM, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, type, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, timeout, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, toString, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getInfo, ice_void_arginfo, ZEND_ACC_PUBLIC) ZEND_ME(
Ice_Connection,
setBufferSize,
Ice_Connection_setBufferSize_arginfo,
ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, throwException, ice_void_arginfo, ZEND_ACC_PUBLIC){
0,
0,
0}};
ZEND_ME(Ice_Connection, getEndpoint, ice_void_arginfo, ZEND_ACC_PUBLIC) ZEND_ME(
Ice_Connection,
flushBatchRequests,
Ice_Connection_flushBatchRequests_arginfo,
ZEND_ACC_PUBLIC) ZEND_ME(Ice_Connection, heartbeat, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, type, ice_void_arginfo, ZEND_ACC_PUBLIC) ZEND_ME(
Ice_Connection,
timeout,
ice_void_arginfo,
ZEND_ACC_PUBLIC) ZEND_ME(Ice_Connection, toString, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getInfo, ice_void_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, setBufferSize, Ice_Connection_setBufferSize_arginfo, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, throwException, ice_void_arginfo, ZEND_ACC_PUBLIC){0, 0, 0}};

ZEND_METHOD(Ice_ConnectionInfo, __construct) { runtimeError("ConnectionInfo cannot be instantiated"); }

Expand Down
142 changes: 0 additions & 142 deletions ruby/ruby/IceLocal/Connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,148 +111,6 @@ def initialize(underlying=nil, incoming=false, adapterName='', connectionId='')
T_HeartbeatCallback = ::Ice::__declareLocalClass('::Ice::HeartbeatCallback')
end

if not defined?(::Ice::ACMClose)
class ACMClose
include Comparable

def initialize(name, value)
@name = name
@value = value
end

def ACMClose.from_int(val)
@@_enumerators[val]
end

def to_s
@name
end

def to_i
@value
end

def <=>(other)
other.is_a?(ACMClose) or raise ArgumentError, "value must be a ACMClose"
@value <=> other.to_i
end

def hash
@value.hash
end

def ACMClose.each(&block)
@@_enumerators.each_value(&block)
end

CloseOff = ACMClose.new("CloseOff", 0)
CloseOnIdle = ACMClose.new("CloseOnIdle", 1)
CloseOnInvocation = ACMClose.new("CloseOnInvocation", 2)
CloseOnInvocationAndIdle = ACMClose.new("CloseOnInvocationAndIdle", 3)
CloseOnIdleForceful = ACMClose.new("CloseOnIdleForceful", 4)

@@_enumerators = {0=>CloseOff, 1=>CloseOnIdle, 2=>CloseOnInvocation, 3=>CloseOnInvocationAndIdle, 4=>CloseOnIdleForceful}

def ACMClose._enumerators
@@_enumerators
end

private_class_method :new
end

T_ACMClose = ::Ice::__defineEnum('::Ice::ACMClose', ACMClose, ACMClose::_enumerators)
end

if not defined?(::Ice::ACMHeartbeat)
class ACMHeartbeat
include Comparable

def initialize(name, value)
@name = name
@value = value
end

def ACMHeartbeat.from_int(val)
@@_enumerators[val]
end

def to_s
@name
end

def to_i
@value
end

def <=>(other)
other.is_a?(ACMHeartbeat) or raise ArgumentError, "value must be a ACMHeartbeat"
@value <=> other.to_i
end

def hash
@value.hash
end

def ACMHeartbeat.each(&block)
@@_enumerators.each_value(&block)
end

HeartbeatOff = ACMHeartbeat.new("HeartbeatOff", 0)
HeartbeatOnDispatch = ACMHeartbeat.new("HeartbeatOnDispatch", 1)
HeartbeatOnIdle = ACMHeartbeat.new("HeartbeatOnIdle", 2)
HeartbeatAlways = ACMHeartbeat.new("HeartbeatAlways", 3)

@@_enumerators = {0=>HeartbeatOff, 1=>HeartbeatOnDispatch, 2=>HeartbeatOnIdle, 3=>HeartbeatAlways}

def ACMHeartbeat._enumerators
@@_enumerators
end

private_class_method :new
end

T_ACMHeartbeat = ::Ice::__defineEnum('::Ice::ACMHeartbeat', ACMHeartbeat, ACMHeartbeat::_enumerators)
end

if not defined?(::Ice::ACM)
class ACM
include ::Ice::Inspect_mixin
def initialize(timeout=0, close=::Ice::ACMClose::CloseOff, heartbeat=::Ice::ACMHeartbeat::HeartbeatOff)
@timeout = timeout
@close = close
@heartbeat = heartbeat
end

def hash
_h = 0
_h = 5 * _h + @timeout.hash
_h = 5 * _h + @close.hash
_h = 5 * _h + @heartbeat.hash
_h % 0x7fffffff
end

def ==(other)
return false if !other.is_a? ::Ice::ACM or
@timeout != other.timeout or
@close != other.close or
@heartbeat != other.heartbeat
true
end

def eql?(other)
return other.class == self.class && other == self
end

attr_accessor :timeout, :close, :heartbeat
end

T_ACM = ::Ice::__defineStruct('::Ice::ACM', ACM, [
["timeout", ::Ice::T_int],
["close", ::Ice::T_ACMClose],
["heartbeat", ::Ice::T_ACMHeartbeat]
])
end

if not defined?(::Ice::ConnectionClose)
class ConnectionClose
include Comparable
Expand Down
Loading

0 comments on commit d804580

Please sign in to comment.