How add resource.res in RDMD

2020-02-01 Thread Marcone via Digitalmars-d-learn
I like use rdmd when I am programming. But I need that the 
program use resource file becouse I am creating program with gui 
win32api. How can I add resource when use rdmd?


Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Feb 02, 2020 at 03:16:46AM +, Saurabh Das via Digitalmars-d-learn 
wrote:
> On Saturday, 1 February 2020 at 20:37:03 UTC, H. S. Teoh wrote:
[...]
> > I've actually done this before in an equation grapher program: the
> > user inputs an equation, the program generates D code to compute the
> > equation, then runs dmd to compile it into a shared library, and
> > opens the shared library and looks up the symbol to execute the
> > compiled code.  Dmd is fast enough that this actually works fairly
> > well. When the input to dmd is small, it's so fast you don't even
> > notice it.
[...]
> This approach seems more tractable at present. Would you have any
> example code lying around for this?
[...]

It's very simple. Let's say you have your code in some string called
'code'. Since dmd nowadays can take stdin as input (specify "-" as input
filename), all you have to do is to assemble your dmd command and use
std.process's awesome API to run it:

/*
 * Step 1: Compile the code
 */
string code = ...;
auto cmd = [
"/usr/bin/dmd", // or wherever your dmd is
"-O",   // or whatever other flags you need
"-fPIC", "-shared", // this is important
"-of" ~ soFilename, // specify output filename
"-" // read from stdin
]

// This part is a bit involved because we have to spawn the
// compiler as a child process then write our code string into
// its stdin.
// Alternatively, just write your code into a temporary file and
// pass the filename to dmd, then you can just use
// std.process.execute() which has a much simpler API.
import std.process : pipeProcess, Redirect, wait;
auto pipes = pipeProcess(cmd, Redirect.stdin | Redirect.stdout |
  Redirect.stderrToStdout);

// Send code to compiler
pipes.stdin.write(code);
pipes.stdin.flush();
pipes.stdin.close();

// Read compiler output (optional)
auto app = appender!string();
enum chunkSize = 4096;
pipes.stdout.byChunk(chunkSize)
.copy(app);

// Wait for compiler to finish
auto status = wait(pipes.pid);
auto output = app.data;
if (status != 0)
throw new Exception("Failed to compile code:\n" ~ output);

/*
 * Step 2: Load the compiled library.
 */
// This is for Posix; replace with Windows equivalent if you're
// on Windows.
auto libhandle = dlopen(soFilename.toStringz, RTLD_LAZY | RTLD_LOCAL);
if (libhandle is null) ... /* handle error here */

// Look up entry point by symbol.
string entryPoint = ...; /* symbol of library entry point */
alias FunType = int function(string); // your function signature here
auto funptr = cast(FunType) dlsym(libhandle, entryPoint.toStringz);

/*
 * Step 3: Use the compiled code.
 */

// Call the compiled function with whatever arguments.
int result = funptr("my input");

...

// Cleanup once you're done with the library.
dlclose(libhandle);
std.file.remove(soFilename);


T

-- 
First Rule of History: History doesn't repeat itself -- historians merely 
repeat each other.


Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn

On Saturday, 1 February 2020 at 20:37:03 UTC, H. S. Teoh wrote:
On Sat, Feb 01, 2020 at 08:01:34PM +, Andre Pany via 
Digitalmars-d-learn wrote: [...]

Another approach:
- include the dmd compiler package with your application
- within your app call the compiler executable and compile the 
source

code to a dll / so
- call the dll / so function

[...]

I've actually done this before in an equation grapher program: 
the user inputs an equation, the program generates D code to 
compute the equation, then runs dmd to compile it into a shared 
library, and opens the shared library and looks up the symbol 
to execute the compiled code. Dmd is fast enough that this 
actually works fairly well. When the input to dmd is small, 
it's so fast you don't even notice it.



T


This approach seems more tractable at present. Would you have any 
example code lying around for this?


Saurabh




Re: More vibe.d : Receiving Post params

2020-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn

On 2/1/20 7:55 PM, seany wrote:


How do I intercept POST params? Thank you


