Skip to content

Commit

Permalink
[D][core] refactored kiwi.core directory structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
nical committed Sep 2, 2011
1 parent 8d89ce7 commit 5eb353f
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 59 deletions.
2 changes: 1 addition & 1 deletion d/ALL.sh
@@ -1,3 +1,3 @@

echo "--test.kiwi.core"
dmd -Iinclude/extern -debug -unittest -g -odbin/ -ofbin/core_test src/kiwi/*.d src/kiwi/dynamic/*.d src/kiwi/utils/*.d src/kiwi/graph/*.d src/kiwi/text/*.d src/extern/*/*.d test/core.d && echo "--done" && ./bin/core_test || echo "\033[1;31m\n--error\033[0m\n"
dmd -Iinclude/extern -debug -unittest -g -odbin/ -ofbin/core_test src/kiwi/core/*.d src/kiwi/dynamic/*.d src/kiwi/utils/*.d src/kiwi/graph/*.d src/kiwi/text/*.d src/extern/*/*.d test/core.d && echo "--done" && ./bin/core_test || echo "\033[1;31m\n--error\033[0m\n"
5 changes: 5 additions & 0 deletions d/src/kiwi/core/all.d
@@ -0,0 +1,5 @@
module kiwi.core.all;

public import kiwi.core.base;
public import kiwi.core.commons;
public import kiwi.core.data;
8 changes: 4 additions & 4 deletions d/src/kiwi/core.d → d/src/kiwi/core/base.d
@@ -1,7 +1,7 @@
module kiwi.core;
module kiwi.core.base;
// kiwi imports
import kiwi.commons;
import kiwi.data;
import kiwi.core.commons;
import kiwi.core.data;
// external imports
import std.string;
import std.conv;
Expand Down Expand Up @@ -349,7 +349,7 @@ public:
+/
Data data();

