Skip to content

Commit

Permalink
Bugfix for new cython version
Browse files Browse the repository at this point in the history
  • Loading branch information
Egil committed Apr 13, 2024
1 parent 0ee8613 commit a7e41f8
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 147 deletions.
79 changes: 49 additions & 30 deletions pysmlib/pysmlib/client.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import traceback
from libc.stdlib cimport malloc, free
import os
from pysmlib.SMlib cimport *
Expand All @@ -9,36 +10,54 @@ SmcDieProcMask = (1L << 1)
SmcSaveCompleteProcMask = (1L << 2)
SmcShutdownCancelledProcMask = (1L << 3)

cdef void save_yourself_wrapper(SmcConn smc_conn, SmPointer client_data, int save_type, Bool shutdown, int interact_style, Bool fast):
print("save_yourself_wrapper")
self = <PySmcConn> client_data
self.signal_save_yourself(save_type, shutdown, interact_style, fast)

cdef void die_wrapper(SmcConn smcConn, SmPointer client_data):
print("die_wrapper")
self = <PySmcConn> client_data
self.signal_die()

cdef void shutdown_cancelled_wrapper(SmcConn smcConn, SmPointer client_data):
print("shutdown_cancelled_wrapper")
self = <PySmcConn> client_data
self.signal_shutdown_cancelled()

cdef void save_complete_wrapper(SmcConn smcConn, SmPointer client_data):
self = <PySmcConn> client_data
self.signal_save_complete()

cdef void save_yourself_phase2_wrapper(SmcConn smcConn, SmPointer client_data):
data = <PySmcConn> client_data
(self, proc) = data
proc()
del self.refs[id(data)]

cdef void prop_reply_proc_wrapper(SmcConn smcConn, SmPointer client_data, int numProps, SmProp **props):
data = <PySmcConn> client_data
(self, proc) = data
proc(smprops_to_dict(numProps, props))
del self.refs[id(data)]
cdef void save_yourself_wrapper(SmcConn smc_conn, SmPointer client_data, int save_type, Bool shutdown, int interact_style, Bool fast) noexcept:
try:
print("save_yourself_wrapper")
self = <PySmcConn> client_data
self.signal_save_yourself(save_type, shutdown, interact_style, fast)
except Exception as e:
traceback.print_exc()

cdef void die_wrapper(SmcConn smcConn, SmPointer client_data) noexcept:
try:
print("die_wrapper")
self = <PySmcConn> client_data
self.signal_die()
except Exception as e:
traceback.print_exc()

cdef void shutdown_cancelled_wrapper(SmcConn smcConn, SmPointer client_data) noexcept:
try:
print("shutdown_cancelled_wrapper")
self = <PySmcConn> client_data
self.signal_shutdown_cancelled()
except Exception as e:
traceback.print_exc()

cdef void save_complete_wrapper(SmcConn smcConn, SmPointer client_data) noexcept:
try:
self = <PySmcConn> client_data
self.signal_save_complete()
except Exception as e:
traceback.print_exc()

cdef void save_yourself_phase2_wrapper(SmcConn smcConn, SmPointer client_data) noexcept:
try:
data = <PySmcConn> client_data
(self, proc) = data
proc()
del self.refs[id(data)]
except Exception as e:
traceback.print_exc()

cdef void prop_reply_proc_wrapper(SmcConn smcConn, SmPointer client_data, int numProps, SmProp **props) noexcept:
try:
data = <PySmcConn> client_data
(self, proc) = data
proc(smprops_to_dict(numProps, props))
del self.refs[id(data)]
except Exception as e:
traceback.print_exc()

cdef class PySmcConn(object):
cdef SmcConn conn
Expand Down
38 changes: 24 additions & 14 deletions pysmlib/pysmlib/ice.pyx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import traceback
from libc.stdlib cimport *
from libc.string cimport *
from pysmlib.SMlib cimport *
from pysmlib.ice cimport *
import sys

cdef void ice_ping_reply_wrapper(IceConn ice_conn, IcePointer client_data):
data = <tuple> client_data
self, method = data
method()
del self.refs[id(data)]
cdef void ice_ping_reply_wrapper(IceConn ice_conn, IcePointer client_data) noexcept:
try:
data = <tuple> client_data
self, method = data
method()
del self.refs[id(data)]
except Exception as e:
traceback.print_exc()

open_connections = {}
error_handler_installed = False
Expand All @@ -20,15 +24,21 @@ cdef void ice_error_handler_wrapper(IceConn ice_conn,
unsigned long offendingSequence,
int errorClass,
int severity,
IcePointer values):
open_connections[<long>ice_conn].error_handler(swap,
offendingMinorOpcode,
offendingSequence,
errorClass,
severity)

cdef void ice_io_error_handler_wrapper(IceConn ice_conn):
open_connections[<long>ice_conn].io_error_handler()
IcePointer values) noexcept:
try:
open_connections[<long>ice_conn].error_handler(swap,
offendingMinorOpcode,
offendingSequence,
errorClass,
severity)
except Exception as e:
traceback.print_exc()

cdef void ice_io_error_handler_wrapper(IceConn ice_conn) noexcept:
try:
open_connections[<long>ice_conn].io_error_handler()
except Exception as e:
traceback.print_exc()

cdef class PyIceConn(object):
cdef PyIceConn init(self, IceConn conn):
Expand Down
Loading

0 comments on commit a7e41f8

Please sign in to comment.