Skip to content
This repository has been archived by the owner on Nov 25, 2018. It is now read-only.

Builtin type can be used for .mlapp -> .m conversion on new MATLAB #8

Closed
Dev-iL opened this issue May 2, 2016 · 6 comments
Closed
Assignees

Comments

@Dev-iL
Copy link
Member

Dev-iL commented May 2, 2016

This basically saves us the hassle of unzipping and stripping of the xml...

This functionality was probably added in MATLAB R2016a with the release of the App Designer, so regex-based code is probably still relevant when converting using older versions.

@sco1
Copy link
Member

sco1 commented May 2, 2016

Interesting, good find!

I just tested that using diary to pipe the output to an *.m file functions correctly, but it adds leading and trailing diary commands that need to be removed. It can also be piped to a string with evalc and written to a file with fprintf, which may be the most time expedient option.

I'll add in a check for versions >= R2016a to utilize one of these options to avoid the overhead of unzipping.

@sco1 sco1 self-assigned this May 2, 2016
@sco1
Copy link
Member

sco1 commented May 3, 2016

type works on *.mlapp files in R2015b as well, I don't have any other old versions to test with.

@Dev-iL
Copy link
Member Author

Dev-iL commented May 3, 2016

Just tested on 2015a - works.

@Dev-iL
Copy link
Member Author

Dev-iL commented May 3, 2016

@AnderBiguri tested this on 2014b and it still works. @adeak tested it on 2012b and it doesn't.

@sco1
Copy link
Member

sco1 commented May 3, 2016

The App Designer tech preview was released in October 2014, so I was thinking R2014b or R2014a would have been the earliest they'd start incorporating support. I'll set the flag to R2014b for now.

sco1 added a commit that referenced this issue May 3, 2016
MATLAB's type function can natively read and display a *.mlapp's class
definition. This is a documented addition to R2016a, but has been tested
successfully in R2014b and newer. This allows us to skip the
intermediate zip file extraction and XML parsing. Though type does not
support an output argument, the output can be piped to a character array
using evalc and exported to an *.m file.

Resolves: #8
@sco1
Copy link
Member

sco1 commented May 3, 2016

Should be in now but the regular expressions will need to be compared between versions. The "old" MATLAB handling reads every line of the XML file into its own cell but the type approach reads everything into a single character array.

@sco1 sco1 closed this as completed May 3, 2016
sco1 added a commit that referenced this issue May 4, 2016
Piping the output of type creates a character array of the *.m code,
where the routine to read in an XML file created a cell array of
strings. This introduces compatibility issues and considerations for
some of the regex approaches utilized for function call conversions. To
eliminate the need to consider the differences in input type, the piped
character array from type has been split into a cell array of strings,
mimicking the output of the XML parser.

See #7, #8, f986a72
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants