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('stream')
0015 require('buffer')
0016 require('event')
0017 
0018 _function = 'function(){}'
0019 _object = 'new Object()'
0020 _date = 'new Date()'
0021 _buffer = 'new buffer.Buffer()'
0022 _stats = 'new Stats'
0023 _callback = ('callback', _function)
0024 _fd = ('fd', _int)
0025 _len = ('len', _int)
0026 _path = ('path', _string)
0027 _uid = ('uid', _int)
0028 _gid = ('gid', _int)
0029 _mode = ('mode', _int)
0030 _offset = ('offset', _int)
0031 _length = ('length', _int)
0032 _position = ('position', _int)
0033 _filename = ('filename', _string)
0034 _options = ('options', _object)
0035 _data = ('data', _string)
0036 
0037 Module().members(
0038     F(_void, 'rename', ('oldPath', _string), ('newPath', _string), _callback),
0039     F(_int, 'renameSync', ('oldPath', _string), ('newPath', _string)),
0040     F(_void, 'ftruncate', _fd, _len, _callback),
0041     F(_int, 'ftruncateSync', _fd, _len),
0042     F(_void, 'truncate', _path, _len, _callback),
0043     F(_int, 'truncateSync', _path, _len),
0044     F(_void, 'chown', _path, _uid, _gid, _callback),
0045     F(_int, 'chownSync', _path, _uid, _gid),
0046     F(_void, 'fchown', _fd, _uid, _gid, _callback),
0047     F(_int, 'fchownSync', _fd, _uid, _gid),
0048     F(_void, 'lchown', _path, _uid, _gid, _callback),
0049     F(_int, 'lchownSync', _path, _uid, _gid),
0050     F(_void, 'chmod', _path, _mode, _callback),
0051     F(_int, 'chmodSync', _path, _mode),
0052     F(_void, 'fchmod', _fd, _mode, _callback),
0053     F(_int, 'fchmodSync', _fd, _mode),
0054     F(_void, 'lchmod', _path, _mode, _callback),
0055     F(_int, 'lchmodSync', _path, _mode),
0056     F(_void, 'stat', _path, _callback),
0057     F(_void, 'lstat', _path, _callback),
0058     F(_void, 'fstat', _fd, _callback),
0059     F(_stats, 'statSync', _path),
0060     F(_stats, 'lstatSync', _path),
0061     F(_stats, 'fstatSync', _fd),
0062     F(_void, 'link', ('srcpath', _string), ('dstpath', _string), _callback),
0063     F(_int, 'linkSync', ('srcpath', _string), ('dstpath', _string)),
0064     F(_void, 'symlink', ('srcpath', _string), ('dstpath', _string), ('type', _string), _callback),
0065     F(_int, 'symlinkSync', ('srcpath', _string), ('dstpath', _string), ('type', _string)),
0066     F(_void, 'readlink', _path, _callback),
0067     F(_int, 'readlinkSync', _path),
0068     F(_void, 'realpath', _path, ('cache', _object), _callback),
0069     F(_string, 'realpathSync', _path, ('cache', _object)),
0070     F(_void, 'unlink', _path, _callback),
0071     F(_int, 'unlinkSync', _path),
0072     F(_void, 'rmdir', _path, _callback),
0073     F(_int, 'rmdirSync', _path),
0074     F(_void, 'mkdir', _path, _mode, _callback),
0075     F(_int, 'mkdirSync', _path, _mode),
0076     F(_void, 'readdir', _path, _callback),
0077     F(_array, 'readdirSync', _path),
0078     F(_void, 'close', _fd, _callback),
0079     F(_int, 'closeSync', _fd),
0080     F(_void, 'open', _path, ('flags', _string), _mode, _callback),
0081     F(_int, 'openSync', _path, ('flags', _string), _mode),
0082     F(_void, 'utimes', _path, ('atime', _date), ('mtime', _date), _callback),
0083     F(_int, 'utimesSync', _path, ('atime', _date), ('mtime', _date)),
0084     F(_void, 'futimes', _fd, ('atime', _date), ('mtime', _date), _callback),
0085     F(_int, 'futimesSync', _fd, ('atime', _date), ('mtime', _date)),
0086     F(_void, 'fsync', _fd, _callback),
0087     F(_int, 'fsyncSync', _fd),
0088     F(_void, 'write', _fd, _buffer, _offset, _length, _position, _callback),
0089     F(_int, 'writeSync', _fd, _buffer, _offset, _length, _position),
0090     F(_void, 'read', _fd, _buffer, _offset, _length, _position, _callback),
0091     F(_int, 'readSync', _fd, _buffer, _offset, _length, _position),
0092     F(_void, 'readFile', _filename, _options, _callback),
0093     F(_int, 'readFileSync', _filename, _options),
0094     F(_void, 'writeFile', _filename, _data, _options, _callback),
0095     F(_int, 'writeFileSync', _filename, _data, _options),
0096     F(_void, 'appendFile', _filename, _data, _options, _callback),
0097     F(_int, 'appendFileSync', _filename, _data, _options),
0098     F(_void, 'watchFile', _filename, _options, _callback),
0099     F(_void, 'unwatchFile', _filename, _callback),
0100     F('new FSWatcher()', 'watch', _filename, _options, _callback),
0101     F(_void, 'exists', _path, _callback),
0102     F(_bool, 'existsSync', _path),
0103     Class('Stats').members(
0104         F(_bool, 'isFile'),
0105         F(_bool, 'isDirectory'),
0106         F(_bool, 'isBlockDevice'),
0107         F(_bool, 'isCharacterDevice'),
0108         F(_bool, 'isSymbolicLink'),
0109         F(_bool, 'isFIFO'),
0110         F(_bool, 'isSocket'),
0111         Var(_int, 'dev'),
0112         Var(_int, 'ino'),
0113         Var(_int, 'mode'),
0114         Var(_int, 'nlink'),
0115         Var(_int, 'uid'),
0116         Var(_int, 'gid'),
0117         Var(_int, 'rdev'),
0118         Var(_int, 'size'),
0119         Var(_int, 'blksize'),
0120         Var(_int, 'blocks'),
0121         Var(_date, 'atime'),
0122         Var(_date, 'mtime'),
0123         Var(_date, 'ctime')
0124     ),
0125     F('new ReadStream()', 'createReadStream', _path, _options),
0126     Class('ReadStream').prototype('stream.Readable'),
0127     F('new WriteStream()', 'createWriteStream', _path, _options),
0128     Class('WriteStream').prototype('stream.Writable'),
0129     Class('FSWatcher').prototype('event.EventEmitter').members(
0130         F(_void, 'close')
0131     )
0132 ).print()