Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
09e29471
Commit
09e29471
authored
Mar 18, 2013
by
Hilton Bristow
Committed by
hbristow
Jun 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added class templates
parent
c29a98ef
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
124 additions
and
1 deletion
+124
-1
filters.py
modules/matlab/generator/filters.py
+11
-0
template_class_base.cpp
modules/matlab/generator/templates/template_class_base.cpp
+85
-0
template_class_base.m
modules/matlab/generator/templates/template_class_base.m
+27
-0
template_function_base.cpp
...les/matlab/generator/templates/template_function_base.cpp
+1
-1
No files found.
modules/matlab/generator/filters.py
View file @
09e29471
from
textwrap
import
TextWrapper
from
textwrap
import
TextWrapper
from
string
import
split
,
join
from
string
import
split
,
join
import
re
def
toUpperCamelCase
(
text
):
return
text
[
0
]
.
upper
()
+
text
[
1
:]
def
toLowerCamelCase
(
text
):
return
text
[
0
]
.
lower
()
+
text
[
1
:]
def
toUnderCase
(
text
):
s1
=
re
.
sub
(
'(.)([A-Z][a-z]+)'
,
r'\1_\2'
,
text
)
return
re
.
sub
(
'([a-z0-9])([A-Z])'
,
r'\1_\2'
,
s1
)
.
lower
()
def
comment
(
text
,
wrap
=
80
,
escape
=
'
%
'
,
escape_first
=
''
,
escape_last
=
''
):
def
comment
(
text
,
wrap
=
80
,
escape
=
'
%
'
,
escape_first
=
''
,
escape_last
=
''
):
'''comment filter
'''comment filter
Takes a string in text, and wraps it to wrap characters in length with
Takes a string in text, and wraps it to wrap characters in length with
...
...
modules/matlab/generator/templates/template_class_base.cpp
0 → 100644
View file @
09e29471
/*
* file: {{class.name}}Bridge.cpp
* author: A trusty code generator
* date: {{time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())}}
*
* This file was autogenerated, do not modify.
* See LICENCE for full modification and redistribution details.
* Copyright {{time.strftime("%Y", time.gmtime())}} The OpenCV Foundation
*/
#include "mex.h"
#include "bridge.hpp"
#include <vector>
#include <unordered_map>
#include <string>
{
%
block
includes
%
}
{
%
endblock
%
}
namespace
{
typedef
std
::
unordered_map
Map
;
typedef
std
::
vector
<
Bridge
>
(
*
)({{
class
.
name
}}
&
,
const
std
::
vector
<
Bridge
>&
)
MethodSignature
;
{
%
for
function
in
class
.
functions
%
}
// wrapper for {{function.name}}() method
std
::
vector
<
Bridge
>
{{
function
.
name
}}({{
class
.
name
}}
&
inst
,
const
std
::
vector
<
Bridge
>&
args
)
{
// setup
// invoke
// setdown
}
{
%
endfor
%
}
map
<
std
::
string
,
MethodSignature
>
createMethodMap
()
{
Map
<
std
::
string
,
MethodSignature
>
m
;
{
%
for
function
in
class
.
functions
%
}
m
[
"{{function.name}}"
]
=
&
{{
function
.
name
}};
{
%
endfor
%
}
return
m
;
}
static
const
Map
<
std
::
string
,
MethodSignature
>
methods
=
createMethodMap
();
// map of created {{class.name}} instances. Don't trust the user to keep them safe...
static
Map
<
void
*
,
{{
class
.
name
}}
>
instances
;
/*
* {{ class.name }}
* Gateway routine
* nlhs - number of return arguments
* plhs - pointers to return arguments
* nrhs - number of input arguments
* prhs - pointers to input arguments
*/
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
// parse the inputs
Bridge
method_name
(
prhs
[
0
]);
Bridge
handle
(
prhs
[
1
]);
std
::
vector
<
Bridge
>
brhs
(
prhs
+
2
,
prhs
+
nrhs
);
// retrieve the instance of interest
try
{
{{
class
.
name
}}
&
inst
=
instances
.
at
(
handle
.
address
());
}
catch
(
const
std
::
out_of_range
&
e
)
{
mexErrMsgTxt
(
"Invalid object instance provided"
);
}
// invoke the correct method on the data
try
{
std
::
vector
<
Bridge
>
blhs
=
(
*
methods
.
at
(
method_name
))(
inst
,
brhs
);
}
catch
(
const
std
::
out_of_range
&
e
)
{
mexErrMsgTxt
(
"Unknown method specified"
);
}
{
%
block
postfun
%
}
{
%
endblock
%
}
{
%
block
cleanup
%
}
{
%
endblock
%
}
}
};
// end namespace
modules/matlab/generator/templates/template_class_base.m
0 → 100644
View file @
09e29471
% {{class.name | upper}}
% Matlab handle class for OpenCV object classes
classdef
{{
class
.
name
}}
<
handle
properties
(
SetAccess
=
private
,
Hidden
=
true
)
ptr_
=
0
;
% handle to the underlying c++ class instance
end
methods
% constructor
function
this
=
{{
class
.
name
}}(
varargin
)
this
.
ptr_
=
{{
class
.
name
}}
Bridge
(
'new'
,
varargin
{:});
end
% destructor
function
delete
(
this
)
{{
className
}}
Bridge
(
this
.
ptr_
,
'delete'
);
end
{% for function in class.functions %}
% {{function.__str__()}}
function
varargout
=
{{
function
.
name
}}(
this
,
varargin
)
[
varargout
{
1
:
nargout
}]
=
{{
class
.
name
}}
Bridge
(
'{{function.name}}'
,
this
.
ptr_
,
varargin
{:});
end
{% endfor %}
end
end
modules/matlab/generator/templates/template_function_base.cpp
View file @
09e29471
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
/*
/*
* {{ fun.name }}
* {{ fun.name }}
*
Main mex entry point
*
Gateway routine
* nlhs - number of return arguments
* nlhs - number of return arguments
* plhs - pointers to return arguments
* plhs - pointers to return arguments
* nrhs - number of input arguments
* nrhs - number of input arguments
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment