Re: Accessing COM Objects

2016-06-15 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 13 June 2016 at 01:22:33 UTC, Incognito wrote: I've been reading over D's com and can't find anything useful. It seems there are different ways: http://www.lunesu.com/uploads/ModernCOMProgramminginD.pdf which is of no help and requires an idl file, which I don't have. Then

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 14:14:23 UTC, Seb wrote: On Wednesday, 15 June 2016 at 13:13:05 UTC, data pulverizer And where can I find more cool tricks like that? Browse the source code and the unittests. Phobos is an amazing resource :) Very true! That's great many thanks!

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 08:25:35 UTC, data pulverizer wrote: I guess foreach would not copy the elements? for example: foreach(el; slice.byElement) x ~= el; But it feels wrong to be doing work pulling elements that already exists by using foreach. I feel as if I am

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 08:53:22 UTC, Andrea Fontana wrote: On Wednesday, 15 June 2016 at 08:25:35 UTC, data pulverizer wrote: I guess foreach would not copy the elements? for example: foreach(el; slice.byElement) x ~= el; But it feels wrong to be doing work pulling

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 08:56:15 UTC, data pulverizer wrote: On Wednesday, 15 June 2016 at 08:53:22 UTC, Andrea Fontana wrote: On Wednesday, 15 June 2016 at 08:25:35 UTC, data pulverizer wrote: I guess foreach would not copy the elements? for example: foreach(el; slice.byElement)

GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread TheDGuy via Digitalmars-d-learn
Hi, this is my app: import gtk.Main; import gtk.MainWindow; import gtk.CssProvider; import gdk.Display; import gdk.Screen; import gtk.StyleContext; import glib.GException; class Window : MainWindow{ this(int width, int height, string title){ super(title);

GTKD - overrideBackgroundColor of Button doesn't work

2016-06-15 Thread TheDGuy via Digitalmars-d-learn
Hello, why does this code not work? RGBA rgb = new RGBA(1,0.5,0.5,1.0); Button btn_1 = new Button("Start"); btn_1.overrideBackgroundColor(StateFlags.NORMAL, rgb); The color of btn_1 just doesn't change.

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread TheDGuy via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 10:21:20 UTC, Rene Zwanenburg wrote: On Wednesday, 15 June 2016 at 09:48:19 UTC, TheDGuy wrote: But if i execute the app my hand (in the windows command window or my double click) it works as expected (so no error)? Why is that? My first guess would be that

Re: short programme from "Programming in D" by Ali Cehreli.

2016-06-15 Thread Nick B via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 16:09:00 UTC, Steven Schveighoffer wrote: On 6/14/16 11:44 AM, Ali Çehreli wrote: On 06/14/2016 04:52 AM, Nick B wrote: Further, when the format string is a literal like the one used in the program, the compiler can in theory determine at compile time that the

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 09:48:19 UTC, TheDGuy wrote: But if i execute the app my hand (in the windows command window or my double click) it works as expected (so no error)? Why is that? My first guess would be that Coedit does not use the directory where the executable is located as

arr.ptr, @safe and void*

2016-06-15 Thread Nick Treleaven via Digitalmars-d-learn
Hi, Walter's made a fix for arr[$..$].ptr being unsafe to dereference - .ptr will be @system: https://github.com/dlang/dmd/pull/5860 A referenced druntime pull mentioned having a safe wrapper for .ptr that allows comparison of the pointer value, but does not allow dereference. The wrapper

Re: Accessing COM Objects P3

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
[in] long index, [out] long* value); [id(0x60020017)] HRESULT PutClass([in] long value); [id(0x60020018)] HRESULT GetGlobalClass( [in] long index, [out] long* value);

Re: Accessing COM Objects

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 06:09:33 UTC, thedeemon wrote: On Monday, 13 June 2016 at 17:38:41 UTC, Incognito wrote: Cool. Oleview gives me the idl files. How to convert the idl files to d or possibly c? There are ready tools idl2d: https://github.com/dlang/visuald/tree/master/c2d and

Re: Accessing COM Objects

2016-06-15 Thread John via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 08:21:06 UTC, John wrote: OK, adding the return type to the signature should fix that. So: private static Parameter getParameters(MethodImpl method) Sorry, I meant the getParameter methods should return be: private static Parameter[] getParameters(MethodImpl

Re: Strange Issues regarding aliases

2016-06-15 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 17:37:40 UTC, Joerg Joergonson wrote: On Tuesday, 14 June 2016 at 17:34:42 UTC, Joerg Joergonson wrote: This is how derelict does it, I simply moved them in to the class for simplicity. I mean glad: http://glad.dav1d.de/ It seems that a loader is required for

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 07:45:12 UTC, Andrea Fontana wrote: On Wednesday, 15 June 2016 at 07:24:23 UTC, data pulverizer wrote: On Wednesday, 15 June 2016 at 03:17:39 UTC, Seb wrote: On Wednesday, 15 June 2016 at 03:11:23 UTC, data pulverizer wrote: in that case: import std.array :

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 03:17:39 UTC, Seb wrote: On Wednesday, 15 June 2016 at 03:11:23 UTC, data pulverizer wrote: in that case: import std.array : array; int[] x = slice.byElement.array; Are you sure you want to create a _copy_ of your data? In most cases you don't need that ;-)

Re: Accessing COM Objects

2016-06-15 Thread thedeemon via Digitalmars-d-learn
On Monday, 13 June 2016 at 17:38:41 UTC, Incognito wrote: Cool. Oleview gives me the idl files. How to convert the idl files to d or possibly c? There are ready tools idl2d: https://github.com/dlang/visuald/tree/master/c2d and tlb2idl: https://github.com/dlang/visuald/tree/master/tools I've

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 07:24:23 UTC, data pulverizer wrote: On Wednesday, 15 June 2016 at 03:17:39 UTC, Seb wrote: On Wednesday, 15 June 2016 at 03:11:23 UTC, data pulverizer wrote: in that case: import std.array : array; int[] x = slice.byElement.array; Are you sure you want to

Re: Accessing COM Objects

2016-06-15 Thread John via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 06:56:59 UTC, Joerg Joergonson wrote: When I try to compile your code I get the following errors: main.d(953): Error: function core.sys.windows.objbase.CoTaskMemAlloc (uint) is not callable using argument types (immutable(ulong)) main.d(970): Error: can only

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread Seb via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 11:19:20 UTC, data pulverizer wrote: On Wednesday, 15 June 2016 at 09:32:21 UTC, Andrea Fontana wrote: Then I think the slice.byElement.array is the right solution. The problem with that is that it slows down the code. I compared matrix multiplication between R

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 09:32:21 UTC, Andrea Fontana wrote: Then I think the slice.byElement.array is the right solution. The problem with that is that it slows down the code. I compared matrix multiplication between R and D's cblas adaptor and ndslice. n = 4000 Matrices: A, B Sizes:

Re: Accessing COM Objects

2016-06-15 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 07:01:30 UTC, Joerg Joergonson wrote: It seems idl2d from VD is not easily compilable? I don't remember problems with that, anyway here's the binary I used: http://stuff.thedeemon.com/idl2d.exe

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread data pulverizer via Digitalmars-d-learn
Oh, I didn't see that runif now returns a tuple.

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread Seb via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 13:13:05 UTC, data pulverizer wrote: On Wednesday, 15 June 2016 at 12:10:32 UTC, Seb wrote: As said you can avoid the copy (see below). I also profiled it a bit and it was interesting to see that 50% of the runtime are spent on generating the random matrix. On my

Re: Accessing COM Objects

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 16:03:04 UTC, Jesse Phillips wrote: On Monday, 13 June 2016 at 01:22:33 UTC, Incognito wrote: [...] There is also: https://github.com/JesseKPhillips/Juno-Windows-Class-Library It kind of provides similar highlevel options as the "Modern COM Programming in D."

Re: Accessing COM Objects

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 08:24:41 UTC, John wrote: On Wednesday, 15 June 2016 at 08:21:06 UTC, John wrote: OK, adding the return type to the signature should fix that. So: private static Parameter getParameters(MethodImpl method) Sorry, I meant the getParameter methods should return

Re: Accessing COM Objects

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 15:12:06 UTC, thedeemon wrote: On Wednesday, 15 June 2016 at 07:01:30 UTC, Joerg Joergonson wrote: It seems idl2d from VD is not easily compilable? I don't remember problems with that, anyway here's the binary I used: http://stuff.thedeemon.com/idl2d.exe

Re: Accessing COM Objects

2016-06-15 Thread John via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 16:45:39 UTC, Joerg Joergonson wrote: Thanks. When I ran it I got a d file! when I tried to use that d file I get undefined IID and IDispatch. I imagine these interfaces come from somewhere, probably built in? Any ideas? Add the following after the module name:

Re: arr.ptr, @safe and void*

2016-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/16 6:32 AM, Nick Treleaven wrote: Hi, Walter's made a fix for arr[$..$].ptr being unsafe to dereference - .ptr will be @system: https://github.com/dlang/dmd/pull/5860 A referenced druntime pull mentioned having a safe wrapper for ..ptr that allows comparison of the pointer value, but

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread TheDGuy via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 13:15:56 UTC, Rene Zwanenburg wrote: I'm not familiar with Coedit, but the run options seem to contain a field for setting it: https://github.com/BBasile/Coedit/wiki#run-options You may be able to use the symbolic strings there:

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread data pulverizer via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 12:10:32 UTC, Seb wrote: As said you can avoid the copy (see below). I also profiled it a bit and it was interesting to see that 50% of the runtime are spent on generating the random matrix. On my machine now both scripts take 1.5s when compiled with I didn't

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 10:31:18 UTC, TheDGuy wrote: Thanks a lot for your answer, getcwd() returns the path where coedit is located on my harddrive: C:\Program Files (x86)\Coedit_32\coedit.2update6.win32 How can i change that? I'm not familiar with Coedit, but the run options seem to

Re: Accessing COM Objects

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 17:20:31 UTC, John wrote: On Wednesday, 15 June 2016 at 16:45:39 UTC, Joerg Joergonson wrote: Thanks. When I ran it I got a d file! when I tried to use that d file I get undefined IID and IDispatch. I imagine these interfaces come from somewhere, probably built

Re: Accessing COM Objects

2016-06-15 Thread John via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 18:35:42 UTC, Joerg Joergonson wrote: On Wednesday, 15 June 2016 at 06:09:33 UTC, thedeemon wrote: On Monday, 13 June 2016 at 17:38:41 UTC, Incognito wrote: [...] There are ready tools idl2d: https://github.com/dlang/visuald/tree/master/c2d [...] I can't

Re: Accessing COM Objects

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 06:09:33 UTC, thedeemon wrote: On Monday, 13 June 2016 at 17:38:41 UTC, Incognito wrote: [...] There are ready tools idl2d: https://github.com/dlang/visuald/tree/master/c2d [...] I can't seem to get ComPtr to work. auto ps =

Re: Accessing COM Objects

2016-06-15 Thread John via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 18:32:28 UTC, Joerg Joergonson wrote: import core.sys.windows.com, core.sys.windows.oaidl; Thanks. Should these not be added to the generated file? The problem is that other type libraries will probably require other headers to be imported, and there's no way

Re: arr.ptr, @safe and void*

2016-06-15 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 17:35:49 UTC, Steven Schveighoffer wrote: On 6/15/16 6:32 AM, Nick Treleaven wrote: My question is: would returning void* instead really be unsafe, i.e. is there a way of dereferencing it in safe code? (I'm not thinking about holes in @safe, but ways by

Re: ndslice: convert a sliced object to T[]

2016-06-15 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 14:14:23 UTC, Seb wrote: ``` T[] a = slice.ptr[0.. slice.elementsCount]; ``` This would work only for slices with continuous memory representation and positive strides. -- Ilya

Re: Accessing COM Objects

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 19:21:51 UTC, John wrote: On Wednesday, 15 June 2016 at 18:32:28 UTC, Joerg Joergonson wrote: import core.sys.windows.com, core.sys.windows.oaidl; Thanks. Should these not be added to the generated file? The problem is that other type libraries will probably

Re: get number of columns and rows in an ndarray.

2016-06-15 Thread Seb via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 21:51:25 UTC, learner wrote: Hi, How can i get the number of cols and rows in and ndarray that has already been created? learner how about `shape`? http://dlang.org/phobos/std_experimental_ndslice_slice.html#.Slice.shape

get number of columns and rows in an ndarray.

2016-06-15 Thread learner via Digitalmars-d-learn
Hi, How can i get the number of cols and rows in and ndarray that has already been created? learner

Re: GTKD - overrideBackgroundColor of Button doesn't work

2016-06-15 Thread Gerald via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 09:03:45 UTC, TheDGuy wrote: Hello, why does this code not work? RGBA rgb = new RGBA(1,0.5,0.5,1.0); Button btn_1 = new Button("Start"); btn_1.overrideBackgroundColor(StateFlags.NORMAL, rgb); The color of btn_1 just doesn't change.

Re: Passing anonymous templated functions as template parameters

2016-06-15 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 23:52:56 UTC, Basile B. wrote: On Wednesday, 15 June 2016 at 22:27:38 UTC, pineapple wrote: Here's a simple code example to illustrate what I expected to work and didn't - is this a mistake in my syntax or a limitation of the language? template

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 23:41:51 UTC, Basile B. wrote: On Wednesday, 15 June 2016 at 17:35:32 UTC, TheDGuy wrote: I'm gonna check on Windows today but in the meantime you can try I've checked on windows and here is what I can say about the problem. - Symbolic strings won't work on

Out of order execution

2016-06-15 Thread Joerg Joergonson via Digitalmars-d-learn
Suppose I have a loop where I execute two functions: for(...) { if (x) Do1(x); if (y) Do2(y); } The problem is, I really always want to execute all the Do2's first then the Do1's. As is, we could get any order of calls. Suppose I can't run the loop twice for performance reasons(there

Re: GTKD - overrideBackgroundColor of Button doesn't work

2016-06-15 Thread captaindet via Digitalmars-d-learn
string cssPath = "test.css"; CssProvider provider = new CssProvider(); provider.loadFromPath(cssPath); unfortunately i don't know anything about yr specific problem. but i just wanted to mention (in case you are not aware of it) that the CSS can be embedded into

Passing anonymous templated functions as template parameters

2016-06-15 Thread pineapple via Digitalmars-d-learn
Here's a simple code example to illustrate what I expected to work and didn't - is this a mistake in my syntax or a limitation of the language? template SomeTemplate(alias func){ auto templatefunc(T)(int x){ return func!T(x); } } // Valid auto

Re: get number of columns and rows in an ndarray.

2016-06-15 Thread learner via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 21:54:22 UTC, Seb wrote: On Wednesday, 15 June 2016 at 21:51:25 UTC, learner wrote: Hi, How can i get the number of cols and rows in and ndarray that has already been created? learner how about `shape`?

Re: arr.ptr, @safe and void*

2016-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/16 4:08 PM, Nick Treleaven wrote: On Wednesday, 15 June 2016 at 17:35:49 UTC, Steven Schveighoffer wrote: On 6/15/16 6:32 AM, Nick Treleaven wrote: My question is: would returning void* instead really be unsafe, i.e. is there a way of dereferencing it in safe code? (I'm not thinking

Re: GTKD - overrideBackgroundColor of Button doesn't work

2016-06-15 Thread TheDGuy via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 20:49:02 UTC, Gerald wrote: On Wednesday, 15 June 2016 at 09:03:45 UTC, TheDGuy wrote: Hello, why does this code not work? RGBA rgb = new RGBA(1,0.5,0.5,1.0); Button btn_1 = new Button("Start");

Re: GTKD - overrideBackgroundColor of Button doesn't work

2016-06-15 Thread Gerald via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 21:39:37 UTC, TheDGuy wrote: On Wednesday, 15 June 2016 at 20:49:02 UTC, Gerald wrote: On Wednesday, 15 June 2016 at 09:03:45 UTC, TheDGuy wrote: Hello, why does this code not work? RGBA rgb = new RGBA(1,0.5,0.5,1.0); Button btn_1 = new

Re: Passing anonymous templated functions as template parameters

2016-06-15 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 22:27:38 UTC, pineapple wrote: Here's a simple code example to illustrate what I expected to work and didn't - is this a mistake in my syntax or a limitation of the language? template SomeTemplate(alias func){ auto templatefunc(T)(int x){

Re: GTKD - Application crashes - or not? [Coedit]

2016-06-15 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 15 June 2016 at 17:35:32 UTC, TheDGuy wrote: On Wednesday, 15 June 2016 at 13:15:56 UTC, Rene Zwanenburg wrote: I'm not familiar with Coedit, but the run options seem to contain a field for setting it: https://github.com/BBasile/Coedit/wiki#run-options You may be able to use the

Re: Passing anonymous templated functions as template parameters

2016-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/16 7:52 PM, Basile B. wrote: On Wednesday, 15 June 2016 at 22:27:38 UTC, pineapple wrote: Here's a simple code example to illustrate what I expected to work and didn't - is this a mistake in my syntax or a limitation of the language? template SomeTemplate(alias func){ auto

Why don't we write configuration files in D instead of JSON?

2016-06-15 Thread Guido via Digitalmars-d-learn
It would seem that by running the file through mixin, you can simply create the vars you want in scope. The drawback being random code execution. Is there any way to sanitize mixin code from user-configurable file? Once that's shot down, does anyone know a .json to .sdl converter program