Re: ffmpeg

2017-08-19 Thread Jolly James via Digitalmars-d-learn

On Saturday, 19 August 2017 at 02:50:44 UTC, Johnson Jones wrote:

Trying to get it to work.



You could just try to use/call the ffmeg executable as wrapper. 
For sure, not the best, but proabably the easiest solution. Afaik 
it also supports pipes.


Re: Remove instance from array

2017-07-06 Thread Jolly James via Digitalmars-d-learn

On Thursday, 6 July 2017 at 08:15:10 UTC, Andrea Fontana wrote:

On Wednesday, 5 July 2017 at 16:17:29 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

[...]




Part of CoreCLR's 'List':


[...]



If there isn't already, maybe something similar to this should 
get part of Phobos. I think this could be really useful.


q = q.remove(1); // Remove element with index 1
q = q.remove(x => x == instance); // Remove all items that 
match instance


thx


Re: dub + local dependencies

2017-07-06 Thread Jolly James via Digitalmars-d-learn

On Thursday, 6 July 2017 at 00:12:25 UTC, Mike Parker wrote:

On Thursday, 6 July 2017 at 00:09:46 UTC, Mike Parker wrote:



You have a few options:

* Use a path dependency:
"dependencies": {
 "xyz": { "path": "path/to/xyz" }
}

* Use add-local with a version on the command line:
dub add-local path/to/xyz  0.0.1

* Use add-local or add-paths and specify a version as 
described by `dub add-paths -h`


Sorry -- extraneous `s` on the `path` bit.

And for the record:

https://code.dlang.org/docs/commandline#add-local
https://code.dlang.org/docs/commandline#add-path
https://code.dlang.org/package-format?lang=json#version-specs


thx


Re: unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 19:01:06 UTC, Jonathan M Davis wrote:
On Wednesday, July 05, 2017 18:50:32 Jolly James via 
Digitalmars-d-learn wrote:

On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote:
> On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:
>> [...]
>
> where would I find these *.lst files. Searching for '*.lst' 
> in the source's root dir doesn't bring any results.


I have changed the 'build' to 'test' in the command. Now at 
least I get the following message: "All unit tests have been 
run successfully." which should not actually happen, as my 
code contains an 'assert(false);' unittest.


If you don't run the tests, you won't get any code coverage. 
Building with


dub test --coverage


The following command does not change anything:
  dub test --coverage --arch=x86_64 --compiler=ldc2
All I get is "All unit tests have been run successfully." in the 
command line.



should do it. As for your assert(false) test failing, was it in 
the same module with your main in it?


No, this test is actually in module 'tools.array'.



Re: unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 18:46:38 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:

On Wednesday, 5 July 2017 at 17:46:01 UTC, Jolly James wrote:

[...]


For every file a `.lst` file is generated (it's the same 
how `-cov` behaves at DMD).
These .lst files contain the original source code with number 
of hits of a respective line:


  2|auto copy = new char[s.length + 1];
  2|copy[0 .. s.length] = s[];
  2|copy[s.length] = 0;

Maybe you haven't seen the lst files?


Btw if you use Travis, you can use an `after_success` event to 
your `.travis.yml` to upload the results to CodeCov for a nice 
visuals & PR integration:


```
after_success:
 - bash <(curl -s https://codecov.io/bash)
```

We do this on most dlang repos, e.g. 
https://github.com/dlang/phobos/pull/5503


where would I find these *.lst files. Searching for '*.lst' in 
the source's root dir doesn't bring any results.


I have changed the 'build' to 'test' in the command. Now at least 
I get the following message: "All unit tests have been run 
successfully." which should not actually happen, as my code 
contains an 'assert(false);' unittest.


Re: unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 18:09:46 UTC, Seb wrote:

On Wednesday, 5 July 2017 at 17:46:01 UTC, Jolly James wrote:

[...]


For every file a `.lst` file is generated (it's the same 
how `-cov` behaves at DMD).
These .lst files contain the original source code with number 
of hits of a respective line:


  2|auto copy = new char[s.length + 1];
  2|copy[0 .. s.length] = s[];
  2|copy[s.length] = 0;

Maybe you haven't seen the lst files?


Btw if you use Travis, you can use an `after_success` event to 
your `.travis.yml` to upload the results to CodeCov for a nice 
visuals & PR integration:


```
after_success:
 - bash <(curl -s https://codecov.io/bash)
```

We do this on most dlang repos, e.g. 
https://github.com/dlang/phobos/pull/5503


where would I find these *.lst files. Searching for '*.lst' in 
the source's root dir doesn't bring any results.


unittest-cov - results?

2017-07-05 Thread Jolly James via Digitalmars-d-learn

How does unit testing with dub work?

dub build --arch=x86_64 --build=unittest-cov --force 
--compiler=ldc2


After execution, there is no result output in the command line.


Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 16:55:43 UTC, bachmeier wrote:

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

Here in D everything looks like climbing mount everest. When 
you ask how to use D's containers you are recommended to use 
dynamic arrays instead. When you look at the docs for 
std.algorithm, e.g. the .remove section, you get bombed with 
things like 'SwapStrategy.unstable', asserts and tuples, but 
you aren't told how to simply remove 1 specific element.


If you feel that there is a problem with the docs, you should 
file a bug: https://dlang.org/bugstats.php


The documentation is still not perfect, but the only way to 
improve it is to file bugs when you see something that needs 
fixing.


unfortunately, it's not that the docs would be wrong or something 
that can be easily corrected. Nope, the docs do everything right, 
they show you what the existing things do. But what they don't do 
is how to get stuff done. imho some additional, useful guides 
would be nice.


Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote:

[...]


Thank you! :)


But why a containers so complicated in D?

[...]




Part of CoreCLR's 'List':


   public bool Remove(T item)
   {
   int index = IndexOf(item);
   if (index >= 0)
   {
   RemoveAt(index);
   return true;
   }

   return false;
   }
// 
https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Collections/Generic/List.cs



If there isn't already, maybe something similar to this should 
get part of Phobos. I think this could be really useful.


Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote:

On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote:
On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin 
wrote:

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


I would like to know how works: removing
 - the first
 - and all
references to 'i' inside the 'q'.


Perhaps, for all references to i it should look like:
a = a.filter!(a => a !is i).array;


Thank you! :)


But why a containers so complicated in D?

In C# I would go for a generic List, which would support 
structs and classes, where I simply could call '.Remove(T item)' 
or '.RemoveAt(int index)'. I would know how this works, because 
the method names make sense, the docs are straight forward.


Here in D everything looks like climbing mount everest. When you 
ask how to use D's containers you are recommended to use dynamic 
arrays instead. When you look at the docs for std.algorithm, e.g. 
the .remove section, you get bombed with things like 
'SwapStrategy.unstable', asserts and tuples, but you aren't told 
how to simply remove 1 specific element.


Re: Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote:

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


I would like to know how works: removing
 - the first
 - and all
references to 'i' inside the 'q'.


dub + local dependencies

2017-07-05 Thread Jolly James via Digitalmars-d-learn
WARNING: A deprecated branch based version specification is 
used for the dependency xyz.

Please use numbered versions instead.
Also note that you can still use the dub.selections.json file 
to override a certain dependency to use a branch instead.



The problem is: xyz is a local package and therefor I don't know 
how to specify its version. So in the dub.json of the package abc 
requiring xyz is written:




"dependencies": {
"xyz": "~master"
},



Is there a cleaner solution?


Remove instance from array

2017-07-05 Thread Jolly James via Digitalmars-d-learn

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


Re: Linking external *.lib files

2017-06-21 Thread Jolly James via Digitalmars-d-learn

*push*



Re: Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

On Saturday, 17 June 2017 at 00:33:01 UTC, Jolly James wrote:

On Saturday, 17 June 2017 at 00:09:41 UTC, Jolly James wrote:

Let's assume, I have the following 2 dub packages:


pkgBASE:
(depends on public DUB package)
source/
lib/
pkgAPP:
(depends on pkgBASE)
source/


I have added pkgBASE via add-path. This wasn't a problem at 
all.


Unfortunately, the public DUB package requires to be linked 
with the libs from pkgBASE/lib. What do I have to add to 
pkgBASE's dub.json?


