Re: Linux dll -> Windows dll

2014-01-25 Thread Benjamin Thaut

Am 25.01.2014 04:13, schrieb Mineko:

Alright.. I've been having issues with getting windows DLL's to work
with DMD, as in I can't make them and can't even compile without a bunch
of errors.

So, I need help on that, as the dll part of the site ain't helping.

Also, any idea on how to convert some of the dll stuff on
https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/utility/core.d
to be windows compatible, I was having weird issues with that also.


Windows Dlls are fundamentally broken. The only thing that works at the 
moment are DLLs with a C-Interface (written in D). DLL support on 
Windows is nowhere near the shared library support on linux.
I tried pushing for a fix, but its currently not a priority. See 
http://wiki.dlang.org/DIP45


Kind Regards
Benjamin Thaut


Re: shared methods

2014-01-25 Thread Johannes Pfau
Am Fri, 24 Jan 2014 22:30:13 +
schrieb "Kagamin" :

> http://igoro.com/archive/volatile-keyword-in-c-memory-model-explained/
> As I understand, because Itanium doesn't have cache coherency, a 
> memory fence is needed to implement volatile load and store. On 
> x86 load and store are already volatile because of cache 
> coherency, so fences are not needed.

Seems like C#s volatile cares about "compiler optimizations and
processor optimizations.". I'd rather want a volatile for D (or as a
base for shared) which only cares about compiler optimizations, leaving
the processor part to the programmer.

(For example it isn't valid in D to access a shared variable with
normal operations anyway, AFAIK. You need to use the atomicOp things
and these will the worry about the hardware part, using the correct
instructions and so on)

See also:
http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484

So volatile is a completely different thing in C#/JAVA and C/C++. This
is why I'm confused, C compilers are not supposed to guarantee that
another thread can see all changes to a volatile variable, volatile must
just prevent compiler optimizations. So if Itanium C compilers
automatically use the barrier/fence instructions for volatile that's
IMHO a compiler performance bug.

I also can't find any information the GCC adds barriers on Itanium.
Maybe this is just true for the Intel compiler, as the main source for
these claims are Intel pages.


ODBC SQLBindParameter for string array

2014-01-25 Thread Andre

Hi,

I have some issues with the ODBC SQLBindParameter. I already
achieved to add an array of integers but the scenario of writting
a string array is not working.
While doing the INSERT statement 3 rows are added to the
database. The first row has the correct value "A". The second row
has not value instead of "B". And the third row has a strange
value and the character 'P' instead of "C".

Do you have some idea?

Kind regards
André

// CREATE TABLE demo(name VARCHAR(1))
// INSERT INTO demo (name) VALUES (?)

string[] stringArr = ["A","B","C"];

SQLSetStmtAttr(hStmt, SQL_ATTR_PARAMSET_SIZE,
   cast(SQLPOINTER) stringArr.length, 0);
SQLSetStmtAttr(hStmt, SQL_ATTR_PARAM_BIND_TYPE,  cast(SQLPOINTER)
   SQL_PARAM_BIND_BY_COLUMN, 0);
SQLINTEGER[] lengIndArr = new SQLINTEGER[](table.rowCount);

// Get max length, in this example always: 1
int maxLength = 0;
foreach(str;stringArr){
   if(str.length > maxLength){
 maxLength = str.length;
   }
}

// SQLCHAR is defined as ubyte
SQLCHAR[][] charArr = new SQLCHAR[][](stringArr.length, maxLength
+ 1);
// +1 for \0 character

foreach(i, str;stringArr){
   charArr[i] =   cast(SQLCHAR[]) (str~"\0");
   lengIndArr[i] = SQL_NTS; // Null terminated string
}

SQLBindParameter( hStmt, cast(SQLUSMALLINT) 1, cast(SQLSMALLINT)
   SQL_PARAM_INPUT, cast(SQLSMALLINT)SQL_C_CHAR,
cast(SQLSMALLINT)SQL_VARCHAR,
   maxLength, 0, charArr[0].ptr , maxLength + 1, lengIndArr.ptr);


Re: How to skip permission denied exceptions if iterate through directories?

2014-01-25 Thread Clas Onnebrink
On Saturday, 25 January 2014 at 02:26:20 UTC, Rikki Cattermole 
wrote:
On Friday, 24 January 2014 at 23:46:04 UTC, Clas Onnebrink 
wrote:


Hi,

Im a newbie in D and I have a small problem. Thats my method

//*
  private void searchAndRunAction() {
 foreach (entry;dirEntries(paramPath,
   paramSearchType,
   (paramSwitchRecursiveOn ? 
SpanMode.breadth : SpanMode.shallow)))

 {
filesCount++;

if (isDuplicate(entry.name)) {
   filesDupCount++;
   if (paramSwitchDeleteOn)
  remove(entry.name);
}

printProgress(entry.name);
 }
  }

I want work through a directory on my linux server but there 
are some

directories I have no permissions to access so I get following:

~/Projects/cltools/smdups $ source/smdups -r 
-p=/media/clas/Elements2 -e=*.*
std.file.FileException@../../../../src/libphobos/src/std/file.d(2353): 
/media/clas/Elements2/lost+found: Permission denied


/home/clas/Projects/cltools/smdups/source/smdups() [0x43cb1d]
/home/clas/Projects/cltools/smdups/source/smdups() [0x43eab4]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404768]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404116]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404d2d]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41a71f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41ae7f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41b0b0]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41ae7f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41b018]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) 
[0x7f66a29c8de5]

/home/clas/Projects/cltools/smdups/source/smdups() [0x403e63]

~/Projects/cltools/smdups $ 
std.file.FileException@../../../../src/libphobos/src/std/file.d(2353): 
/media/clas/Elements2/lost+found: Permission denied
std.file.FileException@../../../../src/libphobos/src/std/file.d(2353):: 
command not found


My question: How to skip any exceptions in dirEntries. I tried 
it with filter.
But no chance. Is there a way to do it like in C# with 
LINQ-Expressions?


greets

clas


One way would just be to catch the exceptions. Note you may 
want to activate debug mode to know what functions are actually 
failing.
A FileException is being fired when it cannot do a file 
operation as detailed in phobos documentation.


To catch the exception dont solve it. Because if dirEntries 
throws an exception then it doesnt going on through the 
directories. I need dirEntries step over directories where I have 
no permissions whithout raise exceptions.


automatic type creation

2014-01-25 Thread Frustrated

I'd like to support extensions of my own interfaced based design
where anyone could simply "drop" in there own inherited classes
and everything would work as if they designed everything using
those classes from the get go.

To do this though, I need a way to know how to generate these
unknown types(except I know the inherit the interface I have
designed).

e.g.,

interface A
{
static final A New()
{
return new myA;  // we have to return something tangible
that acts like A.
}

}

class myA : A//never used directly except as a "base" for
actual work, A is used as the reference type in all programming
and myA is "hidden".
{

}

class anotherA  : A // someone elses A, not known at all at
compile time. This may be generated by a dll at some future point
{

}

...

In the production code, myA, anotherA, and any other class based
on A will never be used, only the interface A.

e.g.,

auto a = A.New();

which obviously returns a myA. I do not want this if the anotherA
is now meant to be used, that is, the user of the code wants to
redefine the behavior of all the code I write by plugging in
their own class implementation instead of using mine.

This is all fine and dandy and easy to accomplish by adding a
static delegate A which can then be overridden to return anotherA
after the fact.


The method I'm actually using is to use a template that
essentially returns the concrete implementation of any interface
I have designed. This then produces identical results as if I
just used classes directly but by using interfaces too I can have
multiple inheritance. But as far as coding is concerned I just
use the interfaces but any time I "new" an interface it's
corresponding class is returned.

Of course, the problem with this is that it's an either or
approach. Either my implementation is completely used or not.

What I'd really like is a way to create objects for the
interfaces that at any point could be any one of the
implementations of the interface.

This way, essentially, the following could be done:

auto a = A.New(); // returns myA

//somewhere else were an anotherA is meant to be used:

auto b = A.New(); // returns anotherA

which, of course, as is, won't work unless New somehow knew when
it was suppose to use myA's and use anotherA's(Which would be
cool if it could because then the user could replace my
implementations selectively where ever it wants).

