Changeset 21253

Show
Ignore:
Timestamp:
10/13/08 21:15:57 (5 years ago)
Author:
tokuhirom
Message:

added some methods
- ntohl
- ntohs
- htonl
- htons

Location:
lang/cplusplus/llv8call/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/cplusplus/llv8call/trunk/ext/socket/socket.cc

    r21249 r21253  
    462462END 
    463463 
     464FUNCTION(_ntohl) 
     465    ARG_COUNT(1); 
     466    ARG_int(n, 0); 
     467    return Uint32::New(ntohl(n)); 
     468END 
     469 
     470FUNCTION(_ntohs) 
     471    ARG_COUNT(1); 
     472    ARG_int(n, 0); 
     473    return Uint32::New(ntohs(n)); 
     474END 
     475 
     476FUNCTION(_htons) 
     477    ARG_COUNT(1); 
     478    ARG_int(n, 0); 
     479    return Uint32::New(htons(n)); 
     480END 
     481 
     482FUNCTION(_htonl) 
     483    ARG_COUNT(1); 
     484    ARG_int(n, 0); 
     485    return Uint32::New(htonl(n)); 
     486END 
     487 
    464488MODULE() 
    465489    { 
     
    482506        BIND_CM("inet_ntoa",      _inet_ntoa); 
    483507        BIND_CM("socketpair",     _socketpair); 
     508        BIND_CM("ntohl",          _ntohl); 
     509        BIND_CM("ntohs",          _ntohs); 
     510        BIND_CM("htons",          _htons); 
     511        BIND_CM("htonl",          _htonl); 
    484512 
    485513        BIND_IM("bind",           _bind); 
     
    504532        // getservbyname 
    505533        // getservbyport 
    506         // socketpair 
    507534        // fromfd 
    508         // ntohl 
    509         // ntohs 
    510         // htonl 
    511         // htons 
    512535        // inet_pton 
    513536        // inet_ntop 
  • lang/cplusplus/llv8call/trunk/t/100_socket/02_misc.js

    r21202 r21253  
    11require('t/util.js'); 
    22 
    3 plan({tests:3}); 
     3plan({tests:7}); 
    44 
    55check_lib("org.coderepos.socket"); 
     
    99is(Socket.inet_aton("127.0.0.1"), (1 << 24) + 127, 'inet_aton'); 
    1010is(Socket.inet_ntoa((1<<24) + 127), "127.0.0.1", 'inet_ntoa'); 
     11is(Socket.ntohs(0xabcd), 0xcdab, 'ntohs'); 
     12is(Socket.htons(0xabcd), 0xcdab, 'htons'); 
     13is(Socket.htonl(0xdeadbe0f), 0x0fbeadde, 'htonl'); 
     14is(Socket.ntohl(0xdeadbe0f), 0x0fbeadde, 'htonl'); 
    1115