Side-note: the lib/ should not be moved for portability reasons 
if this is possible




My bad solution:


"lflags": [
"-Llib\\"
],



but this requires the lib folder to be part of pkgAPP, not 
pkgBASE where I would like to have it. Does anyone have an idea?


Re: Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

On Saturday, 17 June 2017 at 00:09:41 UTC, Jolly James wrote:

Let's assume, I have the following 2 dub packages:


pkgBASE:
(depends on public DUB package)
source/
lib/
pkgAPP:
(depends on pkgBASE)
source/


I have added pkgBASE via add-path. This wasn't a problem at all.

Unfortunately, the public DUB package requires to be linked 
with the libs from pkgBASE/lib. What do I have to add to 
pkgBASE's dub.json?


Side-note: the lib/ should not be moved for portability reasons 
if this is possible


Re: Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

Let's assume, I have the following 2 dub packages:


pkgBASE:
(depends on public DUB package)
source/
lib/
pkgAPP:
(depends on pkgBASE)
source/


I have added pkgBASE via add-path. This wasn't a problem at all.

Unfortunately, the public DUB package requires to be linked with 
the libs from pkgBASE/lib. What do I have to add to pkgBASE's 
dub.json?


Linking external *.lib files

2017-06-16 Thread Jolly James via Digitalmars-d-learn

Let's assume, I have the following 2 dub packages:

pkgBASE:
source/
lib/

pkgAPP:



String Comparison Operator

2017-04-30 Thread Jolly James via Digitalmars-d-learn

Is there a String Comparison Operator in D?


Re: Howto catch SocketOSException?

2017-03-27 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 21:57:29 UTC, Jolly James wrote:

On Sunday, 26 March 2017 at 18:50:13 UTC, bauss wrote:

[...]


If you want try to help me, mabye this helps you:
https://github.com/CyberShadow/ae/blob/master/net/asockets.d#L1237


Finally found the bug: I had a logical error in the way how I 
used this code.


Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 18:50:13 UTC, bauss wrote:

On Sunday, 26 March 2017 at 11:46:39 UTC, Jolly James wrote:

[...]


Chances are it's invoked in another thread and thus you can't 
catch it like that.


To sum it up.

Ex.

void thisFunctionThrows() { ... }

void ableToCatch() {
try {
thisFunctionThrows();
}
catch (Exception e) {
// We can catch the exception ...
}
}

void notAbleToCatch() {
try {
spawn();
}
catch (Exception e) {
// We cannot catch the exception ...
}
}

void ableToCatchToo() {
spawn(); // We're able to handle the exception, 
because the try/catch is handled in the thread that calls the 
function that throws.

}


If you want try to help me, mabye this helps you:
https://github.com/CyberShadow/ae/blob/master/net/asockets.d#L1237


Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 11:35:00 UTC, Jolly James wrote:

On Sunday, 26 March 2017 at 02:41:46 UTC, Adam D. Ruppe wrote:

On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote:
You can ignore the loop()-method. It is not called as the 
application will never reach this statement, because it 
cannot, because it crashes already in the listen()-method in 
consequence of the exception that does not get caught by the 
try-catch block.


Try putting it in the try anyway and see what happens.

It is an async socket library, they can do weird things.\


Unfortunately not working either. I should not forget to 
mention that the exception also raises when the code does not 
contain the loop()-call.


Found out something: You cannot catch any exception thrown in the 
listen()-method in general.



■ Original code:
auto addressInfos = getAddressInfo(addr, to!string(port), 
AddressInfoFlags.PASSIVE, SocketType.STREAM, ProtocolType.TCP);



■ Modified one:

AddressInfo[] addressInfos;

try
{
	addressInfos = getAddressInfo(addr, to!string(port), 
AddressInfoFlags.PASSIVE, SocketType.STREAM, ProtocolType.TCP);

}
catch(SocketOSException e)
{
throw new Exception("Invalid address: " ~ addr, e);
}



■ Not working try-catch:

try
{
tcp.listen(2345, "127.0.0.1c");
socketManager.loop();
}
catch (Exception e)
{
return;
}


Re: Howto catch SocketOSException?

2017-03-26 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 02:41:46 UTC, Adam D. Ruppe wrote:

On Sunday, 26 March 2017 at 02:24:56 UTC, Jolly James wrote:
You can ignore the loop()-method. It is not called as the 
application will never reach this statement, because it 
cannot, because it crashes already in the listen()-method in 
consequence of the exception that does not get caught by the 
try-catch block.


Try putting it in the try anyway and see what happens.

It is an async socket library, they can do weird things.\


Unfortunately not working either. I should not forget to mention 
that the exception also raises when the code does not contain the 
loop()-call.


Re: Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn

On Sunday, 26 March 2017 at 01:22:24 UTC, bauss wrote:

On Sunday, 26 March 2017 at 00:34:03 UTC, Jolly James wrote:

[...]


This part:
catch (std.socket.SocketOSException e)

[...]


[...]


I know that inheritance stuff, but none (!) of them catches that 
strange exception either. You can ignore the loop()-method. It is 
not called as the application will never reach this statement, 
because it cannot, because it crashes already in the 
listen()-method in consequence of the exception that does not get 
caught by the try-catch block.



std.socket.SocketOSException@std\socket.d(975): getaddrinfo 
error: Unknow host.


	0x004205BE in pure @safe bool 
std.exception.enforce!(bool).enforce(bool, lazy object.Throwable)
	0x0040D3A2 in @trusted std.socket.AddressInfo[] 
std.socket.getAddressInfo!(immutable(char)[], 
std.socket.AddressInfoFlags, std.socket.SocketType, 
std.socket.ProtocolType).getAddressInfo(const(char[]), 
immutable(char)[], std.socket.AddressInfoFlags, 
std.socket.SocketType, std.socket.ProtocolType).__lambda7()
	0x0040D37B in @safe std.socket.AddressInfo[] 
std.socket.getAddressInfo!(immutable(char)[], 
std.socket.AddressInfoFlags, std.socket.SocketType, 
std.socket.ProtocolType).getAddressInfo(const(char[]), 
immutable(char)[], std.socket.AddressInfoFlags, 
std.socket.SocketType, std.socket.ProtocolType) at 
C:\dlang\dmd2\windows\bin\..\..\src\phobos\std\socket.d(945)
	0x00404DAF in ushort ae.net.asockets.TcpServer.listen(ushort, 
immutable(char)[]) at C:\Users\jolly\src\ae\net\asockets.d(1242)

0x00416749 in _Dmain at C:\Users\jolly\src\app.d(48)
	0x00423597 in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
	0x0042355B in void rt.dmain2._d_run_main(int, char**, extern 
(C) int function(char[][])*).runAll()

0x0042345C in _d_run_main
0x00417D74 in main at C:\Users\jolly\src\ae\net\asockets.d(7)
0x00443EBD in mainCRTStartup
0x757362C4 in BaseThreadInitThunk
0x773C0FD9 in RtlSubscribeWnfStateChangeNotification
0x773C0FA4 in RtlSubscribeWnfStateChangeNotification


↑ stacktrace


Howto catch SocketOSException?

2017-03-25 Thread Jolly James via Digitalmars-d-learn

How do you catch an std.socket.SocketOSException?


The following does not work, as the exception occurs anyway and 
leads to a crash:



import ae.net.asockets;

void main(string[] args)
{
TcpServer tcp = new TcpServer();

try
{
tcp.listen(2345, "127.0.0.1c");
// '...c' makes the IP address invalid
}
catch (std.socket.SocketOSException e)
{
return;
}
catch (Exception e)
{
return;
}

socketManager.loop();
}


Output:
std.socket.SocketOSException@std\socket.d(975): getaddrinfo 
error: Unknown Host


Re: About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 17:57:31 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 22 February 2017 at 17:53:21 UTC, Jolly James 
wrote:

No matter how I try, I am always getting:
Error: none of the overloads of '__ctor' are callable using 
argument types (Data*), candidates are: (my-project)


I don't know the library, so I'd have to see the Data class, 
but you might just be using  when you should be using 
plain data.