void data( kiwi.core.Data value );
void data( kiwi.core.base.Data value );
//in{ if( dataType !is null && value !is null ) assert( data.type is dataType ); }

} //properties
Expand Down
2 changes: 1 addition & 1 deletion d/src/kiwi/commons.d → d/src/kiwi/core/commons.d
@@ -1,4 +1,4 @@
module kiwi.commons;
module kiwi.core.commons;
/*
* TODO: Dirty stuff here. needs cleanup
*
Expand Down
4 changes: 2 additions & 2 deletions d/src/kiwi/data.d → d/src/kiwi/core/data.d
@@ -1,6 +1,6 @@
module kiwi.data;
module kiwi.core.data;
//
import kiwi.commons;
import kiwi.core.commons;
//
import std.typecons;
import std.traits;
Expand Down
4 changes: 1 addition & 3 deletions d/src/kiwi/dynamic/compatibility.d
Expand Up @@ -4,9 +4,7 @@
+/
module kiwi.dynamic.compatibility;

import kiwi.commons;
import kiwi.data;
import kiwi.core;
import kiwi.core.all;
import kiwi.dynamic.port;


Expand Down
6 changes: 2 additions & 4 deletions d/src/kiwi/dynamic/node.d
@@ -1,8 +1,6 @@
module kiwi.dynamic.node;

import kiwi.commons;
import kiwi.core;
import kiwi.data;
import kiwi.core.all;
import kiwi.dynamic.port;

import std.typecons;
Expand Down Expand Up @@ -101,7 +99,7 @@ private:
}


Node NewContainerNode( kiwi.core.Data data )
Node NewContainerNode( kiwi.core.base.Data data )
{
mixin( logFunction!"NewContainerNode" );

Expand Down
10 changes: 5 additions & 5 deletions d/src/kiwi/dynamic/nodegroup.d
@@ -1,13 +1,13 @@
module kiwi.dynamic.nodegroup;

import kiwi.core;
import kiwi.commons;
import kiwi.core.base;
import kiwi.core.commons;
import kiwi.dynamic.node;

import kiwi.graph.traversal;
import kiwi.graph.acyclic;


class NodeGroup : kiwi.core.NodeGroup
class NodeGroup : kiwi.core.base.NodeGroup
{
enum{ NOT_READY = 0, READY = 1, SORTED = 2, OPTIMIZED = 4 }

Expand Down Expand Up @@ -59,7 +59,7 @@ class NodeGroup : kiwi.core.NodeGroup

void prepare()
{
_sortedNodes = acyclicOrderedNodes( _nodes );
_sortedNodes = OrderedNodes( _nodes );
}

bool isReady()
Expand Down
10 changes: 4 additions & 6 deletions d/src/kiwi/dynamic/port.d
@@ -1,8 +1,6 @@
module kiwi.dynamic.port;

import kiwi.core;
import kiwi.data;
import kiwi.commons;
import kiwi.core.all;



Expand Down Expand Up @@ -90,7 +88,7 @@ class DynamicOutputPort : OutputPort
bool isCompatible( InputPort port ){ return (port !is null); }

}
@property void data( kiwi.core.Data value ){ _data = value; }
@property void data( kiwi.core.base.Data value ){ _data = value; }
private:
string _name;
Data _data;
Expand Down Expand Up @@ -126,7 +124,7 @@ version(unittest)
return new ContainerTest();
}

class SubContainerTest : kiwi.core.Data
class SubContainerTest : kiwi.core.base.Data
{
static this()
{
Expand All @@ -142,7 +140,7 @@ version(unittest)
private static DataTypeInfo _typeInfo;
}

class ContainerTest : kiwi.core.Data
class ContainerTest : kiwi.core.base.Data
{
mixin DeclareSubDataTypes!(SubContainerTest,SubContainerTest);

Expand Down
32 changes: 16 additions & 16 deletions d/src/kiwi/graph/acyclic.d
@@ -1,18 +1,18 @@
module kiwi.graph.traversal;
module kiwi.graph.acyclic;

import kiwi.core;
import kiwi.commons;
import kiwi.core.base;
import kiwi.core.commons;

import std.range;


bool isAcyclic( Node[] )
bool IsAcyclic( Node[] )
{
throw new NotImplementedYetException("kiwi.graph.traversal.isAcyclic", __FILE__, __LINE__);
}


Node[] directDependencies(Node n)
Node[] DirectDependencies(Node n)
in
{
assert( n !is null );
Expand All @@ -27,29 +27,29 @@ body
return result;
}

Node[] indirectDependencies(Node n)
Node[] IndirectDependencies(Node n)
in
{
assert( n !is null );
}
body
{
Node[] result = [];
foreach ( dep ; directDependencies(n) )
foreach ( dep ; DirectDependencies(n) )
{
result ~= indirectDependencies(n);
result ~= IndirectDependencies(n);
result ~= n;
}

return result;
}


Node[] acyclicOrderedNodes( Node[] nodes )
Node[] OrderedNodes( Node[] nodes )
{
Node[] result = [];
foreach ( node ; nodes )
_recAcyclicOrdered( nodes, result, node );
_recOrdered( nodes, result, node );

return result;
}
Expand Down Expand Up @@ -92,14 +92,14 @@ private Node[] _intersection(Node[] r1, Node[]r2)
return result;
}

void _recAcyclicOrdered(ref Node[] nodes, ref Node[] result, Node n)
void _recOrdered(ref Node[] nodes, ref Node[] result, Node n)
{
mixin( logFunction!"_recAcyclicOrdered" );
mixin( logFunction!"_recOrdered" );
if ( !_contains(result, n) && (nodes.length == 0 || _contains(nodes, n)) )
{
foreach ( n_in ; n.inputs )
if ( n_in.isConnected )
_recAcyclicOrdered( nodes, result, n_in.connections[0].node );
_recOrdered( nodes, result, n_in.connections[0].node );
for(int i=0; i<nodes.length; ++i)
if( nodes[i] is n ) log.writeln(i);
result ~= n;
Expand All @@ -123,7 +123,7 @@ version(unittest)

unittest
{
mixin( logTest!"kiwi.graph.traversal" );
mixin( logTest!"kiwi.graph.acyclic" );

Node[] nodes = [];

Expand All @@ -147,7 +147,7 @@ unittest
nodes[0].output() >> nodes[3].input();

// compute the direct dependencies of nodes[0]
auto n0_dependencies = directDependencies( nodes[0] );
auto n0_dependencies = DirectDependencies( nodes[0] );

// check that nodes[0]'s dependencies are nodes[2] and nodes[1]
assert( n0_dependencies.length == 2 );
Expand All @@ -158,7 +158,7 @@ unittest
assert( _isBefore( nodes, nodes[1], nodes[3]) );
assert( !_isBefore( nodes, nodes[3], nodes[1]) );

Node[] sortedNodes = acyclicOrderedNodes( nodes );
Node[] sortedNodes = OrderedNodes( nodes );
log.writeln("nodes.length", nodes.length);
log.writeln("sortedNodes.length", sortedNodes.length);
assert( sortedNodes.length == nodes.length );
Expand Down
7 changes: 3 additions & 4 deletions d/src/kiwi/text/basicfilters.d
@@ -1,12 +1,11 @@
module kiwi.text.basicfilters;

import kiwi.text.data;
import kiwi.commons;
import kiwi.core;
import kiwi.data;

import kiwi.core.all;
import kiwi.dynamic.node;
import kiwi.dynamic.port;
import kiwi.dynamic.compatibility;
import kiwi.text.data;

import std.string;
import std.array;
Expand Down
8 changes: 3 additions & 5 deletions d/src/kiwi/text/data.d
@@ -1,13 +1,11 @@
module kiwi.text.data;

import kiwi.core;
import kiwi.commons;
import kiwi.data;
import kiwi.core.all;


Data NewPlainTextContainer(){ return new PlainTextContainer; }

class PlainTextContainer : kiwi.core.Data
class PlainTextContainer : kiwi.core.base.Data
{
static this(){
_typeInfo = DataTypeManager.Register!PlainTextContainer();
Expand All @@ -25,7 +23,7 @@ class PlainTextContainer : kiwi.core.Data
override{
//bool serialize(DataStream stream){ return false; }
//bool deSerialize(const DataStream stream){ return false; }
@property kiwi.core.Data[] subData(){ return []; }
@property kiwi.core.base.Data[] subData(){ return []; }

DataTypeInfo type(){ return _typeInfo; }
}
Expand Down
4 changes: 1 addition & 3 deletions d/src/kiwi/utils/mock.d
Expand Up @@ -6,9 +6,7 @@
+/
module kiwi.utils.mock;

import kiwi.core;
import kiwi.data;
import kiwi.commons;
import kiwi.core.all;
import kiwi.dynamic.node;
import kiwi.dynamic.port;
import kiwi.dynamic.compatibility;
Expand Down
6 changes: 1 addition & 5 deletions d/test/core.d
Expand Up @@ -2,14 +2,10 @@ module test.core;

//import dtools.testing;

import kiwi.commons;
import kiwi.core.all;
import kiwi.dynamic.port;
import kiwi.dynamic.node;
import kiwi.dynamic.compatibility;
import kiwi.core;
import kiwi.data;




// ---------------------------------------------------------------------
Expand Down

0 comments on commit 5eb353f

Please sign in to comment.