Look at req.form for POST parameters. They are not unified with queryString.

https://vibed.org/api/vibe.http.server/HTTPServerRequest.form

-Steve


More vibe.d : Receiving Post params

2020-02-01 Thread seany via Digitalmars-d-learn

Consider this :

import vibe.vibe;
import std.conv;




ushort port =   5502;






void main(char[][] args)
{

auto router = new URLRouter;
router.post("/archive", );
router.get("/archive", );

auto settings = new HTTPServerSettings;
settings.port = port;
settings.bindAddresses = ["::1", "0.0.0.0"];
listenHTTP(settings, router);

runApplication();
}

void savedata(HTTPServerRequest req, HTTPServerResponse res) {

res.writeBody("srver received : " ~ req.queryString);

// also tested with to!string(req.params)

}



Now, I will send POST values like "line=abcdefgh..." to the port 
under "/archive".


I test it under linux :curl  -X POST -d "line=000" 
http://my.secret.site:5502/archive


The response is : srver received :

How do I intercept POST params? Thank you


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn

On Saturday, 1 February 2020 at 22:25:38 UTC, Danny Arends wrote:

On Saturday, 1 February 2020 at 20:06:42 UTC, seany wrote:

[...]


Hey Seany,

A quick follow up post. I think/suspect that something might be 
broken in your dub installation if the mean import is not 
found. This is the first import from the phobos standard 
library in the project.


Could you try compiling the DaNode web server without using dub 
?


git clone https://github.com/DannyArends/DaNode.git
cd DaNode
rdmd danode/server.d -p=8080

This should work, when you have a working D+Phobos standard 
library installation. If this throws error of being unable to 
find the canFind import (now the first one) then somehing in 
your dub/dmd installation is broken and you will probably have 
to reinstall dmd+dub


Kind regards,
Danny


I will test this tomorrow.


Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn

I solved this by following:

sudo wget 
https://netcologne.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list

sudo apt-get update --allow-insecure-repositories
sudo apt-get -y --allow-unauthenticated install --reinstall 
d-apt-keyring

sudo apt-get update && sudo apt-get install dmd-compiler dub


then dub showed the error : out of memory.

I applied: dub --build-mode=singleFile

That seems to work


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread Danny Arends via Digitalmars-d-learn

On Saturday, 1 February 2020 at 20:06:42 UTC, seany wrote:

On Saturday, 1 February 2020 at 14:42:58 UTC, Seb wrote:

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

Hi
I want to start a small server, that will be accessible form 
outside. Not a huge deal right?

Not quite.

[...]


What version of dub did you install? 1.19 should be the latest.


PS:
As suggested, i try to build dub from github, following: 
https://github.com/dlang/dub/releases


I call ./build.d - and everything stops, and machine crashes.

Same for the master branch


Hey Seany,

A quick follow up post. I think/suspect that something might be 
broken in your dub installation if the mean import is not found. 
This is the first import from the phobos standard library in the 
project.


Could you try compiling the DaNode web server without using dub ?

git clone https://github.com/DannyArends/DaNode.git
cd DaNode
rdmd danode/server.d -p=8080

This should work, when you have a working D+Phobos standard 
library installation. If this throws error of being unable to 
find the canFind import (now the first one) then somehing in your 
dub/dmd installation is broken and you will probably have to 
reinstall dmd+dub


Kind regards,
Danny


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread Danny Arends via Digitalmars-d-learn

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

Hi
I want to start a small server, that will be accessible form 
outside. Not a huge deal right?

Not quite.

My machine: 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 
UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


DMD : DMD64 D Compiler v2.090.0
Copyright (C) 1999-2019 by The D Language Foundation, All 
Rights Reserved written by Walter Bright



Now, I try to install dub from the official repo.
Then I do

* dub init server -t vibe.d
* cd server
* dub

I hit this issue : https://github.com/dlang/dub/issues/1712

As suggested, i try to build dub from github, following: 
https://github.com/dlang/dub/releases


I call ./build.d - and everything stops, and machine crashes.

I then try to install DaNode: 
https://github.com/DannyArends/DaNode


It breaks with : module std.algorithm import 'mean' not found

