Re: Thrift

2015-09-18 Thread David Eagen via Digitalmars-d-learn

On Wednesday, 16 September 2015 at 16:57:39 UTC, ddos wrote:
Looking for a RPC library, thrift looked promising, but i can't 
even compile the simple example given here 
https://thrift.apache.org/tutorial/d


I just ran into the same thing. I tried earlier branches of 
Thrift and those don't work either, but for different reasons.


Re: A valid code that won't run?

2015-04-25 Thread David Eagen via Digitalmars-d

On Friday, 24 April 2015 at 21:47:50 UTC, cym13 wrote:

Reimplementing sure sounds like the best long-term way to go...
Maybe we don't need all libcurl features, we could provide a 
basic

set for 80% of use-cases and advanced users would use the
newly-non-standard libcurl binding.


Vibed already provides a good HTTP library. There is also an 
HTTP/2 library on dub that is being incorporated into Vibed. I 
would suggesting using these if you are doing anything new rather 
than using std.net.curl.




Re: Bugzilla email queue jammed?

2015-02-18 Thread David Eagen via Digitalmars-d
On Wednesday, 18 February 2015 at 23:51:29 UTC, Brad Roberts 
wrote:

Hrm.. that'd be my job.


Brad, thanks for keeping the infrastructure running.


Re: Bugzilla email queue jammed?

2015-02-18 Thread David Eagen via Digitalmars-d

On Thursday, 19 February 2015 at 01:02:48 UTC, David Eagen wrote:
On Wednesday, 18 February 2015 at 23:51:29 UTC, Brad Roberts 
wrote:

Hrm.. that'd be my job.


Brad, thanks for keeping the infrastructure running.


What I meant to say was that as an admin myself I know how 
critical things like this are and how there is no spotlight and 
praise for when things go well. It's only when things break that 
attention turns to the admins. :)


Re: InternetAddress comparison fail

2015-01-02 Thread David Eagen via Digitalmars-d
On Saturday, 3 January 2015 at 01:16:39 UTC, Jonathan Marler 
wrote:
Why doesn't the equals operator work on the InternetAddress 
class?


import std.stdio;
import std.socket;
void main()
{
  auto addr1 = new InternetAddress(192.168.0.1, 80);
  auto addr2 = new InternetAddress(192.168.0.1, 80);
  assert(addr1 == addr2); // FAILS
}

If I am not mistaken, the == operator is overriden by the 
opEquals method.  I don't see any opEquals method in std.socket 
so I'm wondering if this is by design or someone overlooked it?


I ran into this too and made a helper to do the comparison (using 
toAddrString) so I could move forward with my project.


Adding opEquals and opCmp is probably low-hanging fruit and a 
good place for someone to start working on Phobos.


Re: Lost a new commercial user this week :(

2014-12-17 Thread David Eagen via Digitalmars-d
The worst part of the docs is the mass of linked text at the top. 
When are we going to switch to the new layout? It's much better 
than the current layout.




Re: 'int' is enough for 'length' to migrate code from x86 to x64

2014-11-18 Thread David Eagen via Digitalmars-d
Isn't the purpose of size_t is to be large enough to address all 
available memory? A negative value is not only too small but 
doesn't make sense when discussing lengths.


Correctness requires using size_t.



Re: D2 (Debian) + MSSQL

2014-10-09 Thread David Eagen via Digitalmars-d
If there is a C library for MSSQL you should be able to use that 
from your D code. If you do, it would be handy for others if you 
could publish any bindings you create as a dub package 
(code.dlang.org).


Re: Default arguments in function callbacks not taken into account when instantiating templates has huge security implications

2014-05-02 Thread David Eagen via Digitalmars-d

Is this in Bugzilla?



Re: A simple sieve in Phobos?

2014-03-20 Thread David Eagen

On Thursday, 20 March 2014 at 21:31:13 UTC, Gary Willoughby wrote:
For experimental libs i'd rather they were kept out of phobos 
and placed within the dub registry. We can load and use them at 
leisure from there without expecting any sort of support from 
the language maintainers. If included in phobos i can almost 
guarantee that even though they will be marked experimental 
devs will moan when they change because they will have an 
official stamp.


+1


Re: Good name for f.byLine.map!(x = x.idup)?

2014-03-16 Thread David Eagen

copyByLine


Re: Formal review of std.buffer.scopebuffer

2014-03-16 Thread David Eagen
I've started using it in a project to replace a simple dynamic 
array buffer and so far it has fit my needs very well. One thing 
I ran into was a method in the project's API that has this 
signature:


const(ubyte[]) foo() const

I couldn't return a slice from ScopeBuffer directly because of 
the const. I resolved it by changing opSlice's signature in 
ScopeBuffer to this:


@system inout(T[]) opSlice() inout

So there are two questions:

1.) Is this a good way to resolve the problem or am I doing 
something horribly wrong?
2.) Assuming this isn't horribly wrong should ScopeBuffer use 
inout like this?


