Skip to content

Commit

Permalink
Merge pull request #20 from ahmetsait/master
Browse files Browse the repository at this point in the history
Fix nested/qualified modules
  • Loading branch information
jll63 authored Aug 6, 2023
2 parents 45d520a + 83547f5 commit eb72dcd
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 95 deletions.
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.gitignore]
end_of_line = unset

[*.{bat,cmd,ps1}]
end_of_line = crlf

[*.{html,htm,xhtml,xml}]
indent_size = 2

[*.{css,scss,sass}]
indent_size = 2

[*.{json}]
indent_style = tab

[*.{yml,yaml}]
indent_style = space
indent_size = 2
1 change: 0 additions & 1 deletion benchmarks/runtimemetrics/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "test against large code base",
Expand Down
1 change: 0 additions & 1 deletion examples/acceptnovisitors/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "replace awful visitor with neat open method",
Expand Down
1 change: 0 additions & 1 deletion examples/adventure/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "example of a method with three virtual arguments",
Expand Down
1 change: 0 additions & 1 deletion examples/matrix/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "unary and binary matrix operations with two types of matrices",
Expand Down
1 change: 0 additions & 1 deletion examples/next/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "example of 'next', equivalent to calling super",
Expand Down
1 change: 0 additions & 1 deletion examples/rolex/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "Role and Expense example from the yomm11 article on Code Project",
Expand Down
1 change: 0 additions & 1 deletion examples/synopsis/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "synopsis",
Expand Down
1 change: 0 additions & 1 deletion examples/whytheunderscore/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"openmethods": {
"path": "../../",
"version": ">=0.0.0"
}
},
"description": "the reason for the underscore in front of method specializations",
Expand Down
110 changes: 55 additions & 55 deletions presentations/dlang-meetup-2017-09-28/index.html
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

<title>reveal.js</title>
<title>reveal.js</title>

<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">

<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">

<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<div class="reveal">
<div class="slides">
<section>
<section data-markdown>
<textarea data-template>
# Open Is Good
</textarea>
<textarea data-template>
# Open Is Good
</textarea>
</section>
</section>
<section>
<section data-markdown>
<textarea data-template>
## A Short History of OOP
<textarea data-template>
## A Short History of OOP
* Simula 60, 68
* Smalltalk 72, 80
* (~1985 - Common Lisp Object System)
* 90's: OOP gonna save the world
* C++, Java, ...
* 10's: OOP discredited
</textarea>
</textarea>
</section>
</section>
<section>
<section data-markdown class="center">
<textarea data-template>
## The Expression Problem
<textarea data-template>
## The Expression Problem
behaviors += types
types += behavior
</textarea>
</textarea>
</section>
<section data-markdown class="center">
<textarea data-template>
## behavior += types
<textarea data-template>
## behavior += types
OOP languages are good at this
</textarea>
</textarea>
</section>
<section data-markdown class="center">
<textarea data-template>
## types += behaviors
<textarea data-template>
## types += behaviors
functional languages are good at this
</textarea>
</textarea>
</section>
<section data-markdown class="center">
<textarea data-template>
## Multi Layered Architectures
<textarea data-template>
## Multi Layered Architectures
- domain objects
- \+ persistence
- \+ presentation
</textarea>
</textarea>
</section>
</section>
<section>
Expand Down Expand Up @@ -144,34 +144,34 @@
</section>
<section>
<section data-markdown>
<textarea data-template>
## TODO
<textarea data-template>
## TODO
- support templatized methods
- understand why gdc class-to-class calls are so fast
- improve speed of interface-to-class calls
- understand why finding perfect hash with dmd takes so much longer to find than with ldc
- write a guide / implementation notes
</textarea>
</textarea>
</section>
</section>
</div>
</div>
</div>
</div>

<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>

<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>
25 changes: 13 additions & 12 deletions source/openmethods.d
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,10 @@ auto removeStorageClasses(rf.Parameter[] parameters)
return parameters.map!(p => p.withStorageClasses([])).array;
}

struct Method(alias module_, string name, int index)
struct Method(string module_, string name, int index)
{
alias Module = module_;
mixin("static import ", module_, ";");
alias Module = mixin(module_);
enum Name = name;
enum Index = index;

Expand Down Expand Up @@ -582,11 +583,11 @@ struct Method(alias module_, string name, int index)
.mixture);