Then I try to install the Hunt Framework. It breaks with : 
basic type

expected, not foreach


Please help. I really want this issue to be resolved-


Hey Seany,

DaNode author here, the mean function is only used to compute 
some server statistics. I am sorry to hear it didn't compile out 
of the box with the latest DMD compiler, I only tested up-to 
2.088.0


I just installed the latest version 2.090.0 but also using this 
version it compiles fine. Looking into the dlang docs it seems it 
was moved from std.algorithm to std.algorithm.iteration, I wonder 
why it doesn't find this function.


However I just added a mean function to the web server since it 
should always find this function.


Could you pull the latest master branch and try compiling it 
again ?


dub -- -p=8080

then see if the web server works by navigating to

http://localhost:8080/

let me know if you run into any other issues

Kind regards,
Danny


How to explicitly state the expression in with(...)?

2020-02-01 Thread Robert M. Münch via Digitalmars-d-learn

I have quite often this pattern:

with(x.y.z){
xyzFunc();  // = x.y.z.xyzFunc()
myFunc(x.y.z, ...);
}

and it would be cool to write:

with(t = x.y.z){ // work like an implicit alias
xyzFunc();  // = x.y.z.xyzFunc()
myFunc(t, ...);
}

Is there anything which comes near this idea?

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Feb 01, 2020 at 08:01:34PM +, Andre Pany via Digitalmars-d-learn 
wrote:
[...]
> Another approach:
> - include the dmd compiler package with your application
> - within your app call the compiler executable and compile the source
> code to a dll / so
> - call the dll / so function
[...]

I've actually done this before in an equation grapher program: the user
inputs an equation, the program generates D code to compute the
equation, then runs dmd to compile it into a shared library, and opens
the shared library and looks up the symbol to execute the compiled code.
Dmd is fast enough that this actually works fairly well. When the input
to dmd is small, it's so fast you don't even notice it.


T

-- 
An imaginary friend squared is a real enemy.


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn

On Saturday, 1 February 2020 at 14:42:58 UTC, Seb wrote:

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

Hi
I want to start a small server, that will be accessible form 
outside. Not a huge deal right?

Not quite.

[...]


What version of dub did you install? 1.19 should be the latest.


PS:
As suggested, i try to build dub from github, following: 
https://github.com/dlang/dub/releases


I call ./build.d - and everything stops, and machine crashes.

Same for the master branch


Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread Andre Pany via Digitalmars-d-learn

On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote:
I see that DUB has DMD as a library package, but I was not able 
to understand how to use it.


Is it possible to use DMD as a library within a D program to 
compile a string to machine code and run the compiled code at 
runtime?


Thanks,
Saurabh


Another approach:
- include the dmd compiler package with your application
- within your app call the compiler executable and compile the 
source code to a dll / so

- call the dll / so function

Maybe you will get some trouble with AV software with this 
approach...


Kind regards
Andre



Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn

On Saturday, 1 February 2020 at 14:42:58 UTC, Seb wrote:

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

Hi
I want to start a small server, that will be accessible form 
outside. Not a huge deal right?

Not quite.

[...]


What version of dub did you install? 1.19 should be the latest.


1.18.2


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn
On Saturday, 1 February 2020 at 14:30:36 UTC, Steven 
Schveighoffer wrote:


How is your network connection to the dub server? Maybe there 
is a separate problem with network connectivity.


This thing works for me (dub upgrade takes about 2.5 seconds 
and finishes). How long does it take for your process to give 
up?


In any case, maybe the dub check to see if it's "taking too 
long" needs to take into account progress that is being made (a 
"pathalogical case" suggests it's not making progress).


-Steve


With dub 1.18 more than 5 minutes.

If i use dub search dub, it finishes in seconds.

dub fetch dub is fine too.

dub run dub takes 10-12 seconds, and throws the same dependency 
error


Re: Unexpected issue with std.format

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 1 February 2020 at 15:16:41 UTC, Steven 
Schveighoffer wrote:

On 2/1/20 8:39 AM, Saurabh Das wrote:
I faced this issue while working with custom formatting for a 
struct. I have reduced the error down to this test program:


import std.format, std.stdio, std.array;

struct Test1
{
     void toString(W, C)(ref W w, scope const ref FormatSpec!C 
fmt)

     {
     pragma(msg, "Test1 function compiled with W=" ~ 
W.stringof);

     // formatValue(w, this, fmt);
     }
}

struct Test2
{
     void toString(W, C)(ref W w, scope const ref FormatSpec!C 
fmt)

     {
     pragma(msg, "Test2 function compiled with W=" ~ 
W.stringof);

     formatValue(w, this, fmt);
     }
}

void main()
{
     Test1 t1;
     Test2 t2;

     Appender!string writer;
     auto ff = singleSpec("%s");

     formatValue(writer, t1, ff);
     formatValue(writer, t2, ff);
}

When compiled, the output is:

Test1 function compiled with W=S
Test1 function compiled with W=Appender!string
Test2 function compiled with W=S

1. Why was Test2 never compiled with W=Appender!string?
2. What is "S"?

Essentially, my custom struct was not being formatted using 
the toString method that I had written. Reducing the issue, it 
seems like a call to formatValue with the same type caused the 
issue. If someone can explain what I am doing wrong here, it 
would really help a lot.


Thanks,
Saurabh



Something very weird is happening.

I switched to fullyQualifiedName!W, and I get *no output*.

The "S" comes from hasToString 
here:https://github.com/dlang/phobos/blob/9fe5cd354f0166b11d32a5c1214932757d8e7eba/std/format.d#L3876-L3899


I tried copying the implementation to a local file, and as 
expected, I get customPutWriterFormatSpec for both types.


But it's only calling one of them in the implementation.

I think the only true way to diagnose this is to instrument 
std.format and see what it's doing with more pragma(msg) calls. 
Don't have the time right now.


-Steve


Thanks for the lead. To exemplify Steve's observation:

import std.format, std.stdio, std.array, std.range;

struct Test3
{
void toString(W, C)(ref W w,  scope const ref FormatSpec!C 
fmt)

{
import std.traits;
pragma(msg, "A: Test2 function compiled with W=" ~ 
fullyQualifiedName!W.stringof);
pragma(msg, "B: Test2 function compiled with W=" ~ 
W.stringof);

}
}

void main()
{
Test3 t3;

Appender!string writer;
auto ff = singleSpec("%s");

formatValue(writer, t3, ff);
}

Gives an output during compilation:
B: Test2 function compiled with W=S


Saurabh



Re: Unexpected issue with std.format

2020-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn

On 2/1/20 8:39 AM, Saurabh Das wrote:
I faced this issue while working with custom formatting for a struct. I 
have reduced the error down to this test program:


import std.format, std.stdio, std.array;

struct Test1
{
     void toString(W, C)(ref W w, scope const ref FormatSpec!C fmt)
     {
     pragma(msg, "Test1 function compiled with W=" ~ W.stringof);
     // formatValue(w, this, fmt);
     }
}

struct Test2
{
     void toString(W, C)(ref W w, scope const ref FormatSpec!C fmt)
     {
     pragma(msg, "Test2 function compiled with W=" ~ W.stringof);
     formatValue(w, this, fmt);
     }
}

void main()
{
     Test1 t1;
     Test2 t2;

     Appender!string writer;
     auto ff = singleSpec("%s");

     formatValue(writer, t1, ff);
     formatValue(writer, t2, ff);
}

When compiled, the output is:

Test1 function compiled with W=S
Test1 function compiled with W=Appender!string
Test2 function compiled with W=S

1. Why was Test2 never compiled with W=Appender!string?
2. What is "S"?

Essentially, my custom struct was not being formatted using the toString 
method that I had written. Reducing the issue, it seems like a call to 
formatValue with the same type caused the issue. If someone can explain 
what I am doing wrong here, it would really help a lot.


Thanks,
Saurabh



Something very weird is happening.

I switched to fullyQualifiedName!W, and I get *no output*.

The "S" comes from hasToString 
here:https://github.com/dlang/phobos/blob/9fe5cd354f0166b11d32a5c1214932757d8e7eba/std/format.d#L3876-L3899