The only thing I can think of that might work is to supply a
parameter to New that tells it which object to return and allow
the user to add their own creation mechanism to the delegate(sort
of like allowing them to add to a switch statement dynamically).

I'd then have to save/restore dynamically the parameter at every
New() call so it is never hard coded(which would allow it to be
changed how ever and the change would persist in the program).


I will give you an example:

Suppose you have an Icon interface that draws icons and allows
interaction and all that. You also implement a "default" type of
icon that simply displays the icon image.

Now suppose you want to allow others to write their own
implementations. Say someone want's to add right mouse button
properties to it, the ability to "execute" the icon, etc.

As far as you are concerned within the own logic of your program,
it matters not what they do. You want icons to be used in a
specific way, say to be visualized on a desktop. If people want
to expand on your idea still within some constraint of the
interface, you have no problem with that.

While you can predict all possible uses and you can write code in
a way that might satisfy everyone's implementation ideas, you can
at least, allow them to implement the interface on their own and
possibly provide them with some generic stuff that "most" people
would need. The main thing is, you have the interface to work
with and they supply that at a minimum so their implement will
"plug and play".

BUT!!! What if 10 people implement 10 completely and all cool
icon classes and you want some way to allow all 10 to be used in
any way desired. If the user wants 1 of each they can have it.

In this case you can't use the all or nothing approach. Each
implementation still is "plug and play" but how to allow any to
be used when it is suppose to?

This necessitates that New is more complex. A sort of factory
that has some idea on it's own which type of object it is suppose
to return *when*.

It would be very similar to the Dependency Injection pattern but
because it occurs at creation this is impossible(and static
injection of the creation mechanism doesn't seem very safe nor
"generic").

So, in my own code I would have many lines of code that use
something like "new myIcon;", which forces me to use my own
implementation. If I changed it to a sort of static factory I
might have "Icon.New()" which returns whatever specific
implementation but for all further created icons until it is
changed again. (that is, Icon.New() is a so

sqlite_mismatch using etc.c.sqlite3

2014-01-25 Thread Jacho Mendt
Hello everyone, I'm currently working on a prototype database 
system, but I'm kinda new to D and to sqlite3. The fragment of 
code that gives me problems looks like this:


extern(C) int myCallback(void *a_parm, int argc, char **argv,
char **column)
{
 return 0;
}



int new_entity(sqlite3* db)
{
const(char)* sql="SELECT ID FROM ENTITY;";
int result;
result=sqlite3_exec(db,sql,&myCallback,null,null);
writeln(result);
if (SQLITE_OK!=result)
{ return -1;}
return 0;
}

sqlite3_exec here returns 21, wich is the code for 
SQLITE_MISMATCH. I know I'm doing something wrong, i just can't 
find what.


Re: How to skip permission denied exceptions if iterate through directories?

2014-01-25 Thread simendsjo

On Friday, 24 January 2014 at 23:46:04 UTC, Clas Onnebrink wrote:
(...)


I want work through a directory on my linux server but there 
are some

directories I have no permissions to access so I get following:

~/Projects/cltools/smdups $ source/smdups -r 
-p=/media/clas/Elements2 -e=*.*
std.file.FileException@../../../../src/libphobos/src/std/file.d(2353): 
/media/clas/Elements2/lost+found: Permission denied


/home/clas/Projects/cltools/smdups/source/smdups() [0x43cb1d]
/home/clas/Projects/cltools/smdups/source/smdups() [0x43eab4]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404768]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404116]
/home/clas/Projects/cltools/smdups/source/smdups() [0x404d2d]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41a71f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41ae7f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41b0b0]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41ae7f]
/home/clas/Projects/cltools/smdups/source/smdups() [0x41b018]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) 
[0x7f66a29c8de5]

/home/clas/Projects/cltools/smdups/source/smdups() [0x403e63]

~/Projects/cltools/smdups $ 
std.file.FileException@../../../../src/libphobos/src/std/file.d(2353): 
/media/clas/Elements2/lost+found: Permission denied
std.file.FileException@../../../../src/libphobos/src/std/file.d(2353):: 
command not found