enum aliases = q{
alias %s = openmethods.Method!(%s, "%s", %d).dispatcher;
alias %s = openmethods.Method!(%s, "%s", %d).discriminator;
alias %s = openmethods.Method!("%s", "%s", %d).dispatcher;
alias %s = openmethods.Method!("%s", "%s", %d).discriminator;
}.format(
Name, __traits(identifier, Module), Name, Index,
Name, __traits(identifier, Module), Name, Index);
Name, module_, Name, Index,
Name, module_, Name, Index);

// ==========================================================================
// Method Registration
Expand Down Expand Up @@ -651,7 +652,7 @@ struct Method(alias module_, string name, int index)
// ==========================================================================
// Exceptions

static ReturnType notImplementedError(QualParams...)
static ReturnType notImplementedError(/+ QualParams... +/)
{
import std.meta;
errorHandler(new MethodError(MethodError.NotImplemented, &info));
Expand All @@ -660,7 +661,7 @@ struct Method(alias module_, string name, int index)
}
}

static ReturnType ambiguousCallError(QualParams...)
static ReturnType ambiguousCallError(/+ QualParams... +/)
{
errorHandler(new MethodError(MethodError.AmbiguousCall, &info));
static if (!is(ReturnType == void)) {
Expand Down Expand Up @@ -779,7 +780,7 @@ unittest
static assert(!hasVirtualParameters!nonmeth);
}

string registrationMixture(alias MODULE, alias moduleName)()
string registrationMixture(alias MODULE, string moduleName)()
{
import std.array;

Expand All @@ -789,7 +790,7 @@ string registrationMixture(alias MODULE, alias moduleName)()
static if (is(typeof(__traits(getOverloads, MODULE, m)))) {
foreach (i, o; __traits(getOverloads, MODULE, m)) {
static if (hasVirtualParameters!(o)) {
mixture ~= openmethods.Method!(MODULE, m, i).aliases;
mixture ~= openmethods.Method!(moduleName, m, i).aliases;
}
}
}
Expand All @@ -804,7 +805,7 @@ string registrationMixture(alias MODULE, alias moduleName)()
return join(mixture, "\n");
}

mixin template registrar(alias MODULE, alias ModuleName)
mixin template registrar(alias MODULE, string ModuleName)
{
import openmethods;
import std.traits;
Expand All @@ -815,7 +816,7 @@ mixin template registrar(alias MODULE, alias ModuleName)
static if (is(typeof(__traits(getOverloads, MODULE, m)))) {
foreach (i, o; __traits(getOverloads, MODULE, m)) {
static if (hasVirtualParameters!(o)) {
openmethods.Method!(MODULE, m, i).register;
openmethods.Method!(ModuleName, m, i).register;
}
}
}
Expand Down
42 changes: 22 additions & 20 deletions tests/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@
"license": "Boost Software License 1.0",
"name": "tests",
"targetType": "library",
"dflags": ["-mixin=mixins.txt"],
"importPaths": ["../source", "source"],
"dependencies": {
"openmethods": "*"
"dflags": ["-mixin=mixins.txt"],
"importPaths": ["../source", "source"],
"dependencies": {
"openmethods": {
"path": "../",
}
},
"buildTypes": {
"x": {
"debugVersions": ["explain"],
"buildOptions": ["debugMode", "debugInfo", "unittests"],
},
"xtc": {
"debugVersions": ["explain", "traceCalls"],
"buildOptions": ["debugMode", "debugInfo", "unittests"],
},
},
"configurations": [
{
"name": "unittest",
"dflags": ["-mixin=mixins.txt"],
},
]
"buildTypes": {
"x": {
"debugVersions": ["explain"],
"buildOptions": ["debugMode", "debugInfo", "unittests"],
},
"xtc": {
"debugVersions": ["explain", "traceCalls"],
"buildOptions": ["debugMode", "debugInfo", "unittests"],
},
},
"configurations": [
{
"name": "unittest",
"dflags": ["-mixin=mixins.txt"],
},
]
}
Loading

0 comments on commit eb72dcd

Please sign in to comment.