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

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 require('buffer')
0016 
0017 _object = 'new Object()'
0018 _function = 'function(){}'
0019 _buffer = 'new buffer.Buffer()'
0020 _address = '{address: "", family: "", port: 1}'
0021 
0022 Module().members(
0023     F('new Socket', 'createSocket', ('type', _string), ('callback', _function)),
0024     Class('Socket').prototype('event.EventEmitter').members(
0025         F(_void, 'send', ('buf', _buffer), ('offset', _int), ('length', _int), ('port', _int), ('address', _string), ('callback', _function)),
0026         F(_void, 'bind', ('port', _int), ('address', _string), ('callback', _function)),
0027         F(_void, 'close'),
0028         F(_address, 'address'),
0029         F(_void, 'setBroadcast', ('flag', _bool)),
0030         F(_void, 'setTTL', ('ttl', _int)),
0031         F(_void, 'setMulticastTTL', ('ttl', _int)),
0032         F(_void, 'setMulticastLoopback', ('flag', _bool)),
0033         F(_void, 'addMembership', ('multicastAddress', _string), ('multicastInterface', _string)),
0034         F(_void, 'dropMembership', ('multicastAddress', _string), ('multicastInterface', _string)),
0035         F(_void, 'unref'),
0036         F(_void, 'ref')
0037     )
0038 ).print()