Compiler version at compile-time

2014-03-11 Thread David Eagen
Is there a way to determine the compiler version at compile time? 
Something like:


static if(DMD_VERSION = 2.066) {
  virtual int foo();
} else {
  int foo();
}



Re: Compiler version at compile-time

2014-03-11 Thread David Eagen

On Wednesday, 12 March 2014 at 02:46:30 UTC, David Eagen wrote:
Is there a way to determine the compiler version at compile 
time? Something like:


static if(DMD_VERSION = 2.066) {
  virtual int foo();
} else {
  int foo();
}


Naturally I found it as soon as I posted

std.compiler : version_major, version_minor;


Re: Thrift maintained..?

2014-02-12 Thread David Eagen

On Wednesday, 12 February 2014 at 07:53:44 UTC, simendsjo wrote:
Well, that seems quite unprofessional.. Not fixing bugs that 
makes parts of their repository unusable..


To be fair he wasn't able to reproduce the problem. It built fine 
on his box. They list automake 1.9 as the requirement so 
presumably he isn't running 1.13 and that's why he didn't run 
into it.


I'm hoping to fix it in 1.13 in a way that also works for earlier 
versions of automake. If I can I'll reopen an contribute a patch. 
Now if I can just figure out how automake works


Re: Thrift maintained..?

2014-02-11 Thread David Eagen

On Wednesday, 25 December 2013 at 17:14:17 UTC, David Eagen wrote:
I've filed a bug: 
https://issues.apache.org/jira/browse/THRIFT-2294


So the Thrift guys are not too excited about fixing this. The bug 
was closed since it affected just the D library.


I think the problem stems from the fact that I have automake 1.13 
which uses the parallel test harness by default. You can convert 
back to the serial test harness by setting this in configure.ac:


AM_INIT_AUTOMAKE([1.11 tar-ustar serial-tests])

The serial test harness is the default for automake 1.12 and 
earlier.


There must be a reason the D library's Makefile is screwed up 
when the parallel test harness is used but so far I haven't found 
it.


Re: Thrift maintained..?

2014-02-11 Thread David Eagen

On Wednesday, 12 February 2014 at 02:27:51 UTC, David Eagen wrote:
You can convert back to the serial test harness by setting this 
in configure.ac:


AM_INIT_AUTOMAKE([1.11 tar-ustar serial-tests])



I should have pointed out that using the serial-tests option with 
automake 1.13 results in a correct D Makefile and a successful 
thrift build.


Re: inotify and recursion

2013-12-27 Thread David Eagen

On Friday, 27 December 2013 at 10:56:55 UTC, Artur Skawina wrote:


You probably meant

   read(inotfd, event, (*event).sizeof);

but in this case the inotify_event structure contains an 
optional

trailing buffer, so it should be

   read(inotfd, event, bufsiz);

artur


Yes, thanks for the correction.

I had trouble getting the file name from the event. I think it's 
because the inotify module has name defined as char[0]. So I did 
this, which prints the name by using the extra data beyond the 
inotify_event struct itself:



void* buf = GC.malloc(bufsiz);

