Re: OPTLINK Error 45 Too Much DEBUG Data for Old CodeView format

2015-03-21 Thread Trass3r via Digitalmars-d-learn
Just save yourself lots of headaches and abandon the optlink/omf 
crap with -m64 resp. -m32mscoff.


Re: dsource and WinAPI

2014-10-14 Thread Trass3r via Digitalmars-d-learn
the long-term solution is to include the [win32] headers in 
druntime

™


Re: How do I write __simd(void16*, void16) ?

2014-10-09 Thread Trass3r via Digitalmars-d-learn

On Wednesday, 8 October 2014 at 18:56:31 UTC, Etienne wrote:
I can't seem to find this function anywhere: __simd(void16*, 
void16)



MOVDQU = void _mm_storeu_si128 ( __m128i *p, __m128i a)
MOVDQU = __m128i _mm_loadu_si128 ( __m128i *p)


Is there a module by now that allows to directly write Intel 
intrinsics?


Re: Installing LDC on Windows

2014-09-06 Thread Trass3r via Digitalmars-d-learn

SEH was patented, so llvm doesn't support it.


That has changed.


Re: Installing LDC on Windows

2014-09-06 Thread Trass3r via Digitalmars-d-learn
On Saturday, 6 September 2014 at 21:54:00 UTC, David Nadlinger 
wrote:

On Saturday, 6 September 2014 at 17:51:16 UTC, Trass3r wrote:

SEH was patented, so llvm doesn't support it.


That has changed.


Has it? SEH on Win64 is something entirely different from the 
original (x86) SEH design, and not covered by said patent.


Ok 2in1.
1) As far as I know the x86 SEH patent expired in June.
2) For x64 the implementation is very close now:
   
https://github.com/ldc-developers/ldc/issues/166#issuecomment-54522891


Re: Showing a user specified error message when no overloads match

2014-07-26 Thread Trass3r via Digitalmars-d-learn

Yeah that's the price we pay for the simplicity.
Also most constraints directly or indirectly consist of a complex 
boolean expressions and you don't get any hint which part failed 
and why.


Re: Question about @nogc in D 2.066

2014-07-11 Thread Trass3r via Digitalmars-d-learn

http://forum.dlang.org/thread/pxotrowaqcenrpnnw...@forum.dlang.org


Re: Why is the Win32 boilerplate the way it is?

2014-06-29 Thread Trass3r via Digitalmars-d-learn
The only question I have is what happens when you use 
SUBSYSTEM:WINDOWS:4.0 (Which I understand means XP or higher) 
and the program runs on something older?


WinXP is dead :)


Re: what is going on with cgcs.c:351?

2014-06-17 Thread Trass3r via Digitalmars-d-learn
I think it should be possible to run DustMite on some big project 
like phobos to actually search for such internal errors.


Re: Debugging compiler crashes?

