Packages
evision
0.2.9
1.0.1-rc.0
1.0.0
1.0.0-rc.0
0.2.17
0.2.17-rc2
0.2.17-rc1
0.2.16
0.2.16-pre.2
0.2.16-pre
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.2-rc2
0.2.1
0.2.0
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.32
retired
0.1.31
0.1.30
0.1.29
0.1.28
0.1.27
0.1.26
0.1.26-rc3
0.1.26-rc2
0.1.26-rc1
0.1.26-rc0
0.1.25
0.1.24
0.1.23
0.1.22
0.1.21
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
OpenCV-Erlang/Elixir binding.
Current section
Files
Jump to
Current section
Files
py_src/arg_info.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from helper import *
class ArgInfo(object):
def __init__(self, atype, name, default_value, modifiers=(),
enclosing_arg=None):
# type: (ArgInfo, str, str, str, tuple[str, ...], ArgInfo | None) -> None
self.tp = handle_ptr(atype)
self.name = name
self.defval = default_value
self._modifiers = tuple(modifiers)
self.isarray = False
self.is_smart_ptr = self.tp.startswith('Ptr<') # FIXIT: handle through modifiers - need to modify parser
self.arraylen = 0
self.arraycvt = None
for m in self._modifiers:
if m.startswith("/A"):
self.isarray = True
self.arraylen = m[2:].strip()
elif m.startswith("/CA"):
self.isarray = True
self.arraycvt = m[2:].strip()
self.py_inputarg = False
self.py_outputarg = False
self.enclosing_arg = enclosing_arg
def __str__(self):
return 'ArgInfo("{}", tp="{}", default="{}", in={}, out={})'.format(
self.name, self.tp, self.defval, self.inputarg,
self.outputarg
)
def __repr__(self):
return str(self)
@property
def export_name(self):
return self.name
@property
def inputarg(self):
return '/O' not in self._modifiers
@property
def arithm_op_src_arg(self):
return '/AOS' in self._modifiers
@property
def outputarg(self):
return '/O' in self._modifiers or '/IO' in self._modifiers
@property
def pathlike(self):
return '/PATH' in self._modifiers
@property
def has_default(self):
return '/PATH' in self._modifiers
@property
def returnarg(self):
return self.outputarg
@property
def isrvalueref(self):
return '/RRef' in self._modifiers
@property
def full_name(self):
if self.enclosing_arg is None:
return self.name
return self.enclosing_arg.name + '.' + self.name
def isbig(self):
return self.tp in ["Mat", "vector_Mat",
"cuda::GpuMat", "cuda_GpuMat", "GpuMat",
"vector_GpuMat", "vector_cuda_GpuMat",
"UMat", "vector_UMat"] # or self.tp.startswith("vector")
def crepr(self, overwrite_defval=None):
# has_default = 0
# if (defval is not None and len(defval) > 0) or self.defval == self.tp + "()":
# has_default = 1
has_default = self.defval == self.tp + "()"
if overwrite_defval is not None and len(overwrite_defval) > 0:
has_default = 1
arg = 0x01 if self.outputarg else 0x0
arg += 0x02 if self.arithm_op_src_arg else 0x0
arg += 0x04 if self.pathlike else 0x0
arg += 0x08 if has_default else 0x0
return "ArgInfo(\"%s\", %d)" % (self.name, arg)