Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hydra-image-processor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
hydra-image-processor
Commits
6e0d8d26
Commit
6e0d8d26
authored
6 years ago
by
Mark Winter
Browse files
Options
Downloads
Patches
Plain Diff
Modified matlab BuildMex script to handle new 'Info' command output format
parent
5ef8ea51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/MATLAB/+HIP/BuildMexObject.m
+35
-27
35 additions, 27 deletions
src/MATLAB/+HIP/BuildMexObject.m
with
35 additions
and
27 deletions
src/MATLAB/+HIP/BuildMexObject.m
+
35
−
27
View file @
6e0d8d26
...
...
@@ -9,6 +9,12 @@ function BuildMexObject(mexFile, objectName, parentPackage)
commandList
=
mexFunc
(
'Info'
);
cd
(
oldPath
);
% Delete old function definitions
if
(
exist
([
'@'
objectName
],
'dir'
)
)
delete
(
fullfile
([
'@'
objectName
],
'*.m'
));
end
makeClassdef
(
objectName
,
mexName
,
commandList
);
for
i
=
1
:
length
(
commandList
)
makeStaticMethod
(
objectName
,
mexName
,
commandList
(
i
),
parentPackage
);
...
...
@@ -44,25 +50,37 @@ end
function
makeStaticMethod
(
objectName
,
mexName
,
commandInfo
,
parentPackage
)
methodFile
=
fopen
(
fullfile
([
'@'
objectName
],[
commandInfo
.
command
'.m'
]),
'wt'
);
helpLines
=
strsplit
(
commandInfo
.
help
,
'\n'
,
'CollapseDelimiters'
,
false
);
validIdx
=
find
(
cellfun
(
@
(
x
)(
~
isempty
(
x
)),
helpLines
));
validLines
=
helpLines
(
validIdx
);
% Autogenerated help has is organized so that the first two nonempy lines are:
% 1. Internal command usage
% 2. Command Summary
% 3. ... Additional help lines
% Ignore first helpline (internal usage string) which is replaced by prototypeString()
summaryString
=
''
;
if ( length(commandInfo.helpLines)
<
2
)
summaryString =
[makePrototypeString(commandInfo)
'
'];
end
if
(
~
isempty
(
commandInfo.helpLines
)
)
summaryString =
[summaryString
commandInfo.helpLines
{1}];
if
(
length
(
validLines
)
>=
2
)
% Second line is the 'command summary'
summaryString
=
validLines
{
2
};
end
% Write top line as <Command> - <Summary>, Summary may be empty
fprintf
(
methodFile
,
'%% %s - %s\n'
,
commandInfo
.
command
,
summaryString
);
if
(
length
(
commandInfo.helpLines
)
>
1 )
fprintf(methodFile, '%% %s\n', makePrototypeString(commandInfo,objectName,parentPackage,true));
end
% Write call protoype string
fprintf
(
methodFile
,
'%% %s\n'
,
makePrototypeString
(
commandInfo
,
objectName
,
parentPackage
,
true
));
for i=2:length(commandInfo.helpLines)
fprintf(methodFile, '%% %s\n', commandInfo.helpLines{i});
% Write remaining help lines directly
if
(
length
(
validIdx
)
>
2
)
for
i
=
validIdx
(
3
):
length
(
helpLines
)
fprintf
(
methodFile
,
'%% %s\n'
,
helpLines
{
i
});
end
end
% Output function body
fprintf
(
methodFile
,
'function %s\n'
,
makePrototypeString
(
commandInfo
));
fprintf
(
methodFile
,
' %s;\n'
,
makeCommandString
(
objectName
,
mexName
,
commandInfo
,
parentPackage
));
fprintf
(
methodFile
,
'end\n'
);
...
...
@@ -75,6 +93,7 @@ function commandString = makeCommandString(objectName, mexName, commandInfo, par
if
(
~
isempty
(
commandInfo
.
outArgs
)
)
commandString
=
[
'['
makeCommaList
(
commandInfo
.
outArgs
)
'] = '
];
end
if
(
~
exist
(
'parentPackage'
,
'var'
)
)
parentPackage
=
[];
else
...
...
@@ -123,26 +142,15 @@ function protoString = makePrototypeString(commandInfo, objectName, parentPackag
protoString
=
[
protoString
')'
];
end
function commaStr = makeCommaList(in
List
, leaveOptBrackets)
function
commaStr
=
makeCommaList
(
in
Str
,
leaveOptBrackets
)
if
(
~
exist
(
'leaveOptBrackets'
,
'var'
)
||
isempty
(
leaveOptBrackets
))
leaveOptBrackets
=
false
;
end
commaStr = '';
if ( isempty(inList) )
return;
end
for i=1:length(inList)-1
commaStr = [commaStr removeOptBrackets(inList{i}, leaveOptBrackets) ','];
end
commaStr = [commaStr removeOptBrackets(inList{end}, leaveOptBrackets)];
end
function argName = removeOptBrackets(argName, leaveOptBrackets)
if ( ~leaveOptBrackets )
argName = regexprep(argName, '\[(\w+)\]', '$1');
if
(
leaveOptBrackets
)
commaStr
=
inStr
;
else
commaStr
=
regexprep
(
inStr
,
'\[(\w+)\]'
,
'$1'
);
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment