File indexing completed on 2024-05-19 04:42:04

0001 #!/usr/bin/env python3
0002 # -*- coding: utf-8 -*-
0003 #
0004 # SPDX-FileCopyrightText: 2014 Denis Steckelmacher <steckdenis@yahoo.fr>
0005 #
0006 # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007 
0008 from jsgenerator import *
0009 from common import *
0010 
0011 # Print the license of the generated file (the same as the one of this file)
0012 license()
0013 basicTypes(globals())
0014 require('event')
0015 
0016 _function = 'function(){}'
0017 _object = 'new Object()'
0018 _date = 'new Date()'
0019 _socket = 'new Socket()'
0020 _server = 'new Server()'
0021 _address = '{port: 1, family: "", address: ""}'
0022 
0023 Module().members(
0024     F(_server, 'createServer', ('options', _object), ('connectionListener', _function)),
0025     F(_socket, 'connect', ('options', _object), ('connectionListener', _function)),
0026     F(_socket, 'createConnection', ('options', _object), ('connectionListener', _function)),
0027     Class('Server').prototype('event.EventEmitter').members(
0028         F(_void, 'listen', ('port', _int), ('host', _string), ('backlog', _int), ('callback', _function)),
0029         F(_void, 'close', ('callback', _function)),
0030         F(_address, 'address'),
0031         F(_void, 'unref'),
0032         F(_void, 'ref'),
0033         Var(_int, 'maxConnections'),
0034         Var(_int, 'connections'),
0035         F(_void, 'getConnections', ('callback', _function))
0036     ),
0037     Class('Socket', ('options', _object)).prototype('event.EventEmitter').members(
0038         F(_void, 'connect', ('port', _int), ('host', _string), ('connectionListener', _function)),
0039         Var(_int, 'bufferSize'),
0040         F(_void, 'setEncoding', ('encoding', _string)),
0041         F(_void, 'write', ('data', _string), ('encoding', _string), ('callback', _function)),
0042         F(_void, 'end', ('data', _string), ('encoding', _string)),
0043         F(_void, 'destroy'),
0044         F(_void, 'pause'),
0045         F(_void, 'resume'),
0046         F(_void, 'setTimeout', ('timeout', _int), ('callback', _function)),
0047         F(_void, 'setNoDelay', ('noDelay', _bool)),
0048         F(_void, 'setKeepAlive', ('enable', _bool), ('initialDelay', _int)),
0049         F(_address, 'address'),
0050         F(_void, 'unref'),
0051         F(_void, 'ref'),
0052         Var(_string, 'remoteAddress'),
0053         Var(_int, 'remotePort'),
0054         Var(_string, 'localAddress'),
0055         Var(_int, 'localPort'),
0056         Var(_int, 'bytesRead'),
0057         Var(_int, 'bytesWritten')
0058     ),
0059     F(_int, 'isIP', ('input', _string)),
0060     F(_bool, 'isIPv4', ('input', _string)),
0061     F(_bool, 'isIPv6', ('input', _string))
0062 ).print()