My question: How to skip any exceptions in dirEntries. I tried 
it with filter.
But no chance. Is there a way to do it like in C# with 
LINQ-Expressions?


greets

clas



This seems more difficult than i thought. Catching the exception 
doesn't help as there is no way to skip the item in question. The 
exception is being fired on popFront(), but I think the correct 
way would be to fire the exception on calling front() instead so 
you're able to skip to the next item.



import std.file, std.stdio;
void main() {
auto dit = dirEntries("/tmp", SpanMode.breadth, true);
while(!dit.empty) {
try
dit.popFront(); // Fill front()
catch(Exception ex) {
writeln("OOPS: ", ex);
// We should be able to skip the file here
}
/* do something with dit.front */
}
}


Re: Linux dll -> Windows dll

2014-01-25 Thread Mineko
Ok thank both of you, looks like I really will have to wait on 
Windows DLL's.


Re: Profiling

2014-01-25 Thread Philippe Sigaud
On Fri, Jan 24, 2014 at 10:25 PM, Benjamin Thaut  wrote:
> What Plattform are you profiling on?

Linux  32bits. Does it change something? I'm not using any OS-specific
part of Phobos, AFAICT.


Generating an enum from a tuple of Types?

2014-01-25 Thread Johannes Pfau
Is it possible to generate a enum from a tuple of types without string
mixins?

struct S(Types...)
{
enum Tag
{
//?
}
}


where the tag enum should have Types.length members. The exact names of
the enum members don't matter and could be numbered, for example:
Tag._1, Tag._2, ...

This is what I have right now, using string mixins:
http://dpaste.dzfl.pl/536e0be9

It implements a simple C-like tagged union in a generic way, so stuff
like this is possible:

---
alias Value = TaggedUnion!(int, string);
auto val = Value("Hello");
auto vals = val.get!string();
val.set(0);
final switch(val.tag)
{
case Value.tagType!int:
break;
case Value.tagType!string:
break;
}
---

It's basically std.variant Algebraic with less features, but it should
be much faster as it doesn't use TypeInfo.


Re: Generating an enum from a tuple of Types?

2014-01-25 Thread Stanislav Blinov

On Saturday, 25 January 2014 at 15:38:39 UTC, Johannes Pfau wrote:
Is it possible to generate a enum from a tuple of types without 
string

mixins?

struct S(Types...)
{
enum Tag
{
//?
}
}





Without mixins altogether... dunno. But nothing stops you from 
making a eponymous template :)


http://dpaste.dzfl.pl/0af9dd7e


Re: Generating an enum from a tuple of Types?

2014-01-25 Thread Dicebot
If one wants to generate code with new identifiers, usage of 
string mixins is pretty much unavoidable.


Re: Generating an enum from a tuple of Types?

2014-01-25 Thread Artur Skawina
On 01/25/14 16:38, Johannes Pfau wrote:
> Is it possible to generate a enum from a tuple of types without string
> mixins?
> 
> struct S(Types...)
> {
> enum Tag
> {
> //?
> }
> }
> 
> 
> where the tag enum should have Types.length members. The exact names of
> the enum members don't matter and could be numbered, for example:
> Tag._1, Tag._2, ...

Well, if you don't need names then just use the index directly.

Eg, see 'DiscUnion.type' in 

http://forum.dlang.org/thread/mtkzbwfgwsstndxbe...@forum.dlang.org#post-mailman.555.1377703234.1719.digitalmars-d-learn:40puremagic.com

(A newer compiler may allow for that offset-of calculation at CT)

artur


Re: Generating an enum from a tuple of Types?

2014-01-25 Thread Johannes Pfau
Am Sat, 25 Jan 2014 18:55:54 +0100
schrieb Artur Skawina :

> 
> Well, if you don't need names then just use the index directly.
> 
> Eg, see 'DiscUnion.type' in 
> 
> http://forum.dlang.org/thread/mtkzbwfgwsstndxbe...@forum.dlang.org#post-mailman.555.1377703234.1719.digitalmars-d-learn:40puremagic.com
> 
> (A newer compiler may allow for that offset-of calculation at CT)
> 
> artur

