Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-23899] Add support for open access level keyword #163

Merged
merged 1 commit into from
May 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions metabase/ios/lib/swift.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function generateSwiftMetabase (buildDir, sdk, sdkPath, iosMinVersion, xcodeTarg
componentRE = /component id='(.*)'/,
patternNamedRE = /pattern_named type='(\w+)' '(\w+)'/,
typeRE = /type='(\w+)'/,
publicAccessPattern = /access=(public|open)/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about other accessors? Swift has some unique ones like fileprivate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other access levels are restricted in a certain way and cannot be used from any code that is written in Hyperloop so they can be safely ignored.

// turn our imports into includes for the metabase generation
includes = imports.map(function (name) {
return '<' + name + '/' + name + '.h>';
Expand Down Expand Up @@ -229,7 +230,7 @@ function generateSwiftMetabase (buildDir, sdk, sdkPath, iosMinVersion, xcodeTarg
language: 'swift'
};
tok.slice(2).forEach(function (t, i) {
if (t.indexOf('access=public') === 0) {
if (publicAccessPattern.test(t)) {
classdef.public = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An open class is not a public class. Not sure if setting those flags is generic enough to deal with Swift properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but the way we use this flag is to determine if a entity can be accessed via Hyperloop and in that case, it doesn't matter if it is public or open. I tried to make as little changes as possible considering we have a huge Swift overhaul coming anyway.

} else if (t.indexOf('inherits:') === 0) {
classdef.superclass = tok[i + 3]; // 2 is sliced so add + 1
Expand All @@ -250,7 +251,7 @@ function generateSwiftMetabase (buildDir, sdk, sdkPath, iosMinVersion, xcodeTarg
public: false
};
tok.splice(2).forEach(function (t, i) {
if (t.indexOf('access=public') === 0) {
if (publicAccessPattern.test(t)) {
vardef.public = true;
} else if (t.indexOf('type=') === 0) {
vardef.type = resolveType(fn, metabase, typeRE.exec(t)[1]);
Expand Down Expand Up @@ -279,7 +280,7 @@ function generateSwiftMetabase (buildDir, sdk, sdkPath, iosMinVersion, xcodeTarg
});
}
tok.splice(2).forEach(function (t, i) {
if (t.indexOf('access=public') === 0) {
if (publicAccessPattern.test(t)) {
methodef.public = true;
} else if (t.indexOf('type=') === 0) {
if (t.indexOf('type=\'' + classdef.name + '.Type') === 0) {
Expand Down