Skip to content
Browse files

Testing load of SDL::Net, TCP, UDP, IPaddress

  • Loading branch information...
1 parent 7801b0f commit 66c9210dcf2ac478d13c962bc5d7b9c7663d216d @kthakore kthakore committed Dec 9, 2009
Showing with 117 additions and 31 deletions.
  1. +29 −0 Build.PL
  2. +8 −0 lib/SDL/Net.pm
  3. +3 −0 lib/SDL/Net/.gitignore
  4. +8 −0 lib/SDL/Net/IPaddress.pm
  5. +8 −0 lib/SDL/Net/TCP.pm
  6. +8 −0 lib/SDL/Net/UDP.pm
  7. +3 −2 src/Net/Net.xs
  8. +4 −2 src/Net/TCP.xs
  9. +11 −4 src/Net/UDP.xs
  10. +21 −1 src/Net/objects/IPaddress.xs
  11. +5 −0 t/00-load.t
  12. +8 −21 tools/make_XS_stub.pl
  13. +1 −1 typemap
View
29 Build.PL
@@ -298,6 +298,35 @@ my %subsystems =
},
libraries => [qw( SDL SDL_image )],
},
+ Net => {
+ file => {
+ from => 'src/Net/Net.xs',
+ to => 'lib/SDL/Net.xs',
+ },
+ libraries => [qw( SDL SDL_net )],
+ },
+ TCP => {
+ file => {
+ from => 'src/Net/TCP.xs',
+ to => 'lib/SDL/Net/TCP.xs',
+ },
+ libraries => [qw( SDL SDL_net )],
+ },
+ UDP => {
+ file => {
+ from => 'src/Net/UDP.xs',
+ to => 'lib/SDL/Net/UDP.xs',
+ },
+ libraries => [qw( SDL SDL_net )],
+ },
+
+ IPaddress => {
+ file => {
+ from => 'src/Net/objects/IPaddress.xs',
+ to => 'lib/SDL/Net/IPaddress.xs',
+ },
+ libraries => [qw( SDL SDL_net )],
+ },
);
View
8 lib/SDL/Net.pm
@@ -0,0 +1,8 @@
+package SDL::Net;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Net;
+1;
View
3 lib/SDL/Net/.gitignore
@@ -0,0 +1,3 @@
+*.c
+*.o
+*.xs
View
8 lib/SDL/Net/IPaddress.pm
@@ -0,0 +1,8 @@
+package SDL::Net::IPaddress;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Net::IPaddress;
+1;
View
8 lib/SDL/Net/TCP.pm
@@ -0,0 +1,8 @@
+package SDL::Net::TCP;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Net::TCP;
+1;
View
8 lib/SDL/Net/UDP.pm
@@ -0,0 +1,8 @@
+package SDL::Net::UDP;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Net::UDP;
+1;
View
5 src/Net/Net.xs
@@ -93,8 +93,9 @@ net_free_packetV ( packet )
CODE:
SDLNet_FreePacketV(packet);
-net_socket_set
-net_AllocSocketSet ( maxsockets )
+
+SDLNet_SocketSet
+net_alloc_socket_set ( maxsockets )
int maxsockets
CODE:
RETVAL = SDLNet_AllocSocketSet(maxsockets);
View
6 src/Net/TCP.xs
@@ -13,7 +13,7 @@
#endif
-MODULE = SDL::Net:TCP PACKAGE = SDL::Net::TCP PREFIX = net_TCP_
+MODULE = SDL::Net::TCP PACKAGE = SDL::Net::TCP PREFIX = net_TCP_
#ifdef HAVE_SDL_NET
@@ -36,6 +36,8 @@ net_TCP_accept ( server )
IPaddress*
net_TCP_get_peer_address ( sock )
TCPsocket sock
+ PREINIT:
+ char* CLASS = "SDL::IPaddress";
CODE:
RETVAL = SDLNet_TCP_GetPeerAddress(sock);
OUTPUT:
@@ -59,7 +61,7 @@ net_TCP_recv ( sock, maxlen )
int status;
void *buffer;
buffer = safemalloc(maxlen);
- RETVAL = sv_2mortal((SV*)newAV());
+ RETVAL = (AV*)sv_2mortal((SV*)newAV());
status = SDLNet_TCP_Recv(sock,buffer,maxlen);
av_push(RETVAL,newSViv(status));
av_push(RETVAL,newSVpvn((char*)buffer,maxlen));
View
15 src/Net/UDP.xs
@@ -13,7 +13,10 @@
#endif
-MODULE = SDL::Net:UDP PACKAGE = SDL::Net::UDP PREFIX = net_UDP_
+MODULE = SDL::Net::UDP PACKAGE = SDL::Net::UDP PREFIX = net_UDP_
+
+#ifdef HAVE_SDL_NET
+
UDPsocket
net_UDP_open ( port )
@@ -44,13 +47,15 @@ IPaddress*
net_UDP_get_peer_address ( sock, channel )
UDPsocket sock
int channel
+ PREINIT:
+ char* CLASS = "SDL::IPaddress";
CODE:
RETVAL = SDLNet_UDP_GetPeerAddress(sock,channel);
OUTPUT:
RETVAL
-
-net_UDP_sendV ( sock, packets, npackets )
+int
+net_UDP_sendV( sock, packets, npackets )
UDPsocket sock
UDPpacket **packets
int npackets
@@ -59,6 +64,7 @@ net_UDP_sendV ( sock, packets, npackets )
OUTPUT:
RETVAL
+
int
net_UDP_send ( sock, channel, packet )
UDPsocket sock
@@ -102,6 +108,7 @@ net_UDP_add_socket ( set, sock )
RETVAL = SDLNet_UDP_AddSocket(set,sock);
OUTPUT:
RETVAL
+
int
net_UDP_del_socket ( set, sock )
SDLNet_SocketSet set
@@ -111,5 +118,5 @@ net_UDP_del_socket ( set, sock )
OUTPUT:
RETVAL
-#endif
+#endif
View
22 src/Net/objects/IPaddress.xs
@@ -1,3 +1,18 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+#ifdef HAVE_SDL_NET
+#include <SDL_net.h>
+#endif
+
+
=for docs
IPaddress
@@ -18,9 +33,12 @@ This type contains the information used to form network connections and sockets.
MODULE = SDL::Net::IPaddress PACKAGE = SDL::Net::IPaddress PREFIX = netip_
+#ifdef HAVE_SDL_NET
+
IPaddress*
-netip_new ( host, port )
+netip_new (CLASS, host, port )
+ char* CLASS
Uint32 host
Uint16 port
CODE:
@@ -53,3 +71,5 @@ netip_DESTROY ( ip )
safefree(ip);
+#endif
+
View
5 t/00-load.t
@@ -39,6 +39,11 @@ SDL::GFX::ImageFilter
SDL::GFX::Primitives
SDL::GFX::Rotozoom
SDL::Image
+
+SDL::Net
+SDL::Net::TCP
+SDL::Net::UDP
+SDL::Net::IPaddress
/;
plan tests => scalar @modules;
View
29 tools/make_XS_stub.pl
@@ -1,35 +1,22 @@
-my @files = qw/
-ActiveEvent
-KeyboardEvent
-TextInputEvent
-MouseMotionEvent
-MouseButtonEvent
-JoyAxisEvent
-JoyHatEvent
-JoyButtonEvent
-JoyBallEvent
-ResizeEvent
-ExposeEvent
-SysWMEvent
-UserEvent
-QuitEvent
-keysym
-/;
+@files = @ARGV;
foreach (@files)
{
+ my $filename = $_;
my $file = $_;
- my $fn = $file.'.pm';
- open FH, ">$fn";
+ $filename =~ s/\:\:/\//g;
+ $filename = 'lib/'.$filename.'.pm';
+ print "Writing to $filename \n";
+ open FH, ">$filename" or die 'Error '.$!;
print FH
-"package SDL::$file;
+"package $file;
use strict;
use warnings;
require Exporter;
require DynaLoader;
our \@ISA = qw(Exporter DynaLoader);
-bootstrap SDL::$file;
+bootstrap $file;
1;";
close FH;
}
View
2 typemap
@@ -65,7 +65,7 @@ TCPsocket T_PTR
UDPsocket T_PTR
UDPpacket * T_PTR
UDPpacket ** T_PTR
-IPaddress* T_PTR
+IPaddress* O_OBJECT
SDLNet_GenericSocket T_PTR
TTF_Font * O_OBJECT
SDL_Overlay * O_OBJECT

0 comments on commit 66c9210

Please sign in to comment.
Something went wrong with that request. Please try again.