Skip to content

Commit 92db184

Browse files
committed
net: Prepare to split these classes out into panda3d.net module
See panda3d#1466 - these classes are still part of panda3d.core as of 1.11, but they should really be imported from panda3d.net (they can be imported from either place in 1.11). A future release will remove them from panda3d.core entirely.
1 parent b221b49 commit 92db184

File tree

9 files changed

+66
-14
lines changed

9 files changed

+66
-14
lines changed

cmake/macros/Interrogate.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,15 @@ function(add_python_module module)
341341
# Keep command lines short
342342
file(RELATIVE_PATH workdir_rel "${CMAKE_CURRENT_BINARY_DIR}" "${workdir_abs}")
343343

344+
get_target_property(target_module "${target}" IGATE_MODULE)
345+
if(NOT target_module)
346+
set(target_module "${module}")
347+
endif()
348+
344349
interrogate_sources(${target}
345350
"${workdir_abs}/${target}_igate.cxx"
346351
"${workdir_abs}/${target}.in"
347-
"-python-native;-module;${module}")
352+
"-python-native;-module;${target_module}")
348353

349354
get_target_property(target_extensions "${target}" IGATE_EXTENSIONS)
350355
list(APPEND infiles_rel "${workdir_rel}/${target}.in")

direct/src/cluster/ClusterClient.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
from panda3d.core import (
44
ClockObject,
5-
ConnectionWriter,
65
Point3,
7-
QueuedConnectionManager,
8-
QueuedConnectionReader,
96
VBase3,
107
Vec3,
118
decomposeMatrix,
129
)
10+
from panda3d.net import (
11+
ConnectionWriter,
12+
QueuedConnectionManager,
13+
QueuedConnectionReader,
14+
)
1315
from .ClusterMsgs import (
1416
CLUSTER_DAEMON_PORT,
1517
CLUSTER_NAMED_MOVEMENT_DONE,

direct/src/cluster/ClusterMsgs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This module is intended to supply routines and dataformats common to
44
# both ClusterClient and ClusterServer.
55

6-
from panda3d.core import NetDatagram
6+
from panda3d.net import NetDatagram
77
from direct.distributed.PyDatagram import PyDatagram
88
from direct.distributed.PyDatagramIterator import PyDatagramIterator
99
import time

direct/src/cluster/ClusterServer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from panda3d.core import (
22
ClockObject,
3+
Vec3,
4+
)
5+
from panda3d.net import (
36
ConnectionWriter,
47
NetAddress,
58
PointerToConnection,
69
QueuedConnectionListener,
710
QueuedConnectionManager,
811
QueuedConnectionReader,
9-
Vec3,
1012
)
1113
from .ClusterMsgs import (
1214
CLUSTER_CAM_FRUSTUM,

direct/src/distributed/ServerRepository.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
ConfigVariableBool,
55
ConfigVariableDouble,
66
ConfigVariableInt,
7-
ConnectionWriter,
87
DatagramIterator,
98
Filename,
9+
TPLow,
10+
UniqueIdAllocator,
11+
VirtualFileSystem,
12+
getModelPath,
13+
)
14+
from panda3d.net import (
15+
ConnectionWriter,
1016
NetAddress,
1117
NetDatagram,
1218
PointerToConnection,
1319
QueuedConnectionListener,
1420
QueuedConnectionManager,
1521
QueuedConnectionReader,
16-
TPLow,
17-
UniqueIdAllocator,
18-
VirtualFileSystem,
19-
getModelPath,
2022
)
2123
from panda3d.direct import DCFile
2224
from direct.distributed.MsgTypesCMU import (

makepanda/makepanda.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,8 @@ def CreatePandaVersionFiles():
28662866
'_core.pyd', '_core.so',
28672867
'direct.py', 'direct.pyc', 'direct.pyo',
28682868
'_direct.pyd', '_direct.so',
2869-
'dtoolconfig.pyd', 'dtoolconfig.so']
2869+
'dtoolconfig.pyd', 'dtoolconfig.so',
2870+
'net.pyd', 'net.so']
28702871

