mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add builtin exception for builtins.pyi
This commit is contained in:
parent
794392244e
commit
e536665ff6
@ -1,143 +1,181 @@
|
|||||||
from PikaObj import *
|
from PikaObj import *
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def int(arg: any, *base) -> int: ...
|
def int(arg: any, *base) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bool(arg: any) -> bool: ...
|
def bool(arg: any) -> bool: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def float(arg: any) -> float: ...
|
def float(arg: any) -> float: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def str(arg: any) -> str: ...
|
def str(arg: any) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def iter(arg: any) -> any: ...
|
def iter(arg: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def range(*ax) -> any: ...
|
def range(*ax) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def print(*val, **ops): ...
|
def print(*val, **ops): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __setitem__(obj: any, key: any, val: any) -> any: ...
|
def __setitem__(obj: any, key: any, val: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __getitem__(obj: any, key: any) -> any: ...
|
def __getitem__(obj: any, key: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def type(arg: any) -> any: ...
|
def type(arg: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def isinstance(object: any, classinfo: any) -> bool: ...
|
def isinstance(object: any, classinfo: any) -> bool: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def len(arg: any) -> int: ...
|
def len(arg: any) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
||||||
def list(*val) -> any: ...
|
def list(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
||||||
def dict(*val) -> any: ...
|
def dict(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
||||||
def tuple(arg: any) -> any: ...
|
def tuple(arg: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def hex(val: int) -> str: ...
|
def hex(val: int) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def ord(val: str) -> int: ...
|
def ord(val: str) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def chr(val: int) -> str: ...
|
def chr(val: int) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def bytes(val: any) -> bytes: ...
|
def bytes(val: any) -> bytes: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_SYNTAX_FORMAT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_SYNTAX_FORMAT_ENABLE")
|
||||||
def cformat(fmt: str, *var) -> str: ...
|
def cformat(fmt: str, *var) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def id(obj: any) -> int: ...
|
def id(obj: any) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_FILEIO_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_FILEIO_ENABLE")
|
||||||
def open(path: str, mode: str) -> object: ...
|
def open(path: str, mode: str) -> object: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def dir(obj: any) -> list: ...
|
def dir(obj: any) -> list: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
||||||
def exec(code: str): ...
|
def exec(code: str): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
||||||
def eval(code: str) -> any: ...
|
def eval(code: str) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def getattr(obj: object, name: str) -> any: ...
|
def getattr(obj: object, name: str) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def setattr(obj: object, name: str, val: any): ...
|
def setattr(obj: object, name: str, val: any): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def hasattr(obj: object, name: str) -> int: ...
|
def hasattr(obj: object, name: str) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def exit(): ...
|
def exit(): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def input(*info) -> str: ...
|
def input(*info) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def abs(val: any) -> any: ...
|
def abs(val: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def max(*val) -> any: ...
|
def max(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def min(*val) -> any: ...
|
def min(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def help(name: str): ...
|
def help(name: str): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def reboot(): ...
|
def reboot(): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def clear(): ...
|
def clear(): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_GC_MARK_SWEEP_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_GC_MARK_SWEEP_ENABLE")
|
||||||
def gcdump(): ...
|
def gcdump(): ...
|
||||||
|
|
||||||
|
|
||||||
@PIKA_C_MACRO_IF("0")
|
@PIKA_C_MACRO_IF("0")
|
||||||
class RangeObj:
|
class RangeObj:
|
||||||
def __next__(self) -> any: ...
|
def __next__(self) -> any: ...
|
||||||
@ -146,3 +184,267 @@ class RangeObj:
|
|||||||
@PIKA_C_MACRO_IF("0")
|
@PIKA_C_MACRO_IF("0")
|
||||||
class StringObj:
|
class StringObj:
|
||||||
def __next__(self) -> any: ...
|
def __next__(self) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
|
class object:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BaseException(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Exception(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SystemExit(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class KeyboardInterrupt(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class GeneratorExit(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Exception(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class StopIteration(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class StopAsyncIteration(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ArithmeticError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FloatingPointError(ArithmeticError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class OverflowError(ArithmeticError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ZeroDivisionError(ArithmeticError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AssertionError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AttributeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BufferError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class EOFError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ImportError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ModuleNotFoundError(ImportError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class LookupError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IndexError(LookupError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class KeyError(LookupError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MemoryError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NameError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnboundLocalError(NameError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class OSError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BlockingIOError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ChildProcessError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BrokenPipeError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionAbortedError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionRefusedError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionResetError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FileExistsError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FileNotFoundError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class InterruptedError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IsADirectoryError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NotADirectoryError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ProcessLookupError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TimeoutError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ReferenceError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RuntimeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NotImplementedError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RecursionError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SyntaxError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IndentationError(SyntaxError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TabError(IndentationError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SystemError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TypeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ValueError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeError(ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeDecodeError(UnicodeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeEncodeError(UnicodeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeTranslateError(UnicodeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Warning(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class DeprecationWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PendingDeprecationWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RuntimeWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SyntaxWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UserWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FutureWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ImportWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BytesWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceWarning(Warning):
|
||||||
|
pass
|
||||||
|
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -24,7 +24,7 @@
|
|||||||
// "--gtest_filter=lua.eval"
|
// "--gtest_filter=lua.eval"
|
||||||
// "--gtest_filter=eventloop.once1"
|
// "--gtest_filter=eventloop.once1"
|
||||||
// "--gtest_filter=parser.fn_fn"
|
// "--gtest_filter=parser.fn_fn"
|
||||||
// "--gtest_filter=builtin.isinstance"
|
"--gtest_filter=builtin.isinstance"
|
||||||
// "--gtest_filter=VM.run_def_add"
|
// "--gtest_filter=VM.run_def_add"
|
||||||
// "--gtest_filter=parser.slice_fn"
|
// "--gtest_filter=parser.slice_fn"
|
||||||
],
|
],
|
||||||
|
@ -1,143 +1,181 @@
|
|||||||
from PikaObj import *
|
from PikaObj import *
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def int(arg: any, *base) -> int: ...
|
def int(arg: any, *base) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bool(arg: any) -> bool: ...
|
def bool(arg: any) -> bool: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def float(arg: any) -> float: ...
|
def float(arg: any) -> float: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def str(arg: any) -> str: ...
|
def str(arg: any) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def iter(arg: any) -> any: ...
|
def iter(arg: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def range(*ax) -> any: ...
|
def range(*ax) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def print(*val, **ops): ...
|
def print(*val, **ops): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __setitem__(obj: any, key: any, val: any) -> any: ...
|
def __setitem__(obj: any, key: any, val: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __getitem__(obj: any, key: any) -> any: ...
|
def __getitem__(obj: any, key: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def type(arg: any) -> any: ...
|
def type(arg: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def isinstance(object: any, classinfo: any) -> bool: ...
|
def isinstance(object: any, classinfo: any) -> bool: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def len(arg: any) -> int: ...
|
def len(arg: any) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
||||||
def list(*val) -> any: ...
|
def list(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
||||||
def dict(*val) -> any: ...
|
def dict(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
|
||||||
def tuple(arg: any) -> any: ...
|
def tuple(arg: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def hex(val: int) -> str: ...
|
def hex(val: int) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def ord(val: str) -> int: ...
|
def ord(val: str) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def chr(val: int) -> str: ...
|
def chr(val: int) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def bytes(val: any) -> bytes: ...
|
def bytes(val: any) -> bytes: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_SYNTAX_FORMAT_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_SYNTAX_FORMAT_ENABLE")
|
||||||
def cformat(fmt: str, *var) -> str: ...
|
def cformat(fmt: str, *var) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def id(obj: any) -> int: ...
|
def id(obj: any) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_FILEIO_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_FILEIO_ENABLE")
|
||||||
def open(path: str, mode: str) -> object: ...
|
def open(path: str, mode: str) -> object: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def dir(obj: any) -> list: ...
|
def dir(obj: any) -> list: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
||||||
def exec(code: str): ...
|
def exec(code: str): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
||||||
def eval(code: str) -> any: ...
|
def eval(code: str) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def getattr(obj: object, name: str) -> any: ...
|
def getattr(obj: object, name: str) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def setattr(obj: object, name: str, val: any): ...
|
def setattr(obj: object, name: str, val: any): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def hasattr(obj: object, name: str) -> int: ...
|
def hasattr(obj: object, name: str) -> int: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def exit(): ...
|
def exit(): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def input(*info) -> str: ...
|
def input(*info) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def abs(val: any) -> any: ...
|
def abs(val: any) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def max(*val) -> any: ...
|
def max(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def min(*val) -> any: ...
|
def min(*val) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def help(name: str): ...
|
def help(name: str): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def reboot(): ...
|
def reboot(): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||||
def clear(): ...
|
def clear(): ...
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@PIKA_C_MACRO_IF("PIKA_GC_MARK_SWEEP_ENABLE")
|
@PIKA_C_MACRO_IF("PIKA_GC_MARK_SWEEP_ENABLE")
|
||||||
def gcdump(): ...
|
def gcdump(): ...
|
||||||
|
|
||||||
|
|
||||||
@PIKA_C_MACRO_IF("0")
|
@PIKA_C_MACRO_IF("0")
|
||||||
class RangeObj:
|
class RangeObj:
|
||||||
def __next__(self) -> any: ...
|
def __next__(self) -> any: ...
|
||||||
@ -146,3 +184,267 @@ class RangeObj:
|
|||||||
@PIKA_C_MACRO_IF("0")
|
@PIKA_C_MACRO_IF("0")
|
||||||
class StringObj:
|
class StringObj:
|
||||||
def __next__(self) -> any: ...
|
def __next__(self) -> any: ...
|
||||||
|
|
||||||
|
|
||||||
|
class object:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BaseException(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Exception(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SystemExit(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class KeyboardInterrupt(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class GeneratorExit(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Exception(BaseException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class StopIteration(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class StopAsyncIteration(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ArithmeticError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FloatingPointError(ArithmeticError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class OverflowError(ArithmeticError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ZeroDivisionError(ArithmeticError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AssertionError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AttributeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BufferError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class EOFError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ImportError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ModuleNotFoundError(ImportError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class LookupError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IndexError(LookupError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class KeyError(LookupError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MemoryError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NameError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnboundLocalError(NameError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class OSError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BlockingIOError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ChildProcessError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BrokenPipeError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionAbortedError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionRefusedError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionResetError(ConnectionError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FileExistsError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FileNotFoundError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class InterruptedError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IsADirectoryError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NotADirectoryError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ProcessLookupError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TimeoutError(OSError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ReferenceError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RuntimeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NotImplementedError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RecursionError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SyntaxError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IndentationError(SyntaxError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TabError(IndentationError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SystemError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TypeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ValueError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeError(ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeDecodeError(UnicodeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeEncodeError(UnicodeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeTranslateError(UnicodeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Warning(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class DeprecationWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PendingDeprecationWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RuntimeWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SyntaxWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UserWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FutureWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ImportWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class UnicodeWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BytesWarning(Warning):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ResourceWarning(Warning):
|
||||||
|
pass
|
||||||
|
@ -981,25 +981,41 @@ char* methodArg_getName(Arg* method_arg, char* buffs, size_t size) {
|
|||||||
|
|
||||||
char* _find_super_class_name(ByteCodeFrame* bcframe, int32_t pc_start);
|
char* _find_super_class_name(ByteCodeFrame* bcframe, int32_t pc_start);
|
||||||
Arg* _builtin_class(char* sRunPath);
|
Arg* _builtin_class(char* sRunPath);
|
||||||
Arg* methodArg_super(Arg* method_arg) {
|
Arg* methodArg_super(Arg* aThis) {
|
||||||
Arg* aSuper = NULL;
|
Arg* aSuper = NULL;
|
||||||
if (!arg_isConstructor(method_arg)) {
|
PikaObj* builtins = NULL;
|
||||||
return NULL;
|
ArgType type = arg_getType(aThis);
|
||||||
|
if (!argType_isConstructor(type)) {
|
||||||
|
aSuper = NULL;
|
||||||
|
goto __exit;
|
||||||
}
|
}
|
||||||
MethodProp* method_store = (MethodProp*)arg_getContent(method_arg);
|
if (type == ARG_TYPE_METHOD_CONSTRUCTOR) {
|
||||||
ByteCodeFrame* bcframe = method_store->bytecode_frame;
|
builtins = obj_getBuiltins();
|
||||||
int32_t pc = method_store->ptr - bcframe->instruct_array.content_start;
|
MethodProp* method_store = (MethodProp*)arg_getContent(aThis);
|
||||||
char* sSuper = _find_super_class_name(bcframe, pc);
|
ByteCodeFrame* bcframe = method_store->bytecode_frame;
|
||||||
aSuper = _builtin_class(sSuper);
|
int32_t pc = method_store->ptr - bcframe->instruct_array.content_start;
|
||||||
if (NULL != aSuper) {
|
char* sSuper = _find_super_class_name(bcframe, pc);
|
||||||
arg_deinit(method_arg);
|
/* map TinyObj to object */
|
||||||
arg_deinit(aSuper);
|
if (strEqu(sSuper, "TinyObj")) {
|
||||||
return NULL;
|
sSuper = "object";
|
||||||
|
}
|
||||||
|
PikaObj* context = method_store->def_context;
|
||||||
|
aSuper = obj_getMethodArgWithFullPath(context, sSuper);
|
||||||
|
if (NULL == aSuper) {
|
||||||
|
aSuper = obj_getMethodArgWithFullPath(builtins, sSuper);
|
||||||
|
}
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
|
if (type == ARG_TYPE_METHOD_CONSTRUCTOR) {
|
||||||
|
aSuper = NULL;
|
||||||
|
goto __exit;
|
||||||
|
}
|
||||||
|
__exit:
|
||||||
|
if (NULL != builtins) {
|
||||||
|
obj_deinit(builtins);
|
||||||
}
|
}
|
||||||
PikaObj* context = method_store->def_context;
|
|
||||||
aSuper = obj_getMethodArgWithFullPath(context, sSuper);
|
|
||||||
if (NULL != aSuper) {
|
if (NULL != aSuper) {
|
||||||
arg_deinit(method_arg);
|
arg_deinit(aThis);
|
||||||
}
|
}
|
||||||
return aSuper;
|
return aSuper;
|
||||||
}
|
}
|
||||||
|
11
src/PikaVM.c
11
src/PikaVM.c
@ -1828,14 +1828,11 @@ static char* _find_self_name(VMState* vm) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PikaObj* New_builtins_object(Args* args);
|
||||||
Arg* _builtin_class(char* sRunPath) {
|
Arg* _builtin_class(char* sRunPath) {
|
||||||
/* return tiny obj */
|
/* return tiny obj */
|
||||||
if (strEqu(sRunPath, "TinyObj")) {
|
if (strEqu(sRunPath, "TinyObj")) {
|
||||||
return arg_newMetaObj(New_TinyObj);
|
return arg_newMetaObj(New_builtins_object);
|
||||||
}
|
|
||||||
|
|
||||||
if (strEqu(sRunPath, "object")) {
|
|
||||||
return arg_newMetaObj(New_TinyObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2936,9 +2933,9 @@ static Arg* VM_instruction_handler_OPT(PikaObj* self,
|
|||||||
#if !PIKA_NANO_ENABLE
|
#if !PIKA_NANO_ENABLE
|
||||||
if (argType_isObject(op.t1) && argType_isObject(op.t2)) {
|
if (argType_isObject(op.t1) && argType_isObject(op.t2)) {
|
||||||
if (arg_getPtr(op.a1) == arg_getPtr(op.a2)) {
|
if (arg_getPtr(op.a1) == arg_getPtr(op.a2)) {
|
||||||
op.res = arg_setInt(op.res, "", 1);
|
op.res = arg_setBool(op.res, "", pika_true);
|
||||||
} else {
|
} else {
|
||||||
op.res = arg_setInt(op.res, "", 0);
|
op.res = arg_setBool(op.res, "", pika_false);
|
||||||
}
|
}
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,12 @@ assert isinstance("Hello, world!", str) == True
|
|||||||
assert isinstance([1, 2, 3, 4, 5], list) == True
|
assert isinstance([1, 2, 3, 4, 5], list) == True
|
||||||
assert isinstance({"key": "value"}, dict) == True
|
assert isinstance({"key": "value"}, dict) == True
|
||||||
assert isinstance(3.14, float) == True
|
assert isinstance(3.14, float) == True
|
||||||
|
assert isinstance(object(), object) == True
|
||||||
|
|
||||||
class BaseClass:
|
class MyClass:
|
||||||
|
pass
|
||||||
|
|
||||||
|
class BaseClass(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.a = 1
|
self.a = 1
|
||||||
|
|
||||||
@ -18,6 +22,8 @@ base_instance = BaseClass()
|
|||||||
derived_instance = DerivedClass()
|
derived_instance = DerivedClass()
|
||||||
|
|
||||||
# Instances of DerivedClass should also be instances of BaseClass
|
# Instances of DerivedClass should also be instances of BaseClass
|
||||||
|
assert isinstance(MyClass(), object) == True
|
||||||
|
assert isinstance(base_instance, object) == True
|
||||||
assert isinstance(base_instance, BaseClass) == True
|
assert isinstance(base_instance, BaseClass) == True
|
||||||
assert isinstance(derived_instance, BaseClass) == True
|
assert isinstance(derived_instance, BaseClass) == True
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "BaseObj.h"
|
#include "BaseObj.h"
|
||||||
#include "PikaCompiler.h"
|
#include "PikaCompiler.h"
|
||||||
#include "PikaObj.h"
|
#include "PikaObj.h"
|
||||||
@ -8,246 +5,250 @@
|
|||||||
#include "dataStrs.h"
|
#include "dataStrs.h"
|
||||||
#include "libpikabinder.h"
|
#include "libpikabinder.h"
|
||||||
#include "pikascript/pikascript-core/dataStrs.h"
|
#include "pikascript/pikascript-core/dataStrs.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
void help(char* argv0) {
|
void help(char *argv0) {
|
||||||
Args buffs = {0};
|
Args buffs = {0};
|
||||||
char* exe = argv0;
|
char *exe = argv0;
|
||||||
printf(
|
printf("Usage:\r\n"
|
||||||
"Usage:\r\n"
|
" %s"
|
||||||
" %s"
|
" - [Binding C modules and compile all from main.py]\r\n"
|
||||||
" - [Binding C modules and compile all from main.py]\r\n"
|
" %s test.py"
|
||||||
" %s test.py"
|
" - [Compile all from test.py]\r\n"
|
||||||
" - [Compile all from test.py]\r\n"
|
" %s test.py -o out.a"
|
||||||
" %s test.py -o out.a"
|
" - [Compile all from test.py and link to out.a]\r\n"
|
||||||
" - [Compile all from test.py and link to out.a]\r\n"
|
" %s -c test.py"
|
||||||
" %s -c test.py"
|
" - [Only compile test.py to test.py.o]\r\n"
|
||||||
" - [Only compile test.py to test.py.o]\r\n"
|
" %s -c test.py -o out.o"
|
||||||
" %s -c test.py -o out.o"
|
" - [Only compile test.py to out.o]\r\n",
|
||||||
" - [Only compile test.py to out.o]\r\n",
|
exe, exe, exe, exe, exe);
|
||||||
exe, exe, exe, exe, exe);
|
strsDeinit(&buffs);
|
||||||
strsDeinit(&buffs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fake implement */
|
/* fake implement */
|
||||||
PikaObj* __pikaMain;
|
PikaObj *__pikaMain;
|
||||||
void New_PikaStdData_List(void) {}
|
void New_PikaStdData_List(void) {}
|
||||||
void New_PikaStdData_Dict(void) {}
|
void New_PikaStdData_Dict(void) {}
|
||||||
void New_PikaStdData_Tuple(void) {}
|
void New_PikaStdData_Tuple(void) {}
|
||||||
void New_PikaStdData_String(void) {}
|
void New_PikaStdData_String(void) {}
|
||||||
void New_PikaStdData_ByteArray(void) {}
|
void New_PikaStdData_ByteArray(void) {}
|
||||||
int strGetSizeUtf8(char* str){return 0;}
|
int strGetSizeUtf8(char *str) { return 0; }
|
||||||
void PikaStdData_Tuple___init__(PikaObj *self){}
|
void PikaStdData_Tuple___init__(PikaObj *self) {}
|
||||||
void PikaStdData_List___init__(PikaObj *self){}
|
void PikaStdData_List___init__(PikaObj *self) {}
|
||||||
void PikaStdData_List_append(PikaObj *self, Arg* arg){}
|
void PikaStdData_List_append(PikaObj *self, Arg *arg) {}
|
||||||
void PikaStdData_Dict___init__(PikaObj* self){}
|
void PikaStdData_Dict___init__(PikaObj *self) {}
|
||||||
void PikaStdData_Dict_set(PikaObj* self, char* key, Arg* val){}
|
void PikaStdData_Dict_set(PikaObj *self, char *key, Arg *val) {}
|
||||||
PikaObj* New_PikaStdLib_SysObj(Args* args) {return NULL;};
|
PikaObj *New_builtins_object(Args *args);
|
||||||
PikaObj* New_builtins(Args* args) {return NULL;};
|
PikaObj *New_PikaStdLib_SysObj(Args *args) { return NULL; };
|
||||||
PikaObj* New_builtins_RangeObj(Args* args){return NULL;}
|
PikaObj *New_builtins(Args *args) { return NULL; };
|
||||||
PikaObj* New_PikaStdData_FILEIO(Args* args){return NULL;}
|
PikaObj *New_builtins_RangeObj(Args *args) { return NULL; }
|
||||||
char* string_slice(Args* outBuffs, char* str, int start, int end) {return NULL;}
|
PikaObj *New_PikaStdData_FILEIO(Args *args) { return NULL; }
|
||||||
int PikaStdData_FILEIO_init(PikaObj* self, char* path, char* mode){return 0;}
|
char *string_slice(Args *outBuffs, char *str, int start, int end) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
int PikaStdData_FILEIO_init(PikaObj *self, char *path, char *mode) { return 0; }
|
||||||
|
|
||||||
static int _do_main(int argc, char** argv) {
|
static int _do_main(int argc, char **argv) {
|
||||||
int parc = argc - 1;
|
int parc = argc - 1;
|
||||||
PikaMaker* maker = New_PikaMaker();
|
PikaMaker *maker = New_PikaMaker();
|
||||||
|
|
||||||
/* --add-file xxx --add-file yyy */
|
/* --add-file xxx --add-file yyy */
|
||||||
// __platform_printf("parc: %d\r\n", parc);
|
// __platform_printf("parc: %d\r\n", parc);
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
// __platform_printf("%s\r\n", argv[i]);
|
// __platform_printf("%s\r\n", argv[i]);
|
||||||
if (0 == strcmp(argv[i], "--add-file")) {
|
if (0 == strcmp(argv[i], "--add-file")) {
|
||||||
// __platform_printf("add file: %s\r\n", argv[i + 1]);
|
// __platform_printf("add file: %s\r\n", argv[i + 1]);
|
||||||
if (i + 1 < argc) {
|
if (i + 1 < argc) {
|
||||||
pikaMaker_linkRaw(maker, argv[i + 1]);
|
pikaMaker_linkRaw(maker, argv[i + 1]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* delete --xxx yyy */
|
/* delete --xxx yyy */
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (0 == strcmp(argv[i], "--add-file")) {
|
if (0 == strcmp(argv[i], "--add-file")) {
|
||||||
// printf("before delete: %d\r\n", parc);
|
// printf("before delete: %d\r\n", parc);
|
||||||
// for (int j = 0; j < parc; j++) {
|
// for (int j = 0; j < parc; j++) {
|
||||||
// printf("%s\r\n", argv[j + 1]);
|
// printf("%s\r\n", argv[j + 1]);
|
||||||
// }
|
// }
|
||||||
parc -= 2;
|
parc -= 2;
|
||||||
for (int j = i; j < argc - 2; j++) {
|
for (int j = i; j < argc - 2; j++) {
|
||||||
argv[j] = argv[j + 2];
|
argv[j] = argv[j + 2];
|
||||||
}
|
}
|
||||||
// printf("after delete: %d\r\n", parc);
|
// printf("after delete: %d\r\n", parc);
|
||||||
// for (int j = 0; j < parc; j++) {
|
// for (int j = 0; j < parc; j++) {
|
||||||
// printf("%s\r\n", argv[j + 1]);
|
// printf("%s\r\n", argv[j + 1]);
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (0 == parc) {
|
if (0 == parc) {
|
||||||
/* no input, default to main.py */
|
/* no input, default to main.py */
|
||||||
/* run pika_binder to bind C modules */
|
/* run pika_binder to bind C modules */
|
||||||
pika_binder();
|
pika_binder();
|
||||||
pikaMaker_compileModuleWithDepends(maker, "main");
|
pikaMaker_compileModuleWithDepends(maker, "main");
|
||||||
PIKA_RES res = pikaMaker_linkCompiledModules(maker, "pikaModules.py.a");
|
PIKA_RES res = pikaMaker_linkCompiledModules(maker, "pikaModules.py.a");
|
||||||
pikaMaker_deinit(maker);
|
pikaMaker_deinit(maker);
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* example: ./rust-msc-latest-linux -h | --help */
|
||||||
|
if (1 == parc) {
|
||||||
|
if (0 == strcmp(argv[1], "-h") || 0 == strcmp(argv[1], "--help")) {
|
||||||
|
help(argv[0]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* example: ./rust-msc-latest-linux -h | --help */
|
/* example: ./rust-msc-latest-linux main.py */
|
||||||
if (1 == parc) {
|
if (1 == parc) {
|
||||||
if (0 == strcmp(argv[1], "-h") || 0 == strcmp(argv[1], "--help")) {
|
char *module_entry = argv[1];
|
||||||
help(argv[0]);
|
/* remove subfix */
|
||||||
return 0;
|
char *subfix = strrchr(module_entry, '.');
|
||||||
}
|
if (subfix) {
|
||||||
|
*subfix = '\0';
|
||||||
}
|
}
|
||||||
|
pikaMaker_compileModuleWithDepends(maker, module_entry);
|
||||||
|
PIKA_RES res = pikaMaker_linkCompiledModules(maker, "pikaModules.py.a");
|
||||||
|
pikaMaker_deinit(maker);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/* example: ./rust-msc-latest-linux main.py */
|
/* example ./rust-msc-latest-linux main.py -o out.a */
|
||||||
if (1 == parc) {
|
if (3 == parc) {
|
||||||
char* module_entry = argv[1];
|
if (0 == strcmp(argv[2], "-o")) {
|
||||||
/* remove subfix */
|
char *module_entry = argv[1];
|
||||||
char* subfix = strrchr(module_entry, '.');
|
/* remove subfix */
|
||||||
if (subfix) {
|
char *subfix = strrchr(module_entry, '.');
|
||||||
*subfix = '\0';
|
if (subfix) {
|
||||||
}
|
*subfix = '\0';
|
||||||
pikaMaker_compileModuleWithDepends(maker, module_entry);
|
}
|
||||||
PIKA_RES res = pikaMaker_linkCompiledModules(maker, "pikaModules.py.a");
|
pikaMaker_compileModuleWithDepends(maker, module_entry);
|
||||||
pikaMaker_deinit(maker);
|
PIKA_RES res = pikaMaker_linkCompiledModules(maker, argv[3]);
|
||||||
return res;
|
pikaMaker_deinit(maker);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* example ./rust-msc-latest-linux main.py -o out.a */
|
/* example ./rust-msc-latest --docgen main.py */
|
||||||
if (3 == parc) {
|
if (2 == parc) {
|
||||||
if (0 == strcmp(argv[2], "-o")) {
|
if (0 == strcmp(argv[1], "--docgen")) {
|
||||||
char* module_entry = argv[1];
|
Args buffs = {0};
|
||||||
/* remove subfix */
|
char *file_path = argv[2];
|
||||||
char* subfix = strrchr(module_entry, '.');
|
char *file_name = strsPathGetFileName(&buffs, file_path);
|
||||||
if (subfix) {
|
printf("file_name: %s\r\n", file_name);
|
||||||
*subfix = '\0';
|
char *file_folder = strsPathGetFolder(&buffs, file_path);
|
||||||
}
|
char *file_name_no_ext = strsGetFirstToken(&buffs, file_name, '.');
|
||||||
pikaMaker_compileModuleWithDepends(maker, module_entry);
|
printf("file_name_no_ext: %s\r\n", file_name_no_ext);
|
||||||
PIKA_RES res = pikaMaker_linkCompiledModules(maker, argv[3]);
|
char *file_out_name = strsAppend(&buffs, file_name_no_ext, ".md");
|
||||||
pikaMaker_deinit(maker);
|
printf("file_out_name: %s\r\n", file_out_name);
|
||||||
return res;
|
char *file_out_path = strsPathJoin(&buffs, file_folder, file_out_name);
|
||||||
}
|
Parser *parser = New_parser();
|
||||||
|
printf("generating doc %s: %s\r\n", file_path, file_out_path);
|
||||||
|
parser_file2DocFile(parser, file_path, file_out_path);
|
||||||
|
strsDeinit(&buffs);
|
||||||
|
parser_deinit(parser);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* example ./rust-msc-latest --docgen main.py */
|
/* example: ./rust-msc-latest-linux -docgen main.py -o main.md */
|
||||||
if (2 == parc) {
|
if (4 == parc) {
|
||||||
if (0 == strcmp(argv[1], "--docgen")) {
|
if (0 == strcmp(argv[1], "--docgen") && 0 == strcmp(argv[3], "-o")) {
|
||||||
Args buffs = {0};
|
Args buffs = {0};
|
||||||
char* file_path = argv[2];
|
char *file_path = argv[2];
|
||||||
char* file_name = strsPathGetFileName(&buffs, file_path);
|
char *file_out_path = argv[4];
|
||||||
printf("file_name: %s\r\n", file_name);
|
Parser *parser = New_parser();
|
||||||
char* file_folder = strsPathGetFolder(&buffs, file_path);
|
printf("generating doc %s: %s\r\n", file_path, file_out_path);
|
||||||
char* file_name_no_ext = strsGetFirstToken(&buffs, file_name, '.');
|
parser_file2DocFile(parser, file_path, file_out_path);
|
||||||
printf("file_name_no_ext: %s\r\n", file_name_no_ext);
|
strsDeinit(&buffs);
|
||||||
char* file_out_name = strsAppend(&buffs, file_name_no_ext, ".md");
|
parser_deinit(parser);
|
||||||
printf("file_out_name: %s\r\n", file_out_name);
|
return 0;
|
||||||
char* file_out_path = strsPathJoin(&buffs, file_folder, file_out_name);
|
|
||||||
Parser* parser = New_parser();
|
|
||||||
printf("generating doc %s: %s\r\n", file_path,file_out_path);
|
|
||||||
parser_file2DocFile(parser, file_path, file_out_path);
|
|
||||||
strsDeinit(&buffs);
|
|
||||||
parser_deinit(parser);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* example: ./rust-msc-latest-linux -docgen main.py -o main.md */
|
/* example: ./rust-msc-latest-linux -c main.py */
|
||||||
if (4 == parc) {
|
if (2 == parc) {
|
||||||
if (0 == strcmp(argv[1], "--docgen") && 0 == strcmp(argv[3], "-o")) {
|
if (0 == strcmp(argv[1], "-c")) {
|
||||||
Args buffs = {0};
|
Args buffs = {0};
|
||||||
char* file_path = argv[2];
|
/* compile only */
|
||||||
char* file_out_path = argv[4];
|
char *module_entry = argv[2];
|
||||||
Parser* parser = New_parser();
|
char *module_out = strsCopy(&buffs, module_entry);
|
||||||
printf("generating doc %s: %s\r\n", file_path,file_out_path);
|
char *subfix = strrchr(module_out, '.');
|
||||||
parser_file2DocFile(parser, file_path, file_out_path);
|
if (subfix) {
|
||||||
strsDeinit(&buffs);
|
*subfix = '\0';
|
||||||
parser_deinit(parser);
|
}
|
||||||
return 0;
|
module_out = strsAppend(&buffs, module_out, ".py.o");
|
||||||
}
|
printf("compiling %s to %s...\r\n", module_entry, module_out);
|
||||||
|
PIKA_RES res = pikaCompileFileWithOutputName(module_out, module_entry);
|
||||||
|
strsDeinit(&buffs);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* example: ./rust-msc-latest-linux -c main.py */
|
/* example: ./rust-msc-latest-linux -c main.py -o main.py.o */
|
||||||
if (2 == parc) {
|
if (4 == parc) {
|
||||||
if (0 == strcmp(argv[1], "-c")) {
|
if (0 == strcmp(argv[1], "-c") && 0 == strcmp(argv[3], "-o")) {
|
||||||
Args buffs = {0};
|
/* compile only */
|
||||||
/* compile only */
|
char *module_entry = argv[2];
|
||||||
char* module_entry = argv[2];
|
printf("compiling %s to %s...\r\n", module_entry, argv[4]);
|
||||||
char* module_out = strsCopy(&buffs, module_entry);
|
PIKA_RES res = pikaCompileFileWithOutputName(argv[4], module_entry);
|
||||||
char* subfix = strrchr(module_out, '.');
|
return res;
|
||||||
if (subfix) {
|
|
||||||
*subfix = '\0';
|
|
||||||
}
|
|
||||||
module_out = strsAppend(&buffs, module_out, ".py.o");
|
|
||||||
printf("compiling %s to %s...\r\n", module_entry, module_out);
|
|
||||||
PIKA_RES res =
|
|
||||||
pikaCompileFileWithOutputName(module_out, module_entry);
|
|
||||||
strsDeinit(&buffs);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* example: ./rust-msc-latest-linux -c main.py -o main.py.o */
|
/* no valid input */
|
||||||
if (4 == parc) {
|
printf("Invalid input.\r\n");
|
||||||
if (0 == strcmp(argv[1], "-c") && 0 == strcmp(argv[3], "-o")) {
|
help(argv[0]);
|
||||||
/* compile only */
|
|
||||||
char* module_entry = argv[2];
|
|
||||||
printf("compiling %s to %s...\r\n", module_entry, argv[4]);
|
|
||||||
PIKA_RES res = pikaCompileFileWithOutputName(argv[4], module_entry);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* no valid input */
|
return -1;
|
||||||
printf("Invalid input.\r\n");
|
|
||||||
help(argv[0]);
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char **argv) {
|
||||||
char* buf = NULL;
|
char *buf = NULL;
|
||||||
FILE* pika_studio = NULL;
|
FILE *pika_studio = NULL;
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
pika_studio = __platform_fopen("pika.studio", "r");
|
pika_studio = __platform_fopen("pika.studio", "r");
|
||||||
if (NULL != pika_studio) {
|
|
||||||
buf = __platform_malloc(1024);
|
|
||||||
__platform_fread(buf, 1, 1024, pika_studio);
|
|
||||||
/* find <args> </args> */
|
|
||||||
char* start = strstr(buf, "<args>");
|
|
||||||
char* end = strstr(buf, "</args>");
|
|
||||||
if (start && end) {
|
|
||||||
start += 6;
|
|
||||||
*end = '\0';
|
|
||||||
__platform_printf("args: %s\r\n", start);
|
|
||||||
/* split args */
|
|
||||||
char* args[32] = {0};
|
|
||||||
args[0] = argv[0];
|
|
||||||
char* p = start;
|
|
||||||
while (p < end) {
|
|
||||||
char* q = strchr(p, ' ');
|
|
||||||
if (q) {
|
|
||||||
*q = '\0';
|
|
||||||
args[argc++] = p;
|
|
||||||
p = q + 1;
|
|
||||||
} else {
|
|
||||||
args[argc++] = p;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argv = args;
|
|
||||||
// for (int i = 0; i < argc; i++) {
|
|
||||||
// __platform_printf("argv[%d]: %s\r\n", i, argv[i]);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int ret = _do_main(argc, argv);
|
|
||||||
if (NULL != buf) {
|
|
||||||
__platform_free(buf);
|
|
||||||
}
|
|
||||||
if (NULL != pika_studio) {
|
if (NULL != pika_studio) {
|
||||||
__platform_fclose(pika_studio);
|
buf = __platform_malloc(1024);
|
||||||
|
__platform_fread(buf, 1, 1024, pika_studio);
|
||||||
|
/* find <args> </args> */
|
||||||
|
char *start = strstr(buf, "<args>");
|
||||||
|
char *end = strstr(buf, "</args>");
|
||||||
|
if (start && end) {
|
||||||
|
start += 6;
|
||||||
|
*end = '\0';
|
||||||
|
__platform_printf("args: %s\r\n", start);
|
||||||
|
/* split args */
|
||||||
|
char *args[32] = {0};
|
||||||
|
args[0] = argv[0];
|
||||||
|
char *p = start;
|
||||||
|
while (p < end) {
|
||||||
|
char *q = strchr(p, ' ');
|
||||||
|
if (q) {
|
||||||
|
*q = '\0';
|
||||||
|
args[argc++] = p;
|
||||||
|
p = q + 1;
|
||||||
|
} else {
|
||||||
|
args[argc++] = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
argv = args;
|
||||||
|
// for (int i = 0; i < argc; i++) {
|
||||||
|
// __platform_printf("argv[%d]: %s\r\n", i, argv[i]);
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
}
|
||||||
|
int ret = _do_main(argc, argv);
|
||||||
|
if (NULL != buf) {
|
||||||
|
__platform_free(buf);
|
||||||
|
}
|
||||||
|
if (NULL != pika_studio) {
|
||||||
|
__platform_fclose(pika_studio);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user