Thanks for all the answers, I guess I'll keep the string mixin.
I don't really need the names but I need the enum to support final
switch.


Re: shared methods

2014-01-25 Thread Kagamin

On Saturday, 25 January 2014 at 10:00:58 UTC, Johannes Pfau wrote:
(For example it isn't valid in D to access a shared variable 
with
normal operations anyway, AFAIK. You need to use the atomicOp 
things
and these will the worry about the hardware part, using the 
correct

instructions and so on)


Is it invalid to access shared data on stack too? How about 
closures?



See also:
http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484

So volatile is a completely different thing in C#/JAVA and 
C/C++. This
is why I'm confused, C compilers are not supposed to guarantee 
that
another thread can see all changes to a volatile variable, 
volatile must

just prevent compiler optimizations. So if Itanium C compilers
automatically use the barrier/fence instructions for volatile 
that's

IMHO a compiler performance bug.


The standard says "memory" and doesn't address cache and 
processor optimizations, so it probably allows different 
interpretations. Even if there's no fence, disallowed compiler 
optimizations are still a performance hit - on all platforms.


Re: shared methods

2014-01-25 Thread Kagamin
Also if you read a shared value with atomicLoad every time, this 
disallows caching in registers or on stack, which is also 
performance hit. The shared value should be read once and cached 
if possible.


dmd compile large project

2014-01-25 Thread Erik van Velzen
I just downloaded a larger project from Github without a build 
script or anything.


Is there an easy way to compile it to a library or object files?


Re: dmd compile large project

2014-01-25 Thread Uplink_Coder

try dub :D


Re: dmd compile large project

2014-01-25 Thread Dicebot
On Saturday, 25 January 2014 at 22:01:59 UTC, Erik van Velzen 
wrote:
I just downloaded a larger project from Github without a build 
script or anything.


Is there an easy way to compile it to a library or object files?