28712872
for basename in del_files:
28722873
path = os.path.join(GetOutputDir(), 'panda3d', basename)
@@ -2914,6 +2915,20 @@ def CreatePandaVersionFiles():
29142915
if __debug__:
29152916
print("Warning: panda3d.dtoolconfig is deprecated, use panda3d.interrogatedb instead.")
29162917
from .interrogatedb import *
2918+
""")
2919+
2920+
# Add this for forward compatibility.
2921+
ConditionalWriteFile(GetOutputDir() + '/panda3d/net.py', """\
2922+
__all__ = 'BufferedDatagramConnection', 'Buffered_DatagramConnection', 'Connection', 'ConnectionListener', 'ConnectionManager', 'ConnectionReader', 'ConnectionWriter', 'DatagramGeneratorNet', 'DatagramSinkNet', 'Dtool_BorrowThisReference', 'Dtool_PyNativeInterface', 'NetAddress', 'NetDatagram', 'PointerToBaseConnection', 'PointerToBase_Connection', 'PointerToConnection', 'PointerTo_Connection', 'QueuedConnectionListener', 'QueuedConnectionManager', 'QueuedConnectionReader', 'QueuedReturnConnectionListenerData', 'QueuedReturnDatagram', 'QueuedReturnNetDatagram', 'QueuedReturnPointerToConnection', 'QueuedReturn_ConnectionListenerData', 'QueuedReturn_Datagram', 'QueuedReturn_NetDatagram', 'QueuedReturn_PointerTo_Connection', 'RecentConnectionReader', 'SocketAddress', 'SocketFdset', 'SocketIP', 'SocketTCP', 'SocketTCPListen', 'SocketUDP', 'SocketUDPIncoming', 'SocketUDPOutgoing', 'Socket_Address', 'Socket_IP', 'Socket_TCP', 'Socket_TCP_Listen', 'Socket_UDP', 'Socket_UDP_Incoming', 'Socket_UDP_Outgoing', 'Socket_fdset'
2923+
2924+
from . import core
2925+
2926+
scope = globals()
2927+
for name in __all__:
2928+
if hasattr(core, name):
2929+
scope[name] = getattr(core, name)
2930+
2931+
del core, scope, name
29172932
""")
29182933

29192934
# PandaModules is now deprecated; generate a shim for backward compatibility.
@@ -3904,7 +3919,7 @@ def get_config_express():
39043919
OPTS=['DIR:panda/src/nativenet']
39053920
IGATEFILES=GetDirectoryContents('panda/src/nativenet', ["*.h", "*_composite*.cxx"])
39063921
TargetAdd('libp3nativenet.in', opts=OPTS, input=IGATEFILES)
3907-
TargetAdd('libp3nativenet.in', opts=['IMOD:panda3d.core', 'ILIB:libp3nativenet', 'SRCDIR:panda/src/nativenet'])
3922+
TargetAdd('libp3nativenet.in', opts=['IMOD:panda3d.net', 'ILIB:libp3nativenet', 'SRCDIR:panda/src/nativenet'])
39083923

39093924
#
39103925
# DIRECTORY: panda/src/net/
@@ -3919,7 +3934,7 @@ def get_config_express():
39193934
IGATEFILES=GetDirectoryContents('panda/src/net', ["*.h", "*_composite*.cxx"])
39203935
IGATEFILES.remove("datagram_ui.h")
39213936
TargetAdd('libp3net.in', opts=OPTS, input=IGATEFILES)
3922-
TargetAdd('libp3net.in', opts=['IMOD:panda3d.core', 'ILIB:libp3net', 'SRCDIR:panda/src/net'])
3937+
TargetAdd('libp3net.in', opts=['IMOD:panda3d.net', 'ILIB:libp3net', 'SRCDIR:panda/src/net'])
39233938

39243939
#
39253940
# DIRECTORY: panda/src/pstatclient/

panda/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,35 @@ ${win32_init}")
135135
if __debug__:
136136
print(\"Warning: panda3d.dtoolconfig is deprecated, use panda3d.interrogatedb instead.\")
137137
from .interrogatedb import *
138+
")
139+
140+
set(net_file "__all__ = 'BufferedDatagramConnection', 'Buffered_DatagramConnection', 'Connection', 'ConnectionListener', 'ConnectionManager', 'ConnectionReader', 'ConnectionWriter', 'DatagramGeneratorNet', 'DatagramSinkNet', 'Dtool_BorrowThisReference', 'Dtool_PyNativeInterface', 'NetAddress', 'NetDatagram', 'PointerToBaseConnection', 'PointerToBase_Connection', 'PointerToConnection', 'PointerTo_Connection', 'QueuedConnectionListener', 'QueuedConnectionManager', 'QueuedConnectionReader', 'QueuedReturnConnectionListenerData', 'QueuedReturnDatagram', 'QueuedReturnNetDatagram', 'QueuedReturnPointerToConnection', 'QueuedReturn_ConnectionListenerData', 'QueuedReturn_Datagram', 'QueuedReturn_NetDatagram', 'QueuedReturn_PointerTo_Connection', 'RecentConnectionReader', 'SocketAddress', 'SocketFdset', 'SocketIP', 'SocketTCP', 'SocketTCPListen', 'SocketUDP', 'SocketUDPIncoming', 'SocketUDPOutgoing', 'Socket_Address', 'Socket_IP', 'Socket_TCP', 'Socket_TCP_Listen', 'Socket_UDP', 'Socket_UDP_Incoming', 'Socket_UDP_Outgoing', 'Socket_fdset'
141+
142+
from . import core
143+
144+
scope = globals()
145+
for name in __all__:
146+
if hasattr(core, name):
147+
scope[name] = getattr(core, name)
148+
149+
del core, scope, name
138150
")
139151
140152
if(IS_MULTICONFIG)
141153
foreach(config ${CMAKE_CONFIGURATION_TYPES})
142154
# Generate an __init__.py in the per-configuration directory.
143155
file(WRITE "${PROJECT_BINARY_DIR}/${config}/panda3d/__init__.py" ${init_file})
144156
file(WRITE "${PROJECT_BINARY_DIR}/${config}/panda3d/dtoolconfig.py" ${dtoolconfig_file})
157+
if(HAVE_NET)
158+
file(WRITE "${PROJECT_BINARY_DIR}/${config}/panda3d/net.py" ${net_file})
159+
endif()
145160
endforeach(config)
146161
else()
147162
file(WRITE "${PROJECT_BINARY_DIR}/panda3d/__init__.py" ${init_file})
148163
file(WRITE "${PROJECT_BINARY_DIR}/panda3d/dtoolconfig.py" ${dtoolconfig_file})
164+
if(HAVE_NET)
165+
file(WRITE "${PROJECT_BINARY_DIR}/${config}/panda3d/net.py" ${net_file})
166+
endif()
149167
endif()
150168
151169
# Also generate a panda3d.dist-info directory.

panda/src/nativenet/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ add_component_library(p3nativenet SYMBOL BUILDING_PANDA_NATIVENET
3737
target_link_libraries(p3nativenet p3pandabase pandaexpress)
3838
target_interrogate(p3nativenet ALL)
3939

40+
# These are temporarily built with -module panda3d.net, even though they are
41+
# still part of panda3d.core, see #1466
42+
set_target_properties(p3nativenet PROPERTIES IGATE_MODULE panda3d.net)
43+
4044
if(NOT BUILD_METALIBS)
4145
install(TARGETS p3nativenet
4246
EXPORT Core COMPONENT Core

panda/src/net/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ add_component_library(p3net SYMBOL BUILDING_PANDA_NET
3636
target_link_libraries(p3net p3nativenet p3pipeline p3pandabase pandaexpress)
3737
target_interrogate(p3net ALL)
3838

39+
# These are temporarily built with -module panda3d.net, even though they are
40+
# still part of panda3d.core, see #1466
41+
set_target_properties(p3net PROPERTIES IGATE_MODULE panda3d.net)
42+
3943
if(WIN32)
4044
target_link_libraries(p3net iphlpapi.lib)
4145
endif()

0 commit comments

Comments
 (0)