/* wait for an event to occur */
size_t readlen = read(inotfd, buf, bufsiz);
inotify_event* event = cast(inotify_event*) (buf);

/* process event struct here */
writeln(Received inotify event:);
writeln(Bytes read: , readlen);
writeln(Length: , event.len);
writeln(Name:, cast(char[])(buf[event.len..readlen]));



Re: Mobile App STACK4 with a D backend

2013-12-26 Thread David Eagen

My only problem is I can't beat the dang AI. :)



Re: inotify and recursion

2013-12-26 Thread David Eagen
Here is a first attempt. I'm sure there are much better ways to 
do this but this should at least get you going in the right 
direction.


Some of the key things to know are the undocumented (at least not 
documented on the web site) modules that are available. One of 
them contains the Linux inotify header. If you've downloaded the 
zip file from the website take a look at the src/druntime/src 
directory for these modules.


I took the example from 
http://stackoverflow.com/questions/4062806/inotify-how-to-use-it-linux 
and made some changes to get it to compile and run in D.


import core.sys.linux.sys.inotify;
import core.stdc.stdlib : malloc;
import core.sys.posix.unistd : read;

import std.stdio : writeln;
import std.string: toStringz;

enum PATH_MAX = 256;

void main()
{
string filename=aaa;

int inotfd = inotify_init();
int watch_desc = inotify_add_watch(inotfd, 
toStringz(filename), IN_MODIFY);


size_t bufsiz = inotify_event.sizeof + PATH_MAX + 1;
inotify_event* event = cast(inotify_event *) malloc(bufsiz);

/* wait for an event to occur */
read(inotfd, event, event.sizeof);

/* process event struct here */
writeln(Received inotify event.);
}

As far as monitoring a directory, you can do that with inotify 
the same way you would a file. See 
http://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html 
for more a C example (Listing 1).


Re: inotify and recursion

2013-12-26 Thread David Eagen
On Friday, 27 December 2013 at 03:39:58 UTC, Hugo Florentino 
wrote:
BTW, it it a requirement to use malloc, and if so, when would I 
need to free the memory allocated by it?


Inotify is expecting you to read into a buffer. You could 
allocate that buffer from the GC with core.memory.malloc() 
instead.


You want to free the memory once you finish processing the event.


Re: Thrift maintained..?

2013-12-25 Thread David Eagen

On Saturday, 21 December 2013 at 19:20:44 UTC, Martin Nowak wrote:


Rebuild autoconf and automake files?
Try ./bootstrap.sh  ./configure  make.


That's what actually breaks it. I was messing around on another 
box where Thrift compiled just fine and found my configure script 
was not calling ./bootstrap.sh first so it was using old 
Makefiles. Unfortunately I don't know how long ago I ran 
bootsrap.sh on that box so I don't know what version broke the 
Makefile generation.


I've filed a bug: 
https://issues.apache.org/jira/browse/THRIFT-2294


Re: Thrift maintained..?

2013-12-21 Thread David Eagen

On Friday, 15 November 2013 at 21:11:36 UTC, simendsjo wrote:
I thrid compiling thrift 0.9.1 from github with d support, but 
there's a bug in the makefile it seems.


$(addprefix.log: $(addprefix
@p='$(addprefix'; \
b='$(addprefix'; \
$(am__check_pre) $(LOG_DRIVER) --test-name $$f \
--log-file $$b.log --trs-file $$b.trs \
	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) 
$(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \

$$tst $(AM_TESTS_FD_REDIRECT)

The error is reported at the first line with the message:
Makefile:1206: *** unterminated variable reference.  Stop.

Can anyone spot the error? (And preferably send a pull request 
so I don't take the credit :) )


I ran into this same problem but haven't had time to look into 
what is required to fix it. We need someone more familiar with 
make to figure it out.


I imagine the problem is related to the unbalanced parens.


Re: Is this a bug?

2013-11-27 Thread David Eagen
No crash on Ubuntu 13.10 x86_64 using the dmd 2.064.2 package 
downloaded from dlang.org.


Re: endsWith: wrong function call, no error

2013-10-21 Thread David Eagen

On Monday, 21 October 2013 at 15:18:18 UTC, monarch_dodra wrote:


It's a feature.


I actually like that feature. It's me compose long strings in an 
easily viewable way without having to use concatenation and 
therefore additional allocation. Or, even to just comment on 
indvidual lines


string command =
 /usr/bin/rm -rf /  // Don't worry, it'll be fine...
 /dev/null 2/dev/null // This way nobody will know about 
it.


Re: endsWith: wrong function call, no error

2013-10-21 Thread David Eagen

On Monday, 21 October 2013 at 15:57:14 UTC, David Nadlinger wrote:
Concatenation of string literals doesn't need to allocate, as 
discussed here: 
http://d.puremagic.com/issues/show_bug.cgi?id=3827. It's 
trivial to handle the cases where you would've written 
string1 string2 instead of string1 ~ string2. Once 
overloaded operators come into play, it's a bit trickier, but 
if this case really occurred in your program, you could always 
add a pair of parens to fix it.


See also this post by Walter: 
http://forum.dlang.org/post/ibi742$gi2$1...@digitalmars.com


Thanks for pointing that out. I've changed my stance then. It's 
causing difficult to find bugs and serves no useful purpose so it 
should go.


But since the thread you linked to is three years old it is 
apparently already decided and merely waiting implementation.


Re: I don't like slices in D

2013-10-17 Thread David Eagen

On Thursday, 17 October 2013 at 18:00:20 UTC, Vitali wrote:
I expected slices to be in D (http://dlang.org/arrays.html) 
like they are in Go 
(http://blog.golang.org/go-slices-usage-and-internals). But 
they are not.


Why the array have to be reallocated after the length of a 
slice is changed? It makes slices useless.


Here a little example (it fails):

  void testSlices() {
int[] dArr = [10, 11, 12];
int[] dSlice = dArr[0..2];
dSlice.length++;
assert(dArr[2]==dSlice[2]); // failure
  }



Change your slice to
int[] dSlice = dArr[0..$] or [0..3];

The way you are doing it only takes the first 2 elements.

Modified code:

import std.stdio : writeln;

void main()
{
  int[] dArr = [10, 11, 12];
  int[] dSlice = dArr[0..$];
  assert(dArr[2] is dSlice[2]); // passes
  dSlice.length++;
  assert(dArr[2] == dSlice[2]); // passes
}


Re: [OT] Which IDE / Editor do you use?

2013-09-20 Thread David Eagen

On Saturday, 21 September 2013 at 01:05:02 UTC, Manu wrote:

I wish the rest of us could say the same.
We're a pathetic patsy nation that just does whatever the yanks 
tell us to.


But we're suckers for Aussie and English accents. We'll be so 
distracted by how you sound that we won't pay attention to what 
you say.


Yank 1: Did he just ask us to put our military under their 
generals?
Yank 2: Did you hear they way he said today you will serve us? 
That was awesome! This guy's great, we should do whatever he 
wants!


Re: Had another 48hr game jam this weekend...

2013-09-18 Thread David Eagen

On Wednesday, 18 September 2013 at 15:43:21 UTC, Manu wrote:

I've had lots of problems in the past where a header included 
by another
header doesn't prompt the dependent code to be rebuilt, and I 
ended up in a

conservative state of rebuild-all-ing every time... :/
Maybe I should try working with that environment more...



This is what makes tup so interesting to me. It tracks every file 
that is read in during a compile so it knows what to recompile 
when a particular header changes.


Re: Rust Code in the Wild

2013-09-05 Thread David Eagen
I've briefly looked at Rust and so far the pointer ownership 
system is the only thing that appeals to me. If that could be 
somehow integrated in D it would be great. If I recall, a similar 
system was proposed for D by Bartosz Milewski.


Re: Why UTF-8/16 character encodings?

2013-05-27 Thread David Eagen

On Tuesday, 28 May 2013 at 01:38:22 UTC, Peter Williams wrote:



So you're going to spell check them all to make sure that 
they're English?  Or did you mean ASCII?


Peter


That's it. I'm filing a bug against std.traits. There's a 
unittest there that with a struct named Colour. Completely 
unacceptable.




Re: std.variant holding bigger structs and std.concurrency message limitation

2013-04-29 Thread David Eagen

On Saturday, 27 April 2013 at 17:42:54 UTC, Idan Arye wrote:
The way it works now, is that if the size is too big they use a 
reference instead: 
https://github.com/D-Programming-Language/phobos/blob/master/std/variant.d#L544#L555


So is the bug in std.concurrency and they way it uses Variant or 
is the bug in Variant?




Re: dmd goes epic

2013-04-16 Thread David Eagen
Bah - somehow this turned into a browser thread let's get 
back to the fact that this is the best git commit log viewer ever!


Re: D 1.076 and 2.061 release

2013-01-02 Thread David Eagen
On Wednesday, 2 January 2013 at 08:20:41 UTC, Jonathan M Davis 
wrote:

On Wednesday, January 02, 2013 09:12:49 bearophile wrote:

I have to warn people that if they want to suddenly switch from
2.060 to 2.061 with no intermediate steps, probably some of 
their

code will break, and they will have to work to fix it.


Why?

- Jonathan M davis


I have noticed my project doesn't compile with 2.061 when it did 
with 2.060. I am using a few different static libraries, one of 
them is thrift.


I had to recompile the libraries I use with 2.061 which meant I 
had to rebuild thrift and the thrift generated libraries. Once I 
did that I could compile just fine. But before that I got the 
errors below.


I am on 64-bit Ubuntu (AMD64).

/persist/apps/lib/libthriftd.a(base_1_403.o): In function 
`_D6thrift4base10TException6__ctorMFAyaAyamC6object9ThrowableZC6thrift4base10TException':
src/thrift/base.d:(.text._D6thrift4base10TException6__ctorMFAyaAyamC6object9ThrowableZC6thrift4base10TException+0x31): 
undefined reference to 
`_D6object9Exception6__ctorMFAyaAyamC6object9ThrowableZC9Exception'
/persist/apps/lib/libthriftd.a(format_19a_f6c.o): In function 
`_D3std6format62__T11formatRangeTS3std5array16__T8AppenderTAaZ8AppenderTAyaTaZ11formatRangeFKS3std5array16__T8AppenderTAaZ8AppenderKAyaKS3std6format18__T10FormatSpecTaZ10FormatSpecZv':
/persist/apps/dmd/linux/bin64/../../src/phobos/std/format.d:(.text._D3std6format62__T11formatRangeTS3std5array16__T8AppenderTAaZ8AppenderTAyaTaZ11formatRangeFKS3std5array16__T8AppenderTAaZ8AppenderKAyaKS3std6format18__T10FormatSpecTaZ10FormatSpecZv+0x519): 
undefined reference to 
`_D6object9Exception6__ctorMFAyaAyamC6object9ThrowableZC9Exception'
/persist/apps/lib/libthriftd.a(format_518_1094.o): In function 
`_D3std6format81__T11formatRangeTS3std5array17__T8AppenderTAyaZ8AppenderTAC3std6socket7AddressTaZ11formatRangeFKS3std5array17__T8AppenderTAyaZ8AppenderKAC3std6socket7AddressKS3std6format18__T10FormatSpecTaZ10FormatSpecZv':
/persist/apps/dmd/linux/bin64/../../src/phobos/std/format.d:(.text._D3std6format81__T11formatRangeTS3std5array17__T8AppenderTAyaZ8AppenderTAC3std6socket7AddressTaZ11formatRangeFKS3std5array17__T8AppenderTAyaZ8AppenderKAC3std6socket7AddressKS3std6format18__T10FormatSpecTaZ10FormatSpecZv+0x370): 
undefined reference to 
`_D6object9Exception6__ctorMFAyaAyamC6object9ThrowableZC9Exception'
/persist/apps/lib/libthriftd.a(format_528_117d.o): In function 
`_D3std6format72__T11formatRangeTS3std5array17__T8AppenderTAyaZ8AppenderTAC9ExceptionTaZ11formatRangeFKS3std5array17__T8AppenderTAyaZ8AppenderKAC9ExceptionKS3std6format18__T10FormatSpecTaZ10FormatSpecZv':
/persist/apps/dmd/linux/bin64/../../src/phobos/std/format.d:(.text._D3std6format72__T11formatRangeTS3std5array17__T8AppenderTAyaZ8AppenderTAC9ExceptionTaZ11formatRangeFKS3std5array17__T8AppenderTAyaZ8AppenderKAC9ExceptionKS3std6format18__T10FormatSpecTaZ10FormatSpecZv+0x370): 
undefined reference to 
`_D6object9Exception6__ctorMFAyaAyamC6object9ThrowableZC9Exception'
/persist/apps/lib/libthriftd.a(format_555_f95.o): In function 
`_D3std6format327__T11formatRangeTS3std5array17__T8AppenderTAyaZ8AppenderTS3std9algorithm235__T6joinerTS3std9algorithm191__T9MapResultS1123std10functional85__T8unaryFunVAyaa32_7465787428612e5f302c20603a2022602c20612e5f312e6d73672c2060226029Z8unaryFunTS3std5range43__T3ZipTAC3std6socket7AddressTAC9ExceptionZ3ZipZ9MapResultTAyaZ6joiner6ResultTaZ11formatRangeFKS3std5array17__T8AppenderTAyaZ8AppenderKS3std9algorithm235__T6joinerTS3std9algorithm191__T9MapResultS1123std10functional85__T8unaryFunVAyaa32_7465787428612e5f302c20603a2022602c20612e5f312e6d73672c2060226029Z8unaryFunTS3std5range43__T3ZipTAC3std6socket7AddressTAC9ExceptionZ3ZipZ9MapResultTAyaZ6joinerFS3std9algorithm191__T9MapResultS1123std10functional85__T8unaryFunVAyaa32_7465787428612e5f302c20603a2022602c20612e5f312e6d73672c2060226029Z8unaryFunTS3std5range43__T3ZipTAC3std6socket7AddressTAC9ExceptionZ3ZipZ9MapResultAyaZS3std9algorithm235__T6joinerTS3std9algorithm191__T9MapResultS1123std10functional85__T8unaryFunVAyaa32_7465!

787428612e5f302c20603a2022602c20612e5f312e6d73672c2060226029Z8unaryFunTS3std5range43__T3ZipTAC3std6socket7AddressTAC9ExceptionZ3ZipZ9MapResultTAyaZ6joiner6Result6ResultKS3std6format18__T10FormatSpecTaZ10FormatSpecZv':

Re: std.net.curl - HTTP.Method.options - perform()

2012-07-27 Thread David Eagen

On Tuesday, 24 July 2012 at 16:45:49 UTC, Alex wrote:

Hello!

Why does this code print output when I run it?
   - It only happens when the HTTP response Code is == 405
   - 173.194.69.94 is a Google Server for testing
   - Are there any default callbacks which make this output?

CODE:

http://pastebin.com/CZP86Gwh

OUTPUT:

http://pastebin.com/AkA3Fvw1 (Basically a HTML error page)

--Alex


There must be a default onReceive that is writing that to stdout. 
If I add this line just before the perform() call the output is 
not generated:


http.onReceive = (ubyte[] data) { /+ drop +/ return data.length; 
};


-David


Re: D in the cloud with cassandra ?

2012-07-01 Thread David Eagen

On Thursday, 28 June 2012 at 05:42:52 UTC, David Nadlinger wrote:

On Thursday, 28 June 2012 at 00:33:28 UTC, Knud Soerensen wrote:

I am also planing to use a column store as Apache's Cassandra
have anyone tried it with D ?


As far as I know, the »low-level« Cassandra API is based on 
Thrift. This means that you should be able to get started 
pretty easily, as there is a D implementation of it. It has 
been included in the official repository trunk – give me a 
shout if something doesn't work.


David


I've been using the D support in Thrift in the official 
repository in my database testing. I've had no trouble using 
Thrift in D to talk to Cassandra and Hbase. It's quite 
straightforward and easy to do.


The one thing I've had to change is when Thrift names a variable 
version. Since that's a keyword in D I just go in a rename it 
in the generated D sources.


Re: dereferencing null - what about something like an check-scope?

2012-03-08 Thread David Eagen
I like the way Scala handles this with the Option class. None 
indicates no value which is equivalent to your null sentinal 
value but it is a value itself so it is always safe to use.


Combined with pattern matching and the orElse methods makes it 
very easy to use one variable that both stores the value and at 
the same time indicates whether it is valid or not. It's not two 
variables that could get out of sync.


Re: Calling a C++ Object from D

2012-01-25 Thread David Eagen
On Tue, 24 Jan 2012 07:22:46 -0600, Richard Webb we...@beardmouse.org.uk  
wrote:



How about something like this (using Juno):

///
import juno.com.core, std.stdio;

abstract final class SystemInformation {
  mixin(uuid(C01B9BA0-BEA7-41BA-B604-D0A36F469133));
  mixin Interfaces!(ISystemInformation);
}

interface ISystemInformation : IDispatch
{
  mixin(uuid(ade87bf7-7b56-4275-8fab-b9b0e591844b));

  int get_OemHardwareSupportLink(wchar* retval);
  int get_RebootRequired(out VARIANT_BOOL retval);
};

void main()
{
  //auto systemInformation =
coCreate!(ISystemInformation)(uuidof!(SystemInformation));
  auto systemInformation = SystemInformation.coCreate!ISystemInformation;

  if (systemInformation !is null)
  {
  scope(exit) tryRelease(systemInformation);

  VARIANT_BOOL b;
  int result = systemInformation.get_RebootRequired(b);

  if (SUCCEEDED(result))
  {
  writefln(Reboot Required: %s, b);
  }
  }
}
///


Thank you very much. This works great.

Yes, it turns out I was mistaken and this is COM and not C++. Juno  
definitely helps here. I cloned it from github and was glad to see that  
work had recently been done on Juno as well.


-Dave


Calling a C++ Object from D

2012-01-24 Thread David Eagen

I'm trying to understand how to call a C++ library from D. Specifically,
the Windows Update API.

My goal is rather simple in that I want to detect whether there is a
reboot pending for the system. To do that I need to call the
ISystemInformation::RebootRequired property but I don't know how to do
that in D. Information about the call is at
http://msdn.microsoft.com/en-us/library/aa386098(v=vs.85).aspx.

I have the C++ header and have successfully defined VARIANT_BOOL,
VARIANT_TRUE, and VARIANT_FALSE. The last bit to do is to define the
ISystemInterface object itself and the RebootRequired method. How do I do
that?

-Dave


Re: Java Scala

2011-12-01 Thread David Eagen
Andrei Alexandrescu seewebsiteforem...@erdani.org wrote in message 
news:jb8hvh$2sdl$1...@digitalmars.com...

This is a good benchmark for I/O and a practical regex. David, could you
please send (privately if you want) the file or some statistics about it
(bytes, lines, a representative sample)? Thanks!

One more thing before I forget - you may want to use byLine() for input. 
In case the issue turns out to be related to I/O, it's much better we 
improve byLine() instead of the streams library.




I implemented the various suggestions (File.byLine, writeln instead of 
writefln, std.algorithm.sort,  except using FReD. FReD wouldn't compile on 
the linux box I am using. the error was:


/phobos/std/file.d(537): Error: undefined identifier package c.stdio

Previous timing:
real4m21.255s
user4m14.216s
sys 0m5.940s

New timing after the changes:
real2m15.840s
user2m12.700s
sys 0m2.760s


So, it's nearly twice as fast but still the slowest of the four.

I was able to compile with FReD on a 32-bit Windows system and it performed 
15% faster than std.regex processing these same test files. I would love to 
try the precompiled regex code for FReD but the compile throws an out of 
memory error when I try it.


The source files are /var/log/syslog files from sendmail on a Solaris 10 
box. I can't make them available because they are mail logs from our company 
but here are the sizes and line counts along with example entries.


$ wc -l syslog syslog.0 syslog.1 syslog.2
  280618 syslog
  331609 syslog.0
  535035 syslog.1
  543241 syslog.2
 1690503 total

-rw-r--r-- 1 david david  86244537 2011-11-30 21:26 syslog.0
-rw-r--r-- 1 david david 146156778 2011-11-30 21:26 syslog.1
-rw-r--r-- 1 david david 143481904 2011-11-30 21:26 syslog.2
-rw-r--r-- 1 david david  73030898 2011-11-30 21:26 syslog

The entries look like this:

Oct 27 03:10:01 thehost sendmail[3248]: [ID 801593 mail.info] 
p9R8A0MJ003245: to=u...@somewhere.com, delay=00:00:01, xdelay=00:00:01, 
mailer=esmtp, pri=120773, relay=some.host.com. [5.6.7.8], dsn=2.0.0, 
stat=Sent (ok 1319703001 qp 25319 the.mail.host.com!1319703000!80184558!1)
Oct 27 03:10:04 thehost sendmail[3289]: [ID 801593 mail.info] 
p9R8A3Nr003289: from=sender@senderbox, size=765, class=0, nrcpts=1, 
msgid=201110270810.p9R8A3QA021419@senderbox, proto=ESMTP, daemon=MTA, 
relay=senderbox.foo.com [1.2.3.4]



-Dave



relayhosts.d
Description: Binary data


Re: Java Scala

2011-11-30 Thread David Eagen
Recently I needed to analyze some mail logs. I needed to find the hosts that 
were sending mail and how many lines in the log existed for each host. 
Thinking this would be perfect for natively compiled code in D I first wrote 
a D app. I then wrote it in perl and was amazed at how much faster perl was. 
I expanded out to Java and Scala. For all four I used the same source files 
and the same output was created.


The four source files totalled 430MB together with 1.69 million lines. In 
all four implementations the file was read a line at a time and the same 
regex was applied to extract the desired data. Output was 6,857 bytes.


Here are the run results on a 32-bit linux 3.0.0 system. The absolute 
numbers are not important since I ran this on a very old system. It is the 
relative numbers that matter here.


Java (JVM 7 update 1)
real0m56.465s
user0m51.911s
sys 0m3.344s

Perl (5.12.4)
real1m22.256s
user1m19.773s
sys 0m2.212s

Scala (2.9.1 on JVM 7 update 1)
real1m41.187s
user1m36.566s
sys 0m3.892s

D (2.0.56 compiled with -O -release -inline -noboundscheck)
real4m21.255s
user4m14.216s
sys 0m5.940s

Java is the fastest, even faster than perl. The D version which is the only 
natively compiled code version is over 4.6 times slower than the Java 
version even when including overhead like the JVM startup time.


The source for each of the four implementations is attached. I admit to 
being very new to D so perhaps I'm really doing something wrong.


bearophile bearophileh...@lycos.com wrote in message 
news:jb6j8h$12js$1...@digitalmars.com...

Jude:


Got any ideas for code that is currently way less than optimal in D?


Compared to Java running on the OracleVM D is most times slower when it 
comes to heavily garbage collected code, and often with 
floating-point-heavy code. Exceptions (and synchronized methods) are 
faster than D-DMD ones. Sometimes textual I/O is faster in Java compared 
to D-DMD-Phobos one. Often the JavaVM is able to de-virtualize and inline 
virtual calls, while D-DMD is not able to do this (maybe LDC2-LLVM3 will 
be able to do this a bit), making such code faster. The JavaVM is usually 
able to dynamically unrool loops that have a loop count known only at 
runtime, this sometimes speeds up loops a lot compared to D-DMD. Some of 
Java libraries implement important data structures or other things that 
are currently sometimes significantly faster than equivalent D ones. This 
is probably a not complete list.


Bye,
bearophile 


relayhosts.d
Description: Binary data


RelayHosts.java
Description: Binary data


relayhosts.pl
Description: Binary data


RelayHosts.scala
Description: Binary data