Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
djinni
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
djinni
Commits
c5b923f6
Commit
c5b923f6
authored
Jan 13, 2017
by
Andrew Twyman
Committed by
GitHub
Jan 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #252 from GreatCall-KayeK/kkaye/include-paths
Kkaye/include paths
parents
6a497f5c
a440560c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
24 deletions
+43
-24
src/.idea/runConfigurations/djinni_Main__Test_Suite_.xml
src/.idea/runConfigurations/djinni_Main__Test_Suite_.xml
+2
-2
src/source/Main.scala
src/source/Main.scala
+6
-3
src/source/parser.scala
src/source/parser.scala
+28
-13
test-suite/djinni/all.djinni
test-suite/djinni/all.djinni
+2
-2
test-suite/djinni/vendor/third-party/date.djinni
test-suite/djinni/vendor/third-party/date.djinni
+0
-0
test-suite/djinni/vendor/third-party/date.yaml
test-suite/djinni/vendor/third-party/date.yaml
+0
-0
test-suite/djinni/vendor/third-party/duration.djinni
test-suite/djinni/vendor/third-party/duration.djinni
+0
-0
test-suite/djinni/vendor/third-party/duration.yaml
test-suite/djinni/vendor/third-party/duration.yaml
+0
-0
test-suite/generated-src/inFileList.txt
test-suite/generated-src/inFileList.txt
+4
-4
test-suite/run_djinni.sh
test-suite/run_djinni.sh
+1
-0
No files found.
src/.idea/runConfigurations/djinni_Main__Test_Suite_.xml
View file @
c5b923f6
...
@@ -8,10 +8,10 @@
...
@@ -8,10 +8,10 @@
</extension>
</extension>
<option
name=
"MAIN_CLASS_NAME"
value=
"djinni.Main"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"djinni.Main"
/>
<option
name=
"VM_PARAMETERS"
value=
""
/>
<option
name=
"VM_PARAMETERS"
value=
""
/>
<option
name=
"PROGRAM_PARAMETERS"
value=
"--java-out djinni-output-temp/java --java-package com.dropbox.djinni.test --java-nullable-annotation "javax.annotation.CheckForNull" --java-nonnull-annotation "javax.annotation.Nonnull" --ident-java-field mFooBar --cpp-out djinni-output-temp/cpp --cpp-namespace testsuite --ident-cpp-enum-type foo_bar --cpp-optional-template "std::experimental::optional" --cpp-optional-header "<experimental/optional>" --jni-out djinni-output-temp/jni --ident-jni-class NativeFooBar --ident-jni-file NativeFooBar --objc-out djinni-output-temp/objc --objcpp-out djinni-output-temp/objc --objc-type-prefix DB --list-in-files generated-src/inFileList.txt --list-out-files generated-src/outFileList.txt --yaml-out djinni-output-temp/yaml --yaml-out-file "yaml-test.yaml" --yaml-prefix "test_" --idl djinni/all.djinni"
/>
<option
name=
"PROGRAM_PARAMETERS"
value=
"--java-out djinni-output-temp/java --java-package com.dropbox.djinni.test --java-nullable-annotation "javax.annotation.CheckForNull" --java-nonnull-annotation "javax.annotation.Nonnull" --ident-java-field mFooBar --cpp-out djinni-output-temp/cpp --cpp-namespace testsuite --ident-cpp-enum-type foo_bar --cpp-optional-template "std::experimental::optional" --cpp-optional-header "<experimental/optional>" --jni-out djinni-output-temp/jni --ident-jni-class NativeFooBar --ident-jni-file NativeFooBar --objc-out djinni-output-temp/objc --objcpp-out djinni-output-temp/objc --objc-type-prefix DB --list-in-files generated-src/inFileList.txt --list-out-files generated-src/outFileList.txt --yaml-out djinni-output-temp/yaml --yaml-out-file "yaml-test.yaml" --yaml-prefix "test_" --idl djinni/all.djinni
--idl-include-path djinni/vendor
"
/>
<option
name=
"WORKING_DIRECTORY"
value=
"file://$PROJECT_DIR$/../test-suite"
/>
<option
name=
"WORKING_DIRECTORY"
value=
"file://$PROJECT_DIR$/../test-suite"
/>
<option
name=
"ALTERNATIVE_JRE_PATH_ENABLED"
value=
"false"
/>
<option
name=
"ALTERNATIVE_JRE_PATH_ENABLED"
value=
"false"
/>
<option
name=
"ALTERNATIVE_JRE_PATH"
value=
""
/>
<option
name=
"ALTERNATIVE_JRE_PATH"
/>
<option
name=
"ENABLE_SWING_INSPECTOR"
value=
"false"
/>
<option
name=
"ENABLE_SWING_INSPECTOR"
value=
"false"
/>
<option
name=
"ENV_VARIABLES"
/>
<option
name=
"ENV_VARIABLES"
/>
<option
name=
"PASS_PARENT_ENVS"
value=
"true"
/>
<option
name=
"PASS_PARENT_ENVS"
value=
"true"
/>
...
...
src/source/Main.scala
View file @
c5b923f6
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
package
djinni
package
djinni
import
java.io.
{
IOException
,
FileInputStream
,
InputStreamReader
,
File
,
BufferedWriter
,
FileWriter
}
import
java.io.
{
IOException
,
File
NotFoundException
,
File
InputStream
,
InputStreamReader
,
File
,
BufferedWriter
,
FileWriter
}
import
djinni.generatorTools._
import
djinni.generatorTools._
...
@@ -24,6 +24,7 @@ object Main {
...
@@ -24,6 +24,7 @@ object Main {
def
main
(
args
:
Array
[
String
])
{
def
main
(
args
:
Array
[
String
])
{
var
idlFile
:
File
=
null
var
idlFile
:
File
=
null
var
idlIncludePaths
:
List
[
String
]
=
List
(
""
)
var
cppOutFolder
:
Option
[
File
]
=
None
var
cppOutFolder
:
Option
[
File
]
=
None
var
cppNamespace
:
String
=
""
var
cppNamespace
:
String
=
""
var
cppIncludePrefix
:
String
=
""
var
cppIncludePrefix
:
String
=
""
...
@@ -95,6 +96,8 @@ object Main {
...
@@ -95,6 +96,8 @@ object Main {
help
(
"help"
)
help
(
"help"
)
opt
[
File
](
"idl"
).
valueName
(
"<in-file>"
).
required
().
foreach
(
idlFile
=
_
)
opt
[
File
](
"idl"
).
valueName
(
"<in-file>"
).
required
().
foreach
(
idlFile
=
_
)
.
text
(
"The IDL file with the type definitions, typically with extension \".djinni\"."
)
.
text
(
"The IDL file with the type definitions, typically with extension \".djinni\"."
)
opt
[
String
](
"idl-include-path"
).
valueName
(
"<path> ..."
).
optional
().
unbounded
().
foreach
(
x
=>
idlIncludePaths
=
idlIncludePaths
:+
x
)
.
text
(
"An include path to search for Djinni @import directives. Can specify multiple paths."
)
note
(
""
)
note
(
""
)
opt
[
File
](
"java-out"
).
valueName
(
"<out-folder>"
).
foreach
(
x
=>
javaOutFolder
=
Some
(
x
))
opt
[
File
](
"java-out"
).
valueName
(
"<out-folder>"
).
foreach
(
x
=>
javaOutFolder
=
Some
(
x
))
.
text
(
"The output for the Java files (Generator disabled if unspecified)."
)
.
text
(
"The output for the Java files (Generator disabled if unspecified)."
)
...
@@ -248,10 +251,10 @@ object Main {
...
@@ -248,10 +251,10 @@ object Main {
None
None
}
}
val
idl
=
try
{
val
idl
=
try
{
(
new
Parser
).
parseFile
(
idlFile
,
inFileListWriter
)
(
new
Parser
(
idlIncludePaths
)
).
parseFile
(
idlFile
,
inFileListWriter
)
}
}
catch
{
catch
{
case
ex
:
IOException
=>
case
ex
@
(
_:
FileNotFoundException
|
_
:
IOException
)
=>
System
.
err
.
println
(
"Error reading from --idl file: "
+
ex
.
getMessage
)
System
.
err
.
println
(
"Error reading from --idl file: "
+
ex
.
getMessage
)
System
.
exit
(
1
);
return
System
.
exit
(
1
);
return
}
}
...
...
src/source/parser.scala
View file @
c5b923f6
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
package
djinni
package
djinni
import
java.io.
{
File
,
InputStreamReader
,
FileInputStream
,
Writer
}
import
java.io.
{
File
,
FileNotFoundException
,
InputStreamReader
,
FileInputStream
,
Writer
}
import
djinni.ast.Interface.Method
import
djinni.ast.Interface.Method
import
djinni.ast.Record.DerivingType.DerivingType
import
djinni.ast.Record.DerivingType.DerivingType
...
@@ -26,10 +26,11 @@ import java.util.{Map => JMap}
...
@@ -26,10 +26,11 @@ import java.util.{Map => JMap}
import
org.yaml.snakeyaml.Yaml
import
org.yaml.snakeyaml.Yaml
import
scala.collection.JavaConversions._
import
scala.collection.JavaConversions._
import
scala.collection.mutable
import
scala.collection.mutable
import
scala.util.control.Breaks._
import
scala.util.parsing.combinator.RegexParsers
import
scala.util.parsing.combinator.RegexParsers
import
scala.util.parsing.input.
{
Position
,
Positional
}
import
scala.util.parsing.input.
{
Position
,
Positional
}
case
class
Parser
()
{
case
class
Parser
(
includePaths
:
List
[
String
]
)
{
val
visitedFiles
=
mutable
.
Set
[
File
]()
val
visitedFiles
=
mutable
.
Set
[
File
]()
val
fileStack
=
mutable
.
Stack
[
File
]()
val
fileStack
=
mutable
.
Stack
[
File
]()
...
@@ -37,21 +38,35 @@ val fileStack = mutable.Stack[File]()
...
@@ -37,21 +38,35 @@ val fileStack = mutable.Stack[File]()
private
object
IdlParser
extends
RegexParsers
{
private
object
IdlParser
extends
RegexParsers
{
override
protected
val
whiteSpace
=
"""[ \t\n\r]+"""
.
r
override
protected
val
whiteSpace
=
"""[ \t\n\r]+"""
.
r
def
idlFile
(
origin
:
String
)
:
Parser
[
IdlFile
]
=
rep
(
importFile
)
~
rep
(
typeDecl
(
origin
))
^^
{
case
imp
~
types
=>
IdlFile
(
imp
,
types
)
}
def
idlFile
(
origin
:
String
)
:
Parser
[
IdlFile
]
=
rep
(
importFileRef
)
~
rep
(
typeDecl
(
origin
))
^^
{
case
imp
~
types
=>
IdlFile
(
imp
,
types
)
}
def
importFile
:
Parser
[
FileRef
]
=
{
def
fileParent
:
String
=
if
(
fileStack
.
top
.
getParent
()
!=
null
)
return
fileStack
.
top
.
getParent
()
+
"/"
else
return
""
def
importFileRef
()
:
Parser
[
FileRef
]
=
{
(
"@"
~>
directive
)
~
(
"\""
~>
filePath
<~
"\""
)
^^
{
(
"@"
~>
directive
)
~
(
"\""
~>
filePath
<~
"\""
)
^^
{
case
"import"
~
x
=>
case
"import"
~
x
=>
{
val
newPath
=
fileParent
+
x
new
IdlFileRef
(
importFile
(
x
))
new
IdlFileRef
(
new
File
(
newPath
))
}
case
"extern"
~
x
=>
case
"extern"
~
x
=>
{
val
newPath
=
fileParent
+
x
new
ExternFileRef
(
importFile
(
x
))
new
ExternFileRef
(
new
File
(
newPath
))
}
}
}
}
}
def
importFile
(
fileName
:
String
)
:
File
=
{
var
file
:
Option
[
File
]
=
None
val
path
=
includePaths
.
find
(
path
=>
{
val
relPath
=
if
(
path
.
isEmpty
)
fileStack
.
top
.
getParent
()
else
path
val
tmp
=
new
File
(
relPath
,
fileName
)
val
exists
=
tmp
.
exists
if
(
exists
)
file
=
Some
(
tmp
)
exists
})
if
(
file
.
isEmpty
)
throw
new
FileNotFoundException
(
"Unable to find file \""
+
fileName
+
"\" at "
+
fileStack
.
top
.
getCanonicalPath
)
return
file
.
get
}
def
filePath
=
"[^\"]*"
.
r
def
filePath
=
"[^\"]*"
.
r
def
directive
=
importDirective
|
externDirective
def
directive
=
importDirective
|
externDirective
...
...
test-suite/djinni/all.djinni
View file @
c5b923f6
@import "common.djinni"
@import "common.djinni"
@import "date.djinni"
@import "
vendor/third-party/
date.djinni"
@import "duration.djinni"
@import "
third-party/
duration.djinni"
test-suite/djinni/date.djinni
→
test-suite/djinni/
vendor/third-party/
date.djinni
View file @
c5b923f6
File moved
test-suite/djinni/date.yaml
→
test-suite/djinni/
vendor/third-party/
date.yaml
View file @
c5b923f6
File moved
test-suite/djinni/duration.djinni
→
test-suite/djinni/
vendor/third-party/
duration.djinni
View file @
c5b923f6
File moved
test-suite/djinni/duration.yaml
→
test-suite/djinni/
vendor/third-party/
duration.yaml
View file @
c5b923f6
File moved
test-suite/generated-src/inFileList.txt
View file @
c5b923f6
...
@@ -17,7 +17,7 @@ djinni/single_language_interfaces.djinni
...
@@ -17,7 +17,7 @@ djinni/single_language_interfaces.djinni
djinni/extended_record.djinni
djinni/extended_record.djinni
djinni/varnames.djinni
djinni/varnames.djinni
djinni/relative_paths.djinni
djinni/relative_paths.djinni
djinni/date.djinni
djinni/
vendor/third-party/
date.djinni
djinni/date.yaml
djinni/
vendor/third-party/
date.yaml
djinni/duration.djinni
djinni/
vendor/third-party/
duration.djinni
djinni/duration.yaml
djinni/
vendor/third-party/
duration.yaml
test-suite/run_djinni.sh
View file @
c5b923f6
...
@@ -123,6 +123,7 @@ fi
...
@@ -123,6 +123,7 @@ fi
--yaml-prefix
"test_"
\
--yaml-prefix
"test_"
\
\
\
--idl
"
$in_relative
"
\
--idl
"
$in_relative
"
\
--idl-include-path
"djinni/vendor"
\
)
)
# Make sure we can parse back our own generated YAML file
# Make sure we can parse back our own generated YAML file
...
...
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