I tried copying the implementation to a local file, and as expected, I 
get customPutWriterFormatSpec for both types.


But it's only calling one of them in the implementation.

I think the only true way to diagnose this is to instrument std.format 
and see what it's doing with more pragma(msg) calls. Don't have the time 
right now.


-Steve


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread kinke via Digitalmars-d-learn

On Saturday, 1 February 2020 at 14:52:21 UTC, kinke wrote:
Trivial cases like yours should actually work wrt. using C++ 
ctor implementations from D IIRC.


Ah, you need at least one virtual function in the C++ class 
(because D always reserves a vptr, the pointer to the class 
vtable).


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread kinke via Digitalmars-d-learn

On Saturday, 1 February 2020 at 08:15:20 UTC, Luhrel wrote:

But somehow I got a segfault on dcpp.getNumber(true).


That's because you declare it as virtual in D (default for 
classes, use `final`), but non-virtual in C++. You also forgot to 
add the class field to the D declaration (yes, D needs to know 
about the struct layout and size too, especially when you `new` 
the class in D and let the GC allocate it).


Trivial cases like yours should actually work wrt. using C++ ctor 
implementations from D IIRC.


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread Seb via Digitalmars-d-learn

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

Hi
I want to start a small server, that will be accessible form 
outside. Not a huge deal right?

Not quite.

[...]


What version of dub did you install? 1.19 should be the latest.


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn

On 2/1/20 6:15 AM, seany wrote:



$ dub init server -t vibe.d
Package recipe format (sdl/json) [json]:
Name [server]:
Description [A simple vibe.d server application.]:
Author name [root]:
License [proprietary]:
Copyright string [Copyright © 2020, root]:
Add dependency (leave empty to skip) []:
Successfully created an empty project in '/root/progs/D/server'.
Package successfully created in server

$ cd server
$ dub upgrade
Upgrading project in /root/progs/D/server
The dependency resolution process is taking too long. The dependency 
graph is likely hitting a pathological case in the resolution algorithm. 
Please file a bug report at https://github.com/dlang/dub/issues and 
mention the package recipe that reproduces this error.



$ dub upgrade vibe.d
Upgrading project in /root/progs/D/server
The dependency resolution process is taking too long. The dependency 
graph is likely hitting a pathological case in the resolution algorithm. 
Please file a bug report at https://github.com/dlang/dub/issues and 
mention the package recipe that reproduces this error.


How is your network connection to the dub server? Maybe there is a 
separate problem with network connectivity.


This thing works for me (dub upgrade takes about 2.5 seconds and 
finishes). How long does it take for your process to give up?