Silly me!
Now I used Xamarin's Find-Usage-Feature, found one usage in ae 
and realized that there is no reason for using the keyword `new`, 
as Data is a struct (and so one does not need `new` unlike in C#) 
...


Re: About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn

On Wednesday, 22 February 2017 at 17:06:51 UTC, Jolly James wrote:
On Wednesday, 22 February 2017 at 17:01:11 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 22 February 2017 at 16:55:03 UTC, Jolly James 
wrote:
Well, what are these void-arrays for real? I mean, they 
contain data what does not make them really void, does it?


They represent an array of anything; the user can pass ubyte[] 
to it, or int[] to it, or char[] to it, or anything else (even 
string if it is in void[] or const void[]).



And how to I get received data out of Data.content[]?
How to use TcpConnection.send()? E.g. for sending a string?


Cast it to `const(ubyte)[]` then use it as a bag of bytes. 
That's almost always what you want to do inside.


The function signature uses `in void[]` instead of `ubyte[]` 
because void will accept strings and other stuff too, whereas 
ubyte specifically requires it to be typed as bye.


You want to use it INTERNALLY as bytes, but the external 
interface can accept almost anything.


Thank you very much!
Now it makes sense and I understand.


But I have one problem: How to use the constructor of the Data 
class?


No matter how I try, I am always getting:
Error: none of the overloads of '__ctor' are callable using 
argument types (Data*), candidates are: (my-project)


Re: About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 17:01:11 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 22 February 2017 at 16:55:03 UTC, Jolly James 
wrote:
Well, what are these void-arrays for real? I mean, they 
contain data what does not make them really void, does it?


They represent an array of anything; the user can pass ubyte[] 
to it, or int[] to it, or char[] to it, or anything else (even 
string if it is in void[] or const void[]).



And how to I get received data out of Data.content[]?
How to use TcpConnection.send()? E.g. for sending a string?


Cast it to `const(ubyte)[]` then use it as a bag of bytes. 
That's almost always what you want to do inside.


The function signature uses `in void[]` instead of `ubyte[]` 
because void will accept strings and other stuff too, whereas 
ubyte specifically requires it to be typed as bye.


You want to use it INTERNALLY as bytes, but the external 
interface can accept almost anything.


Thank you very much!
Now it makes sense and I understand.


Re: Class Order Style

2017-02-22 Thread Jolly James via Digitalmars-d-learn
On Tuesday, 21 February 2017 at 23:06:23 UTC, Jonathan M Davis 
wrote:
On Tuesday, February 21, 2017 22:41:40 Lenny Lowood via 
Digitalmars-d-learn wrote:

[...]


It's completely a stylistic preference. There are a number of 
different ways to order your member variables and functions, 
and there are several different ways to apply attributes to 
them.


[...]


thank you!


About void[] and asockets

2017-02-22 Thread Jolly James via Digitalmars-d-learn
For sure, some might know ae. I am trying to use it as TcpServer. 
I got almost everything working fine concerning connection 
establishment and disconnecting. But there is one thing that 
makes it hard for me to understand, how to handle data.


https://github.com/CyberShadow/ae/blob/master/net/asockets.d

Well, what are these void-arrays for real? I mean, they contain 
data what does not make them really void, does it?


And how to I get received data out of Data.content[]?
How to use TcpConnection.send()? E.g. for sending a string?


Re: Class Order Style

2017-02-20 Thread Jolly James via Digitalmars-d-learn

On Monday, 20 February 2017 at 13:50:26 UTC, ketmar wrote:
just add ddoc documentation to 'em, and then it doesn't matter 
in which order they are declared: people will generate 
documentation to find out how to use your code. ;-)


ah okay, thx


But what about this?


class A
{
private:
   int a;
   int b;
public:
   int c;
   int d;
}

or

class A
{
   private
   {
   int a;
   int b;
   }
   public
   {
   int c;
   int d;
   }
}


Class Order Style

2017-02-20 Thread Jolly James via Digitalmars-d-learn

How to sort the members of a class?

like:

1. properties
then
2. private 3. methods
4. ctors

... and so on. are there any recommendations?


And what is better?


class A
{
private:
   int a;
   int b;
public:
   int c;
   int d;
}

or

class A
{
   private
   {
   int a;
   int b;
   }
   public
   {
   int c;
   int d;
   }
}