If it has "package.json" file in root, that it is a dub 
(http://code.dlang.org/download) project. Another option can be 
that author simply expects you to do `rdmd main.d` but that is 
very unlikely for larger project.


Re: dmd compile large project

2014-01-25 Thread Erik van Velzen
Thanks for the input I was thinking there maybe was an easy way 
that I wasn't aware of.


I only wanted to use a small part of the project so I just made a 
list of those files and their dependencies and compiled that.


Re: shared methods

2014-01-25 Thread Johannes Pfau
Am Sat, 25 Jan 2014 21:41:20 +
schrieb "Kagamin" :

> On Saturday, 25 January 2014 at 10:00:58 UTC, Johannes Pfau wrote:
> > (For example it isn't valid in D to access a shared variable 
> > with
> > normal operations anyway, AFAIK. You need to use the atomicOp 
> > things
> > and these will the worry about the hardware part, using the 
> > correct
> > instructions and so on)
> 
> Is it invalid to access shared data on stack too? How about 
> closures?
> 

I'm not sure about the details - shared hasn't been completely
implemented or even specified yet. AFAIK the most recent idea was that
shared does basically nothing but prevents direct access to variables.
Synchronized statements then remove the shared qualifier and you can
access the variables as usual. Atomic OPs also work with shared
variables. Using locks manually then probably requires casting away
shared.

However, this part of the language is really unfinished. I hoped we
could at least use shared as a replacement for volatile, but as you
said in your other reply we probably can't.



Re: shared methods

2014-01-25 Thread Johannes Pfau
Am Sat, 25 Jan 2014 21:48:39 +
schrieb "Kagamin" :

> Also if you read a shared value with atomicLoad every time, this 
> disallows caching in registers or on stack, which is also 
> performance hit. The shared value should be read once and cached 
> if possible.

Yes, I came to the same conclusion. If we combine volatile
and shared into one qualifier we'll always have a certain performance
hit.

Great, now we have to convince Walter that we have to undeprecate
volatile for embedded programming...


Good ol' OpenGL D-C interfacing. :(

2014-01-25 Thread Mineko
Alright.. For the record, I've been searching on how to fix this 
for 2 hours now, so yeah.


Anyway, here's the issue, and it's probably half OpenGL being 
well.. OpenGL, and the other half being D-C interfacing.


Point is, I'm trying to draw a triangle with a custom Triangle 
class I made, and I'm having issues, relevant code is here:

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/scene.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/utility/graphics/primitives.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/res/shaders/testShader.glsl

I assume this is probably me messing up with arrays and sizing, 
but I've done what I can as far as that goes so.. Maybe one of 
you know what to do.


Xor trick?

2014-01-25 Thread bearophile
Do you know how to perform the xor trick 
(http://en.wikipedia.org/wiki/XOR_swap_algorithm ) on two 
pointers in D?


This is a try:


void foo(T)(ref T x, ref T y) pure nothrow {
x ^= y;
y ^= x;
x ^= y;
}
void main() {
int* p, q;
foo(p, q);
}


Currently that gives:

test.d(2): Error: 'x' is not of integral type, it is a int*
test.d(2): Error: 'y' is not of integral type, it is a int*
test.d(3): Error: 'y' is not of integral type, it is a int*
test.d(3): Error: 'x' is not of integral type, it is a int*
test.d(4): Error: 'x' is not of integral type, it is a int*
test.d(4): Error: 'y' is not of integral type, it is a int*
test.d(8): Error: template instance test.foo!(int*) error 
instantiating


Bye,
bearophile


Re: Xor trick?

2014-01-25 Thread Martin Cejp

That's what you get for trying to be a smartass!

Seriously though, why would you want to do this? It's not 
actually faster or anything, you know.


Re: Xor trick?

2014-01-25 Thread Adam D. Ruppe

On Sunday, 26 January 2014 at 00:04:08 UTC, bearophile wrote:
Do you know how to perform the xor trick 
(http://en.wikipedia.org/wiki/XOR_swap_algorithm ) on two 
pointers in D?


You don't; it is undefined behavior and could lead to crashes. 
Suppose another thread triggers a GC run right after the first 
xor. Then there may be no valid pointers to *x and the GC frees 
it, so then after the swap, *y points to something entirely 
different.



test.d(2): Error: 'x' is not of integral type, it is a int*


You could cast it to size_t, then the compiler will let you do 
the operation, but casting pointers to and from integers means 
you take matters of correctness into your own hands.


Re: Xor trick?

2014-01-25 Thread bearophile

Adam D. Ruppe:

You could cast it to size_t, then the compiler will let you do 
the operation, but casting pointers to and from integers means 
you take matters of correctness into your own hands.


Right, so I have to carry around size_t instead of pointers.

Bye and thank you,
bearophile


Re: Xor trick?

2014-01-25 Thread Ali Çehreli

On 01/25/2014 04:08 PM, Martin Cejp wrote:

That's what you get for trying to be a smartass!

Seriously though, why would you want to do this? It's not actually
faster or anything, you know.


Yeah, surprisingly, it is not faster for integers either. It was 
probably faster for older CPUs.


Ali



Re: Xor trick?

2014-01-25 Thread H. S. Teoh
On Sun, Jan 26, 2014 at 12:14:40AM +, bearophile wrote:
> Adam D. Ruppe:
> 
> >You could cast it to size_t, then the compiler will let you do the
> >operation, but casting pointers to and from integers means you
> >take matters of correctness into your own hands.
> 
> Right, so I have to carry around size_t instead of pointers.
[...]

And you can't use the GC since the GC won't be able to find your
xor'd pointers.


T

-- 
WINDOWS = Will Install Needless Data On Whole System -- CompuMan


Re: Python calling D

2014-01-25 Thread Ellery Newcomer

On Friday, 24 January 2014 at 10:55:34 UTC, Russel Winder wrote:


Probably want to use a virtualenv for this rather than install 
into the

base installation



you can also do

python setup.py build
python runtests.py -b hello



It needs to work for Python 3.3 as well!


try the latest commit


Re: Good ol' OpenGL D-C interfacing. :(

2014-01-25 Thread Rikki Cattermole

On Saturday, 25 January 2014 at 23:28:07 UTC, Mineko wrote:
Alright.. For the record, I've been searching on how to fix 
this for 2 hours now, so yeah.


Anyway, here's the issue, and it's probably half OpenGL being 
well.. OpenGL, and the other half being D-C interfacing.


Point is, I'm trying to draw a triangle with a custom Triangle 
class I made, and I'm having issues, relevant code is here:

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/scene.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/utility/graphics/primitives.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/res/shaders/testShader.glsl

I assume this is probably me messing up with arrays and sizing, 
but I've done what I can as far as that goes so.. Maybe one of 
you know what to do.


Try breaking it down into a single module. Basically on render 
call your file's function that you handle drawing of said 
triangle. Relying on as little as possible on other code.


That way you should be able to use existing examples and 
tutorials straight. This is what really helped me with DOOGLE and 
working it out. I have an example for it if you want to check it 
out.


From the module you'll have than you can start abstracting out 
and testing your own code base.


Re: Good ol' OpenGL D-C interfacing. :(

2014-01-25 Thread Mineko
On Sunday, 26 January 2014 at 02:39:29 UTC, Rikki Cattermole 
wrote:

On Saturday, 25 January 2014 at 23:28:07 UTC, Mineko wrote:
Alright.. For the record, I've been searching on how to fix 
this for 2 hours now, so yeah.


Anyway, here's the issue, and it's probably half OpenGL being 
well.. OpenGL, and the other half being D-C interfacing.


Point is, I'm trying to draw a triangle with a custom Triangle 
class I made, and I'm having issues, relevant code is here:

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/scene.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/utility/graphics/primitives.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/res/shaders/testShader.glsl

I assume this is probably me messing up with arrays and 
sizing, but I've done what I can as far as that goes so.. 
Maybe one of you know what to do.


Try breaking it down into a single module. Basically on render 
call your file's function that you handle drawing of said 
triangle. Relying on as little as possible on other code.


That way you should be able to use existing examples and 
tutorials straight. This is what really helped me with DOOGLE 
and working it out. I have an example for it if you want to 
check it out.


From the module you'll have than you can start abstracting out 
and testing your own code base.


I see what you're saying, and that's more or less what I've been 
doing, I'm asking what opengl function did I mess up to cause it 
not to render, because I've checked it over and over again.


Re: Good ol' OpenGL D-C interfacing. :(

2014-01-25 Thread TheFlyingFiddle

On Saturday, 25 January 2014 at 23:28:07 UTC, Mineko wrote:
Alright.. For the record, I've been searching on how to fix 
this for 2 hours now, so yeah.


Anyway, here's the issue, and it's probably half OpenGL being 
well.. OpenGL, and the other half being D-C interfacing.


Point is, I'm trying to draw a triangle with a custom Triangle 
class I made, and I'm having issues, relevant code is here:

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/scene.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/utility/graphics/primitives.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/res/shaders/testShader.glsl

I assume this is probably me messing up with arrays and sizing, 
but I've done what I can as far as that goes so.. Maybe one of 
you know what to do.



Your init and finalize methods in primitives.d does not work. You 
need to send the vao, points_vbo and colors_vbo by ref.


Re: Good ol' OpenGL D-C interfacing. :(

2014-01-25 Thread Mineko

On Sunday, 26 January 2014 at 03:39:37 UTC, TheFlyingFiddle wrote:

On Saturday, 25 January 2014 at 23:28:07 UTC, Mineko wrote:
Alright.. For the record, I've been searching on how to fix 
this for 2 hours now, so yeah.


Anyway, here's the issue, and it's probably half OpenGL being 
well.. OpenGL, and the other half being D-C interfacing.


Point is, I'm trying to draw a triangle with a custom Triangle 
class I made, and I'm having issues, relevant code is here:

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/scene.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/src/breaker/utility/graphics/primitives.d

https://github.com/MinekoRox/Breaker-Engine/blob/master/res/shaders/testShader.glsl

I assume this is probably me messing up with arrays and 
sizing, but I've done what I can as far as that goes so.. 
Maybe one of you know what to do.



Your init and finalize methods in primitives.d does not work. 
You need to send the vao, points_vbo and colors_vbo by ref.


Thank you, that was exactly the problem.


Re: sqlite_mismatch using etc.c.sqlite3

2014-01-25 Thread Jesse Phillips

On Saturday, 25 January 2014 at 12:43:48 UTC, Jacho Mendt wrote:
sqlite3_exec here returns 21, wich is the code for 
SQLITE_MISMATCH. I know I'm doing something wrong, i just can't 
find what.


I can't really see why that would be considering the explaination 
of that error:
"This error occurs when there is an attempt to insert non-integer 
data into a column labeled INTEGER PRIMARY KEY. For most columns, 
SQLite ignores the data type and allows any kind of data to be 
stored. But an INTEGER PRIMARY KEY column is only allowed to 
store integer data."


Might I suggest using a wrapper?
https://github.com/bayun/SQLite3-D/blob/master/sqlite3.d

You'll want to replace the import sqlite3_bindings to use the 
etc.c.sqlite3.


Re: automatic type creation

2014-01-25 Thread Ali Çehreli

Where is the tldr; section? :)

On 01/25/2014 04:08 AM, Frustrated wrote:

> I'd like to support extensions of my own interfaced based design
> where anyone could simply "drop" in there own inherited classes
> and everything would work as if they designed everything using
> those classes from the get go.

I think the concept-based polymorphism popularized by Sean Parent may be 
relevant.


The following is an example where the "subtypes" Cat and Dog are not 
inherited from Animal but still behave specially. The design naturally 
allows hierarchical designs where for example an Animal of Animal(Dog) 
can be constructed. (See the WAT? line below.)


import std.stdio;

struct Animal
{
void sing()
{
animal.sing();
}

this(AnimalT)(AnimalT animal)
{
this.animal = new Model!AnimalT(animal);
}

private:

interface Interface
{
void sing();
}

class Model(T) : Interface
{
T t;

this(T t)
{
this.t = t;
}

void sing()
{
t.sing();
}
}

Interface animal;
}

struct Cat
{
void sing()
{
writeln("meow");
}
}

struct Dog
{
void sing()
{
writeln("woof");
}
}

void main()
{
Animal[] animals = [ Animal(Cat()),
 Animal(Dog()),
 Animal(Animal(Dog())) /* WAT? :) */ ];

foreach (animal; animals) {
animal.sing();
}
}

Ali



Re: automatic type creation

2014-01-25 Thread Frustrated

On Sunday, 26 January 2014 at 05:19:51 UTC, Ali Çehreli wrote:

Where is the tldr; section? :)

On 01/25/2014 04:08 AM, Frustrated wrote:

> I'd like to support extensions of my own interfaced based
design
> where anyone could simply "drop" in there own inherited
classes
> and everything would work as if they designed everything using
> those classes from the get go.

I think the concept-based polymorphism popularized by Sean 
Parent may be relevant.


The following is an example where the "subtypes" Cat and Dog 
are not inherited from Animal but still behave specially. The 
design naturally allows hierarchical designs where for example 
an Animal of Animal(Dog) can be constructed. (See the WAT? line 
below.)


import std.stdio;

struct Animal
{
void sing()
{
animal.sing();
}

this(AnimalT)(AnimalT animal)
{
this.animal = new Model!AnimalT(animal);
}

private:

interface Interface
{
void sing();
}

class Model(T) : Interface
{
T t;

this(T t)
{
this.t = t;
}

void sing()
{
t.sing();
}
}

Interface animal;
}

struct Cat
{
void sing()
{
writeln("meow");
}
}

struct Dog
{
void sing()
{
writeln("woof");
}
}

void main()
{
Animal[] animals = [ Animal(Cat()),
 Animal(Dog()),
 Animal(Animal(Dog())) /* WAT? :) */ ];

foreach (animal; animals) {
animal.sing();
}
}

Ali


While this is interesting I don't think it specifically addresses
the issue of having only to create the "interface" in the
original code but have it automatically create the desired type
at runtime.

In the above code you have to specify cat and dog and are simply
wrapping the desired code.

If I were using the above code it would be something like

Animal[] animals = [Animal.New(State), Animal.New(State),
Animal.New(State)];

and somehow New would use the state to know which to create(in
this case, cat, dog, and an animal wrapped dog).


(of course, the above code would be rather useless and hard to
determine the appropriate state information)