In any case, maybe the dub check to see if it's "taking too long" needs 
to take into account progress that is being made (a "pathalogical case" 
suggests it's not making progress).


-Steve


Re: Unexpected issue with std.format

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn

On Saturday, 1 February 2020 at 13:39:34 UTC, Saurabh Das wrote:
I faced this issue while working with custom formatting for a 
struct. I have reduced the error down to this test program:


[...]


PS: Currently using DMD64 D Compiler v2.090.0


Unexpected issue with std.format

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn
I faced this issue while working with custom formatting for a 
struct. I have reduced the error down to this test program:


import std.format, std.stdio, std.array;

struct Test1
{
void toString(W, C)(ref W w, scope const ref FormatSpec!C fmt)
{
pragma(msg, "Test1 function compiled with W=" ~ 
W.stringof);

// formatValue(w, this, fmt);
}
}

struct Test2
{
void toString(W, C)(ref W w, scope const ref FormatSpec!C fmt)
{
pragma(msg, "Test2 function compiled with W=" ~ 
W.stringof);

formatValue(w, this, fmt);
}
}

void main()
{
Test1 t1;
Test2 t2;

Appender!string writer;
auto ff = singleSpec("%s");

formatValue(writer, t1, ff);
formatValue(writer, t2, ff);
}

When compiled, the output is:

Test1 function compiled with W=S
Test1 function compiled with W=Appender!string
Test2 function compiled with W=S

1. Why was Test2 never compiled with W=Appender!string?
2. What is "S"?

Essentially, my custom struct was not being formatted using the 
toString method that I had written. Reducing the issue, it seems 
like a call to formatValue with the same type caused the issue. 
If someone can explain what I am doing wrong here, it would 
really help a lot.


Thanks,
Saurabh



GtkDcoding Featured Coder Program

2020-02-01 Thread Ron Tarrant via Digitalmars-d-learn
Everybody knows what I’ve been doing with GtkD for the last 
year—writing blog posts. But what about all of you? What projects 
are you working on using GtkD? What finished applications do you 
have that use GtkD? Or maybe you’re still in the planning stages.


I’d like to start a new series of posts on GtkDcoding wherein I 
interview you and we talk about the coding projects you’re 
involved in and how GtkD figures into it.


No matter what stage you’re at, drop me a line at 
gtkdcod...@gmail.com and let’s talk.




Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn

On Saturday, 1 February 2020 at 11:15:49 UTC, seany wrote:
On Saturday, 1 February 2020 at 11:08:46 UTC, Ferhat Kurtulmuş 
wrote:

[...]


I even tried:

$ dub fetch dub
Fetching dub 1.19.0...
Please note that you need to use `dub run ` or add it to 
dependencies of your package to actually use/run it. dub does not 
do actual installation of packages outside of its own ecosystem.



$ dub run dub
Building package dub in /root/.dub/packages/dub-1.19.0/dub/
Fetching libevent 2.0.2+2.0.16 (getting selected version)...
Fetching diet-ng 1.6.0 (getting selected version)...
Fetching taggedalgebraic 0.11.8 (getting selected version)...
Fetching botan 1.12.10 (getting selected version)...
Fetching stdx-allocator 2.77.5 (getting selected version)...
Fetching vibe-d 0.8.6 (getting selected version)...
Fetching mir-linux-kernel 1.0.1 (getting selected version)...
Fetching memutils 0.4.13 (getting selected version)...
Fetching vibe-core 1.8.1 (getting selected version)...
Fetching libasync 0.8.4 (getting selected version)...
Fetching botan-math 1.0.3 (getting selected version)...
Fetching eventcore 0.8.48 (getting selected version)...
The dependency resolution process is taking too long. The 
dependency graph is likely hitting a pathological case in the 
resolution algorithm. Please file a bug report at 
https://github.com/dlang/dub/issues and mention the package 
recipe that reproduces this error.




Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn
On Saturday, 1 February 2020 at 11:08:46 UTC, Ferhat Kurtulmuş 
wrote:



Have you tried
dub upgrade



$ dub init server -t vibe.d
Package recipe format (sdl/json) [json]:
Name [server]:
Description [A simple vibe.d server application.]:
Author name [root]:
License [proprietary]:
Copyright string [Copyright © 2020, root]:
Add dependency (leave empty to skip) []:
Successfully created an empty project in '/root/progs/D/server'.
Package successfully created in server

$ cd server
$ dub upgrade
Upgrading project in /root/progs/D/server
The dependency resolution process is taking too long. The 
dependency graph is likely hitting a pathological case in the 
resolution algorithm. Please file a bug report at 
https://github.com/dlang/dub/issues and mention the package 
recipe that reproduces this error.



$ dub upgrade vibe.d
Upgrading project in /root/progs/D/server
The dependency resolution process is taking too long. The 
dependency graph is likely hitting a pathological case in the 
resolution algorithm. Please file a bug report at 
https://github.com/dlang/dub/issues and mention the package 
recipe that reproduces this error.



$ cd
$ dub upgrade
There was no package description found for the application in 
'/root/progs/D'.

Upgrading project in /root/progs/D


Now I repeated:

$ cd server
$ dub upgrade
Upgrading project in /root/progs/D/server
The dependency resolution process is taking too long. The 
dependency graph is likely hitting a pathological case in the 
resolution algorithm. Please file a bug report at 
https://github.com/dlang/dub/issues and mention the package 
recipe that reproduces this error.



$ dub upgrade vibe.d
Upgrading project in /root/progs/D/server
The dependency resolution process is taking too long. The 
dependency graph is likely hitting a pathological case in the 
resolution algorithm. Please file a bug report at 
https://github.com/dlang/dub/issues and mention the package 
recipe that reproduces this error.


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Saturday, 1 February 2020 at 11:02:45 UTC, seany wrote:
On Saturday, 1 February 2020 at 10:58:14 UTC, Ferhat Kurtulmuş 
wrote:

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

As suggested, i try to build dub from github, following: 
https://github.com/dlang/dub/releases



I don't know if it is a solution. But you can try using 
~master branch, not a release on GitHub.



You can also try my vibed app skeleton:
https://github.com/aferust/simplerestvibed
İ simply run it with dub command.


sadly, also doesn't work. same as the full system crash


Have you tried
dub upgrade


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn
On Saturday, 1 February 2020 at 10:58:14 UTC, Ferhat Kurtulmuş 
wrote:

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

As suggested, i try to build dub from github, following: 
https://github.com/dlang/dub/releases



I don't know if it is a solution. But you can try using ~master 
branch, not a release on GitHub.



You can also try my vibed app skeleton:
https://github.com/aferust/simplerestvibed
İ simply run it with dub command.


sadly, also doesn't work. same as the full system crash


Re: Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Saturday, 1 February 2020 at 10:35:52 UTC, seany wrote:

As suggested, i try to build dub from github, following: 
https://github.com/dlang/dub/releases



I don't know if it is a solution. But you can try using ~master 
branch, not a release on GitHub.



You can also try my vibed app skeleton:
https://github.com/aferust/simplerestvibed
İ simply run it with dub command.


Dub - vibe.d - hunt framework ... problems

2020-02-01 Thread seany via Digitalmars-d-learn

Hi
I want to start a small server, that will be accessible form 
outside. Not a huge deal right?

Not quite.

My machine: 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 
UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


DMD : DMD64 D Compiler v2.090.0
Copyright (C) 1999-2019 by The D Language Foundation, All Rights 
Reserved written by Walter Bright



Now, I try to install dub from the official repo.
Then I do

* dub init server -t vibe.d
* cd server
* dub

I hit this issue : https://github.com/dlang/dub/issues/1712

As suggested, i try to build dub from github, following: 
https://github.com/dlang/dub/releases


I call ./build.d - and everything stops, and machine crashes.

I then try to install DaNode: 
https://github.com/DannyArends/DaNode


It breaks with : module std.algorithm import 'mean' not found

Then I try to install the Hunt Framework. It breaks with : basic 
type

expected, not foreach


Please help. I really want this issue to be resolved-


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Saturday, 1 February 2020 at 10:21:54 UTC, norm wrote:

On Saturday, 1 February 2020 at 08:38:22 UTC, Luhrel wrote:
On Saturday, 1 February 2020 at 08:32:51 UTC, Ferhat Kurtulmuş 
wrote:

On Saturday, 1 February 2020 at 08:27:07 UTC, Luhrel wrote:
On Saturday, 1 February 2020 at 08:21:29 UTC, Ferhat 
Kurtulmuş wrote:

[...]


Oh I see, so there's definitively no way to call a c++ ctor 
without modifying the c++ code ?


İf you are not allowed to modify that c++ code, you can write 
a createInstance function in your custom cpp file.


That was my fear.


It isn't too bad, you need a simple wedge written in C++ that 
returns an instance of any T you want. A simple template 
function usually works, or to make it more generic you can use 
a variadic template to handle N args, but I find variadic 
templates in C++ are still annoying to use.


And do not forget to write a void cppDestroy(T instance) function 
that runs delete instance in c++ so that you can call it from D 
code.


void cppDestroy(T instance)


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread norm via Digitalmars-d-learn

On Saturday, 1 February 2020 at 08:38:22 UTC, Luhrel wrote:
On Saturday, 1 February 2020 at 08:32:51 UTC, Ferhat Kurtulmuş 
wrote:

On Saturday, 1 February 2020 at 08:27:07 UTC, Luhrel wrote:
On Saturday, 1 February 2020 at 08:21:29 UTC, Ferhat 
Kurtulmuş wrote:


You cannot. 
https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d


You must use a factory method like createInstance.


Oh I see, so there's definitively no way to call a c++ ctor 
without modifying the c++ code ?


İf you are not allowed to modify that c++ code, you can write 
a createInstance function in your custom cpp file.


That was my fear.


It isn't too bad, you need a simple wedge written in C++ that 
returns an instance of any T you want. A simple template function 
usually works, or to make it more generic you can use a variadic 
template to handle N args, but I find variadic templates in C++ 
are still annoying to use.


Re: Question about alias and getOverloads

2020-02-01 Thread uranuz via Digitalmars-d-learn

OK. Thanks. Created two reports related to these questions:
https://issues.dlang.org/show_bug.cgi?id=20553
https://issues.dlang.org/show_bug.cgi?id=20555


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread Luhrel via Digitalmars-d-learn
On Saturday, 1 February 2020 at 08:32:51 UTC, Ferhat Kurtulmuş 
wrote:

On Saturday, 1 February 2020 at 08:27:07 UTC, Luhrel wrote:
On Saturday, 1 February 2020 at 08:21:29 UTC, Ferhat Kurtulmuş 
wrote:


You cannot. 
https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d


You must use a factory method like createInstance.


Oh I see, so there's definitively no way to call a c++ ctor 
without modifying the c++ code ?


İf you are not allowed to modify that c++ code, you can write a 
createInstance function in your custom cpp file.


That was my fear.


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Saturday, 1 February 2020 at 08:27:07 UTC, Luhrel wrote:
On Saturday, 1 February 2020 at 08:21:29 UTC, Ferhat Kurtulmuş 
wrote:


You cannot. 
https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d


You must use a factory method like createInstance.


Oh I see, so there's definitively no way to call a c++ ctor 
without modifying the c++ code ?


İf you are not allowed to modify that c++ code, you can write a 
createInstance function in your custom cpp file.


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread Luhrel via Digitalmars-d-learn
On Saturday, 1 February 2020 at 08:21:29 UTC, Ferhat Kurtulmuş 
wrote:


You cannot. 
https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d


You must use a factory method like createInstance.


Oh I see, so there's definitively no way to call a c++ ctor 
without modifying the c++ code ?


Re: How to call a extern C++ class constructor ?

2020-02-01 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Saturday, 1 February 2020 at 08:15:20 UTC, Luhrel wrote:

Hello there,

I would like to know how can I call a C++ ctor.

[...]


You cannot. 
https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d


You must use a factory method like createInstance.


How to call a extern C++ class constructor ?

2020-02-01 Thread Luhrel via Digitalmars-d-learn

Hello there,

I would like to know how can I call a C++ ctor.

Actually, I have this:

C++:
CppClass.cpp

#include "CppClass.h"


AmazingCppClass::AmazingCppClass()
{
number = 124;
}

int AmazingCppClass::getNumber(bool show)
{
if (show)
printf("Number: %s", number);
return number;
}

void AmazingCppClass::add(int num)
{
number += num;
}

CppClass.h:

#include 


class AmazingCppClass
{
private:
int number;

public:
AmazingCppClass();
int getNumber(bool show);
void add(int num);
};


D:
app.d

import std.stdio;

void main()
{
auto dcpp = new AmazingCppClass();
dcpp.getNumber(true); //segfault here
}

extern(C++) class AmazingCppClass
{
this();

int getNumber(bool show);

void add(int num);
}


But somehow I got a segfault on dcpp.getNumber(true).
I found that there's a __cpp_new 
(https://dlang.org/phobos/core_stdcpp_new_.html), but I have no 
idea how to use it and the doc doesn't say a lot about this 
(https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d)


Do you guys know ?


Re: How make Executable Dlang EXE ask for "Run as Administrator"?

2020-02-01 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Saturday, 1 February 2020 at 06:26:04 UTC, Marcone wrote:

I created a program in Dlang and compiled to exe using dmd.
But my program need administrator privileges. How can I make 
executable dlang program ask for administrator privileges on 
start up program?


Disclaimer: did not tried. You must somehow embed this manifest 
file into your exe using  some linker parameter. Or put this 
manifest next to your exe by naming it MyApplication.exe.manifest.



manifestVersion="1.0">

  
  Description of your application