Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
bb61cc0d
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 8 个月
通知
988
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
bb61cc0d
编写于
7月 10, 2023
作者:
A
Alexander Smorkalov
提交者:
GitHub
7月 10, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23954 from VadimLevin:dev/vlevin/matrix-type-constants-stubs
feat: add matrix type stubs generation
上级
de8e6abd
986e379f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
4 deletion
+30
-4
modules/python/src2/typing_stubs_generation/api_refinement.py
...les/python/src2/typing_stubs_generation/api_refinement.py
+30
-1
modules/python/src2/typing_stubs_generation/generation.py
modules/python/src2/typing_stubs_generation/generation.py
+0
-3
未找到文件。
modules/python/src2/typing_stubs_generation/api_refinement.py
浏览文件 @
bb61cc0d
...
@@ -4,11 +4,13 @@ __all__ = [
...
@@ -4,11 +4,13 @@ __all__ = [
from
typing
import
Sequence
,
Callable
from
typing
import
Sequence
,
Callable
from
.nodes
import
NamespaceNode
,
FunctionNode
,
OptionalTypeNode
,
ClassProperty
,
PrimitiveTypeNode
from
.nodes
import
(
NamespaceNode
,
FunctionNode
,
OptionalTypeNode
,
ClassProperty
,
PrimitiveTypeNode
)
from
.ast_utils
import
find_function_node
,
SymbolName
from
.ast_utils
import
find_function_node
,
SymbolName
def
apply_manual_api_refinement
(
root
:
NamespaceNode
)
->
None
:
def
apply_manual_api_refinement
(
root
:
NamespaceNode
)
->
None
:
export_matrix_type_constants
(
root
)
# Export OpenCV exception class
# Export OpenCV exception class
builtin_exception
=
root
.
add_class
(
"Exception"
)
builtin_exception
=
root
.
add_class
(
"Exception"
)
builtin_exception
.
is_exported
=
False
builtin_exception
.
is_exported
=
False
...
@@ -17,6 +19,33 @@ def apply_manual_api_refinement(root: NamespaceNode) -> None:
...
@@ -17,6 +19,33 @@ def apply_manual_api_refinement(root: NamespaceNode) -> None:
refine_symbol
(
root
,
symbol_name
)
refine_symbol
(
root
,
symbol_name
)
def
export_matrix_type_constants
(
root
:
NamespaceNode
)
->
None
:
MAX_PREDEFINED_CHANNELS
=
4
depth_names
=
(
"CV_8U"
,
"CV_8S"
,
"CV_16U"
,
"CV_16S"
,
"CV_32S"
,
"CV_32F"
,
"CV_64F"
,
"CV_16F"
)
for
depth_value
,
depth_name
in
enumerate
(
depth_names
):
# Export depth constants
root
.
add_constant
(
depth_name
,
str
(
depth_value
))
# Export predefined types
for
c
in
range
(
MAX_PREDEFINED_CHANNELS
):
root
.
add_constant
(
f
"
{
depth_name
}
C
{
c
+
1
}
"
,
f
"
{
depth_value
+
8
*
c
}
"
)
# Export type creation function
root
.
add_function
(
f
"
{
depth_name
}
C"
,
(
FunctionNode
.
Arg
(
"channels"
,
PrimitiveTypeNode
.
int_
()),
),
FunctionNode
.
RetType
(
PrimitiveTypeNode
.
int_
())
)
# Export CV_MAKETYPE
root
.
add_function
(
"CV_MAKETYPE"
,
(
FunctionNode
.
Arg
(
"depth"
,
PrimitiveTypeNode
.
int_
()),
FunctionNode
.
Arg
(
"channels"
,
PrimitiveTypeNode
.
int_
())),
FunctionNode
.
RetType
(
PrimitiveTypeNode
.
int_
())
)
def
make_optional_arg
(
arg_name
:
str
)
->
Callable
[[
NamespaceNode
,
SymbolName
],
None
]:
def
make_optional_arg
(
arg_name
:
str
)
->
Callable
[[
NamespaceNode
,
SymbolName
],
None
]:
def
_make_optional_arg
(
root_node
:
NamespaceNode
,
def
_make_optional_arg
(
root_node
:
NamespaceNode
,
function_symbol_name
:
SymbolName
)
->
None
:
function_symbol_name
:
SymbolName
)
->
None
:
...
...
modules/python/src2/typing_stubs_generation/generation.py
浏览文件 @
bb61cc0d
...
@@ -103,9 +103,6 @@ def _generate_typing_stubs(root: NamespaceNode, output_path: Path) -> None:
...
@@ -103,9 +103,6 @@ def _generate_typing_stubs(root: NamespaceNode, output_path: Path) -> None:
_write_reexported_symbols_section
(
root
,
output_stream
)
_write_reexported_symbols_section
(
root
,
output_stream
)
# Write constants section, because constants don't impose any dependencies
_generate_section_stub
(
StubSection
(
"# Constants"
,
ConstantNode
),
root
,
output_stream
,
0
)
# NOTE: Enumerations require special handling, because all enumeration
# NOTE: Enumerations require special handling, because all enumeration
# constants are exposed as module attributes
# constants are exposed as module attributes
has_enums
=
_generate_section_stub
(
StubSection
(
"# Enumerations"
,
EnumerationNode
),
has_enums
=
_generate_section_stub
(
StubSection
(
"# Enumerations"
,
EnumerationNode
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录