2012-07-02 Thread Trass3r
dmd: glue.c:542: virtual void FuncDeclaration::toObjFile(int): Assertion  
`semanticRun == PASSsemantic3done' failed.

Aborted
wouter@carillon:~/code/d/DustMite$

... and I'm not yet that fluent in D to understand what's going on. Any
ideas?


pass dustmite.d before dsplit.d
known problem, but the error message has changed


Re: Debugging compiler crashes?

2012-07-02 Thread Trass3r

... the order of files matters? Yuck.


Yep it's a bug.


Re: Lack of warning messages

2012-06-21 Thread Trass3r

A notice for some unused imports would be great too...


You could create a brute-force tool.
Rip off an import statement at a time and see if it still compiles.
One could probably modify DustMite to do that.


Re: Casting the Result of splitter() into a string array

2012-06-17 Thread Trass3r

If you want to convert a range to an array, use std.array.array


This is a constant source of confusion and it also is a crappy design to  
use a function in a totally different module for this purpose imho.
Can't these Result types get an eval() method and/or be made implicitly  
convertible to an array where appropriate?


The C++ matrix library Eigen uses this approach and it works out  
fantastically.
a*b returns an object representing this expression. If I do want to use  
this I write 'auto c=a*b;'.
If I want the result I can explicitly use its eval() method (which is  
especially useful inside a bigger expression) or something like 'Matrix  
c=a*b;' which also evaluates the expression.


Re: align(16) struct member throws an exception with movdqa

2012-06-11 Thread Trass3r

test code please


Re: align(16) struct member throws an exception with movdqa

2012-06-11 Thread Trass3r

import std.stdio, core.simd;

void main()
{   int4 v;
}

Internal error: ..\ztc\cgcod.c 1447
Building Debug\dtest1.exe failed!


Works fine on Linux.

Maybe the 32Bit check doesn't work for Windoze?
-m32 on Linux yields Error: SIMD vector types not supported on this  
platform


Re: align(16) struct member throws an exception with movdqa

2012-06-11 Thread Trass3r
I think it has been fixed for the next version of DMD already. Any idea  
why align isn't letting me use movdqa?


Cause align doesn't work the way you think it does.
In fact I still don't understand how it works at all.


Re: std.mmfile issues

2012-05-14 Thread Trass3r
I found out that OpenFileMapping is not needed and CreateFileMapping is  
sufficient. I managed to code this with std.c.windows only however  
MmFile is not working even with simplest examlple maybe a bug under win  
7?


Possible. Feel free to file a bug report or create a pull request.


Re: undefined reference - Derelict2

2012-05-07 Thread Trass3r
Though I was under the impression that the new Derelict2 hierarchy / d  
interface files in Derelict2/import reduced the neccesity for command  
line arguments, that is a Derelict related question.


You may try to use --chatty and compare the output.


Re: How to pass list of strings as compile-time parameters?

2012-04-24 Thread Trass3r

bool compareByMemb(string[] ignores, T)(T obj1, T obj2) {
foreach (name; __traits(getAllMembers, T)) {
...
}


In this particular case you could try

foo(T, U...)(T obj1, T obj2, U ignores)


Re: this() const

2012-04-15 Thread Trass3r

Am 15.04.2012, 21:20 Uhr, schrieb sclytrack sclytr...@hotmail.com:



this( const size_t step) const
{
this.step = step;
}


Error: cannot modify const/immutable/inout expression this.step


Is this the expected behavior? Thanks.


Yep.


Re: D Dll injection problem

2012-03-27 Thread Trass3r

Maybe it's because I have no def file.


Very possible.
Just pass it to dmd like the other files.
Or try the new -shared flag.


Re: D Dll injection problem

2012-03-27 Thread Trass3r
I inject it but it returns nothing and the App(where the dll is  
injected) is hanging( not responding).


Could you try it maybe?
I would like to know whether it's a Problem with D or with me.


Are dlls without injection working?


Re: Vector operations optimization.

2012-03-23 Thread Trass3r

The flags you want are -O, -inline -release.

If you don't have those, then that might explain some of the slow down
on slicing, since -release drops a ton of runtime checks.


-noboundscheck option can also speed up things.


Re: Vector operations optimization.

2012-03-22 Thread Trass3r
What is the status at the moment? What compiler and with which compiler  
flags I should use to achieve maximum performance?


In general gdc or ldc. Not sure how good vectorization is though, esp.  
auto-vectorization.
On the other hand the so called vector operations like a[] = b[] + c[];  
are lowered to hand-written SSE assembly even in dmd.


Re: anything that would provide support for zip filesystem?

2012-03-22 Thread Trass3r

I guess Tango provides something like that via the VFS stuff.

https://github.com/SiegeLord/Tango-D2 resp.
https://github.com/mtachrono/tango


Re: preprocessor pass equivalent?

2012-03-15 Thread Trass3r

There's a pull request to help with debugging string mixins:
https://github.com/D-Programming-Language/dmd/pull/426


Re: htod - const

2012-03-06 Thread Trass3r

Why is 'const' removed?


cause htod sucks.
D1 didn't have const and htod wasn't updated for ages.


Re: htod - const

2012-03-06 Thread Trass3r
Am 06.03.2012, 20:13 Uhr, schrieb maarten van damme  
maartenvd1...@gmail.com:



I wouldn't say that it sucks. It has really helped a lot in
porting some simple header files. It  goes terribly bad on the more  
complex though.


Sadly, using regular expressions is much more efficient.
At least those don't destroy the source by removing const, comments,  
evaluating preprocessor directives, etc.


Re: Dumb question about git

2012-03-01 Thread Trass3r

OK, so what's the right way to do it then? I have some changes in a
branch, but master has been updated since, so I want to merge in the
latest updates so that the branch changes are compatible with the latest
code.


I use a quite crappy way to rebase my feature branch:
git stash  git checkout master  git pull -v --rebase  git rebase  
master myworkingbranch


There's probably some redundancy or whatever here, but at least it works ^^


Re: Random behavior using a wrapped C library

2012-02-28 Thread Trass3r

http://d.puremagic.com/issues/show_bug.cgi?id=5570


Re: Random behavior using a wrapped C library

2012-02-28 Thread Trass3r

A blocker for using x64 on linux then.


Use gdc. Better codegen anyway.


Re: produced binary is quite big

2012-02-26 Thread Trass3r
You may try -L--gc-sections (in case of gdc in combination with  
-ffunction-sections -fdata-sections) and -L-s


Re: Make alias parameter optional?

2012-02-25 Thread Trass3r

void foo(T, T2, alias thing = (){})(T a, T2 b)
{
thing();
}

void bar(){}

void main()
{
foo!(int,int,bar)(1,2);
foo(1,2);
}


Re: Executable size when compiling with GDC

2012-02-21 Thread Trass3r

Lots of symbols and stuff.
You can get it down with -ffunction-sections -fdata-sections  
-Wl,-s,--gc-sections
Phobos should also be compiled with -ffunction-sections -fdata-sections to  
get the whole effect though.


Re: Everything on the Stack

2012-02-20 Thread Trass3r

scope auto e1 = new EntryInt();
Foo = e1.toFoo();


You don't need auto there.
And scope is deprecated, use std.typecons' scoped


Re: Compiling Lua for D

2012-02-15 Thread Trass3r
LuaD works fine, but I'd rather learn to compile stuff like this myself.  
It will get me further in the long run^^


Try to switch to gdc.
dmc, optlink  Co. must die a bloody death anyway :)


Re: D for game Development

2012-02-15 Thread Trass3r

Can I use OpenGL or DirectX with D?


Of course.

E.g. there's a D1 game engine: http://yage3d.net
I think http://3d.benjamin-thaut.de/?p=16 is D2, but it's rendering code  
only.


Re: Compiling Lua for D

2012-02-15 Thread Trass3r
I guess GDC uses COFF? That would definitely be handy... although I  
couldn't compile and debug from VS anymore in that case, and that would  
be unfortunate^^


Just recently Rainer added gdc support to cv2pdb.


Re: Templated aliases name in compilation error output

2012-02-12 Thread Trass3r

dmd simply doesn't keep those information about aliases.


Re: Struct inheritance

2012-02-04 Thread Trass3r
So why not just use classes? I've understood it as there may be a  
performance gain by using structs over classes, and in my program Point  
and Coordinate are used heavily.


The other big difference is value vs. reference type.
You can use alias this to achieve something like struct inheritance.


Re: i18n

2012-02-03 Thread Trass3r
I deduce so that there is no official support for that. If it's, it's  
a pain.


Pain? Writing such a system can be done in a couple of lines.


Re: linker @ meaning and how to compile static libs

2012-02-03 Thread Trass3r
The main question is how do I either compile the library with the right  
version suffix (@12)

Or get the linker to use the right version suffix (@8)


That's no version suffix. It's the number of bytes of the arguments IIRC.
Windows calling convention.


Re: i18n

2012-02-03 Thread Trass3r
Thanks a lot, So I just need to detect user locale using How to do  
that?


You can always use the functions you would use in C.


Re: opAssign and references

2012-01-31 Thread Trass3r
I am using DMD 2.057 on Ubuntu 64bit. Are you sure that it does not  
work? Can anyone reproduce the error?


import std.variant;
struct Foo {
 Variant a;
 ref Variant refA(){
 return a;
 }
}
void main(){
 Foo f1;
 f1.refA() = 24;
}


Compiles fine on Ubuntu x64 with git dmd and -m(32|64)


Re: Scoped Class Instance

2012-01-31 Thread Trass3r

However, I cannot, by default, scope my custom allocations.
Any ideas?


std.typecons.scoped


Re: regex: force entire string to match

2012-01-31 Thread Trass3r

I want to write a regex to check if a whole string is a number.
With my current regex([0-9]+) numbers will be carved out of things like
aaa456 (hit: 456) and I circumvent this by checking the lengths for
inequality, which is stupid. My regex is surely missing something?


Try ^ and $ if applicable. These match start and end of a line.


Re: Class Initialization

2012-01-31 Thread Trass3r

I was reading the C++ Object Model book recently (well, I'm still
reading) and was amazed at how many edge-cases there are in C++, and
how lucky I am to be using D. Well, minus the Optlink that is. :)


*whispers gee dee c*


Re: Class Initialization

2012-01-31 Thread Trass3r

*whispers gee dee c*


windows binaries please...


Seek and you shall find.
https://bitbucket.org/goshawk/gdc/downloads


Re: Chained Catch Statements

2012-01-30 Thread Trass3r

What is the idiom for handling
a case where multiple exceptions of different types may be thrown?


I think you could catch a common baseclass like Exception and test if it's  
a specific Exception by casting.


Re: dmd gdc

2012-01-26 Thread Trass3r

There is also gdmd : dmd front end that use gdc
It's nothing but a perl script that translates dmd command line 
options into gdc ones.


Re: dmd gdc

2012-01-26 Thread Trass3r

Building gcc in general is a pain. It's just a little less painful on
*nix systems, but still painful.


I can't agree.
The build instructions contain everything. Has been straightforward for me  
right from the beginning.


Re: dmd gdc

2012-01-26 Thread Trass3r

I looked up ldc recently, and it seems that it hasn't been updated for
years. Seems that gdc is the only other D compiler that's still actively
maintained.


Please don't spread such misinformation.
https://github.com/ldc-developers/ldc/commits/master


Re: Definition of extern(System)?

2012-01-25 Thread Trass3r

I was pretty sure it's somewhere in the spec.


Re: for loop

2012-01-23 Thread Trass3r

void main(){
   for ({int x=0; short y=0;} x  10; x++, y++){
   }
}


wtf?


Re: for loop

2012-01-22 Thread Trass3r

for (int x = 0, int y = 0; .)


for (int x=0, y=0; ...)


Re: Struct initialization, implicit conversions and delegates

2012-01-16 Thread Trass3r

StringHash sh = SomeString; // ok


That's the only thing that works.
An @implicit tag for constructors to allow all implicit conversions would  
really be helpful.


In general we need finer control of implicit conversions.
Just have a look at ProxyOf:  
https://github.com/D-Programming-Language/phobos/pull/300/files#L0R2670


That's madness, all of that code just for getting alias this without  
implicit conversion to the original type.


Re: Problem with interfacing C code to D

2012-01-09 Thread Trass3r

What's the definition of Display?


Re: Ref local variables?

2012-01-08 Thread Trass3r

MapTile[] map;  // It's a struct

ref MapTile tile=map[y*w+x];
tile.id=something;
tile.isWall=true;


MapTile* tile = map[y*w+x];


Re: Ref local variables?

2012-01-08 Thread Trass3r

Sorry, didn't read the rest. ^^


Re: typedef deprecated - now what ?

2011-12-30 Thread Trass3r
is there a template or something in phobos to get the same typesafe  
behaviour of good old typedef ?


I've brought this up several times.
People just don't give a shit.

http://d.puremagic.com/issues/show_bug.cgi?id=5467


Re: Reading about D: few questions

2011-12-23 Thread Trass3r

5. Align attribute.

http://dlang.org/attribute.html#align

struct S {
   align(4) byte a; // placed at offset 0
   align(4) byte b; // placed at offset 1
}

Explain this please.


align is a huge mess imo.
It matches the corresponding C compiler behavior
So what's the point of align in the first place, if the compiler does what  
it wants anyway, see above?


The only thing that really works is

align(1) struct S {...}

for packed structs.


Re: test if object is instance of class at compile time

2011-12-22 Thread Trass3r

I'd really like to have 'if (instance is ClassType)' syntax in D.


Re: writing iterators without code duplication. inout?

2011-12-21 Thread Trass3r

Can't really answer your original question, but
1. Why don't you use opApply?
2. Why do you use ref int even in the const version?
3. You could also use alias this to allow iteration, don't know if that's  
what you want in general though.


Re: Void initialization

2011-12-19 Thread Trass3r

Am 19.12.2011, 13:04 Uhr, schrieb Bear joanylepri...@yahoo.fr:


Using D1, I have a program that creates tons of float[] ; for performance
reasons, I would like them to be uninitialized.


std.array.uninitializedArray


Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Trass3r
It actualy returns a procedure address and the procedure is called. It  
lands inside export extern (C) int magicNumber() and crashes when  
attempting to allocate memory for Something.


Did you properly initialize druntime?


Re: Allocating memory in D shared library when accessed from C++

2011-12-19 Thread Trass3r

Am 19.12.2011, 23:13 Uhr, schrieb Martin Drašar dra...@ics.muni.cz:


Dne 19.12.2011 23:09, Trass3r napsal(a):

It actualy returns a procedure address and the procedure is called. It
lands inside export extern (C) int magicNumber() and crashes when
attempting to allocate memory for Something.


Did you properly initialize druntime?


As I am just starting with D, the most precise answer I can give you is:  
I don't know... how do I tell? Or in another way - the code for D  
library is almost complete except for imports. The rest was done for me  
by Visual D.


It's explained there: http://www.dlang.org/dll.html


Re: Alias/Ref Tuples ?

2011-12-16 Thread Trass3r

I think something like this is implemented in a dmd pull request.


Re: -D option = Embedded documentation

2011-12-16 Thread Trass3r

Am 16.12.2011, 17:47 Uhr, schrieb dune do-...@email.com:


Never tried this before:

Tried (with D2.057) to use the embedded documentation option with:

/**
 * documentation here
 */

and the html files are generated but they only contain a html skeleton  
and no documentation.


This comment doesn't refer to any code.


Re: -D option = Embedded documentation

2011-12-16 Thread Trass3r
What I posted was an example, in reality there is tons of code inside  
the d file.


Show the file, or part of it.


Re: -D option = Embedded documentation

2011-12-16 Thread Trass3r
 hrsmallPage generated by a  
href=http://www.digitalmars.com/d/2.0/ddoc.html;Ddoc/a. /small

 /body/html


Ah looks like that must be updated to dlang.org too


Re: -D option = Embedded documentation

2011-12-16 Thread Trass3r

Am 16.12.2011, 19:45 Uhr, schrieb dune do-...@email.com:


I didn't realize that stuff like this will not work as expected:

[code]
/***
 * Brief summary of what
 * myfunc does, forming the summary section.
 *
 * First paragraph of synopsis description.
 *
 * Second paragraph of
 * synopsis description.
 */

void myfunc() { }

/***
 * This is just some text that
 * should be added to the
 * documentation
 */

// below is the next chunk of code
[/code]

The second block of documentation will not show up.


How is the doc generator supposed to know where that doc fragment is  
supposed to end up?

If it's related to a declaration, put it there.
If it's just a module-level comment, put it into the module doc comment.


Re: D Grammar Specification

2011-11-29 Thread Trass3r

http://lists.puremagic.com/pipermail/digitalmars-d/2011-March/098950.html


Re: auto

2011-11-24 Thread Trass3r

The type has to be deduced anyway for type checking the
assignment/initialization.


Makes sense. Overseen that.


Re: Internal error: ..\ztc\cgcs.c 352

2011-11-22 Thread Trass3r
Please check if your case is equal to  
http://d.puremagic.com/issues/show_bug.cgi?id=4414


Re: Make a variable single-assignment?

2011-11-21 Thread Trass3r

Don't think so.
You could also wrap it in a struct with disabled opAssign, but this would  
also change the type.


Re: web development in D programming

2011-11-09 Thread Trass3r

I am a little disapointed, so if you have many request for a web page
this lib  http://arsdnet.net/dcode/ is usable or not ?

If they are any other method to do a web application in D2 programming
do not hesitate and tell to me which lib used.


There's also a project named Serenity
http://www.digitalmars.com/d/archives/digitalmars/D/Serenity_web_framework_-_early_feedback_wanted_125473.html

But it hasn't been updated in months nor is it mature.

Adam uses his code in production and also provides FastCGI support.


Re: .Net

2011-11-09 Thread Trass3r

Am 09.11.2011, 13:39 Uhr, schrieb Reklen rek...@mymaill.com:


Is there a project to export D in .Net world? I see this
http://dnet.codeplex.com/
but it seems dead.


Feel free to continue that project ;)
Apart from that you are left with C interface dlls.


Re: Spurious imports in Phobos ?

2011-11-09 Thread Trass3r
2. what is your opinion about public import ? In C++, hidden or  
implicit #includes is a common source of compilation problems (order  
of #includes), I tend to think it's a bad thing.


It can be quite useful. I use it often for C library wrappers. As soon as  
you import the wrapper code you automatically import the bindings to be  
able to use constants etc.


Re: Spurious imports in Phobos ?

2011-11-09 Thread Trass3r
Phobos contains a lot of templates and if a template isn't instantiated  
it won't be compiled. Meaning there can be hidden compile errors if you  
start to remove imports and they will not show until a template that  
uses something from the import is instantiate.


Wouldn't it be possible/better then to move the imports into those  
template functions?


Re: Is this actually valid code?

2011-11-07 Thread Trass3r

class Foo
{
@property void test(int) {}
@property int test() { return 1; }
}

class Bar : Foo
{
alias super.test test;
override @property void test(int) {}
void bartest() { auto x = test; }
}

And it actually works! Is this a documented feature?


http://d-programming-language.org/hijack.html


Re: Is this actually valid code?

2011-11-07 Thread Trass3r

Cool stuff, thanks guys. This thing kicks some serious C++ ass. ^^


How? You can use using in C++ to do the same.


Re: extends and implements

2011-11-07 Thread Trass3r

You can do this and/or use the convention of extends first, implements
second:

class Rectangle : Drawable, IShape, IOtherInterface {}


It's not a convention, the spec demands that.
http://d-programming-language.org/class.html



If you're really concerned about clarity, use comments:

class Rectangle : /* extends */ Drawable,
  /* implements */ IShape
{
}


Good point.


Re: template expressions in C++ to an equivalent in D

2011-10-30 Thread Trass3r

I was thinking about porting http://eigen.tuxfamily.org/index.php in D.


Don't we have a LinAlg library now thx to that GSoC project?

I'm currently on SFML2 but it goes quite fast (thanks to  Trass3r for  
porting SFML to D2 so a big part of the job is done).


You're welcome.


Re: char and string with umlauts

2011-10-20 Thread Trass3r

Make sure your source file is saved in UTF-8 format.


Re: Looking for documentation of D's lower-level aspects.

2011-10-19 Thread Trass3r

Am 20.10.2011, 00:06 Uhr, schrieb Sean Silva chisophu...@gmail.com:

== Quote from Jesse Phillips (jessekphillip...@gmail.com)'s article

Right now D isn't ready to be used in this fashion


It looks there's a more-or-less functional kernel written in D (and
pretty well documented too):
http://wiki.xomb.org/index.php?title=Main_Page


You do not need the Tango standard library to compile XOmB as it contains  
its own standard calls and runtime.


Re: Looking for documentation of D's lower-level aspects.

2011-10-18 Thread Trass3r

 ahead = n._next;

The C/C++ equivalent of this is `ahead = n-next;`, or equivalently  
`ahead = (*n).next;`. This is a difference in semantics from C/C++ with  
respect to the `.`---it seems like D turns pointer to struct property  
accesses into property access with indirection.


Yes. It was really dumb to introduce that in C back then cause you can't  
easily change from a pointer to a class to a real class without editing  
all places where it is accessed.
D chose the sane and safer way of letting the compiler figure out what to  
do.


Nowhere that I can recall in Alexandrescu's book talked about this, but  
it's a really big deal!


I can't recall where I read about it back then, but I did know it soon  
after I had started learning D.
Some of the differences to C/C++ are explained there:  
http://www.d-programming-language.org/ctod.html

Though it could use an overhaul.

As for getting rid of the GC, it is theoretically possible.
But nobody has put much effort into making it work yet (cause the only  
application platform is still x86/64).
I guess it will become necessary though once D conquers ARM (we can  
generate code for it with LDC/GDC but druntime isn't ready).


Re: operator ~ does not check type?

2011-10-12 Thread Trass3r

I believe that the primary reasoning for allowing the implicit conversion
between int and dchar is so that code like this

dchar c = 'a' + 7;


That's a '+' though, not a '~'.

I think it shouldn't be allowed with ~ since it's misleading.
Newbies would probably expect abc ~ 10 to yield abc10 rather than the  
odd abc\n.


Re: Calling D DLL from C# and passing/retrieving string variables

2011-10-12 Thread Trass3r

[DllImport(mydll.dll,
CallingConvention = CallingConvention.Cdecl,
SetLastError = false, CharSet = CharSet.Auto)]
private static extern bool concatenate(
string str1, // in
string str2, // in
StringBuilder strResult); // out


Question is if that StringBuilder really is equal to a char* in this case.


Re: How convice people that D it's wonderfull in a hour ?

2011-10-09 Thread Trass3r
Talk about stuff that's hard to do or impossible in C++ (or just a PITA  
like the whole language) and compare it to some nifty D code.


For example template metaprogramming. No easy way to do template  
constraints, no is expressions nor a proper typeof so you have to use  
specialization a lot.
You could also show something that checks for an interface at  
compile-time, like

template isInputRange(R)
{
enum bool isInputRange = is(typeof(
{
R r;  // can define a range object
if (r.empty) {}   // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}()));
}

CTFE is another strong feature.
You could for example show some code that generates Token handling code  
(an enum for the tokens, associative arrays for token 2 string and the  
other way around, etc.) to be used by a lexer without the necessity for a  
DSL like in Clang or a separate tool like dmd.


Re: contrary of std.utf.toUTFz!(const(wchar)*)

2011-10-07 Thread Trass3r
I feel a little stupid, but how to convert  a wchar* zero terminated  
string into a wstring (DMD 2.055)?


wstring w = cstr[0 .. strlenw(cstr)];


Re: contrary of std.utf.toUTFz!(const(wchar)*)

2011-10-07 Thread Trass3r

Just wanted to point out how it's implemented with language tools.


Re: Why an abstract pointer cannot be used as value in an associate array?

2011-09-29 Thread Trass3r

Am 29.09.2011, 06:51 Uhr, schrieb Cheng Wei riverch...@gmail.com:


extern(C) {
struct ab;
}

ab*[int] map;

void main() {
map.clear();
}


Cannot be compiled. Why?

Thanks.


Just use void* for opaque pointers in D.


Re: I can't build dsfml2 or derelict.sfml whit dsss

2011-09-22 Thread Trass3r

DSFML2's dsss file is just a remnant from the old DSFML.
Also I don't really update DSFML2 anymore. A SWIG wrapper would be a  
better idea but it's hard to make it use our custom system module instead  
of wrapping the original one.


In general using dsss isn't advisable, since rebuild is horribly outdated.


Re: toUTFz and WinAPI GetTextExtentPoint32W

2011-09-20 Thread Trass3r

bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);


toUTFz returns a wchar*, not a wchar[].


Re: toUTFz and WinAPI GetTextExtentPoint32W

2011-09-20 Thread Trass3r
Are you sure that the call requires the string to be null terminated? I  
do not know that winapi function, but this might work:


bool test(HDC dc, string str, SIZE* s)
{
auto wstr = to!(wchar[])str;
GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s);
...


It doesn't need to be null-terminated for that function.
Shouldn't you use to!wstring though?!


Re: attribute decl in version decl

2011-09-19 Thread Trass3r
Am 18.09.2011, 18:55 Uhr, schrieb Ellery Newcomer  
ellery-newco...@utulsa.edu:



Just came across some old D code that does this:

version(linux){
extern(C):
}

Hundreds of OpenGL decls



in dmd 2.055, the extern(C) is not being applied to the OpenGL decls.
should it?


Walter once said it was deliberate.
That extern(C) is only valid inside the version block.
But I also think it should be the other way around.


Re: D, DLLs, UnrealScript and UDK (Sort of a complex question)

2011-09-19 Thread Trass3r

So, my question is THIS:

Can I write a windows DLL file in D that would have functions that can  
be accessible from a compiled C++ program?  (Actually, in this case, it's

UnrealScript that is compiled into a C++ exe.)


It's perfectly possible to create DLLs with D, also see
http://www.d-programming-language.org/dll.html

I already successfully used a D dll with C interface to create Matlab  
plugins as well as a D dll exposing a COM interface to hook DirectDraw.


Re: attribute decl in version decl

2011-09-19 Thread Trass3r

Change it to the following, and you're golden.

extern(System):

Hundreds of OpenGL decls


That only fixes this particular issue.

I once had the following case that can't be done:

version(V1)
{
extern(System):
}
else
{
extern(C):
}


Re: port c macro to D

2011-09-15 Thread Trass3r

Am 15.09.2011, 13:37 Uhr, schrieb Matthias Pleh u...@example.net:


When porting c-code to D, I come consitently to the problem,
how to convert such a c-macro:

#define V(a,b,c) glVertex3d( a size, b size, c size );
#define N(a,b,c) glNormal3d( a, b, c );
N( 1.0, 0.0, 0.0); V(+,-,+); V(+,-,-); V(+,+,-); V(+,+,+);
...

Ok, I could just write it out, but that's not the case.
Sometimes I just want to keep it small and clear as in this example.
I've started with some static functions and use it in mixins:

static string V(string a, string b, string c) {
return glVertex3d(~a~ size, ~b~ size, ~c~ size);
}
static string N(string a, string b, string c) {
return glNormal3d(~a~,~b~,~c~);;
}


If you are willing to write V(+1,-1,+1) instead you can just turn them  
into functions.

Also by static function you probably mean private in D.


Re: port c macro to D

2011-09-15 Thread Trass3r

Also by static function you probably mean private in D.

No, I meant for mixin I nead static functions, but I just realized,
it also works without the static keyword.


I think static has no meaning in global scope, only in function scope  
where it tells the compiler you don't want a closure.


  1   2   3   4   >