Re: Placement of shared does not allow to set a delegate

2014-06-19 Thread Tolga Cakiroglu via Digitalmars-d-learn
Yes the understanding is correct. I simplified the code a little: IMPORTANT: DMD 2.065 is used. class Car{ void delegate() onEvent; } class Test{ this() shared { auto car = new shared Car(); assert( typeid( car.onEvent ).toString() == shared(void

Placement of shared does not allow to set a delegate

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
In a class I defined an event attribute as follows: public void delegate( shared(SocketListener) sender ) eventWhenStarted; --- An instance of SocketListener is created. auto listener = new shared SocketListener(); --- I defined a shared method that will be called when the event occurs.

Re: Placement of shared does not allow to set a delegate

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
Thanks Ali. That has solved the problem. Actually I tried to use that `shared` as follows before: public shared void delegate( shared(BasicSocketListener) sender ) eventWhenStarted; Though it didn't work with that. When it is put before the attribute name, it works now. It is just confusing

Re: Doing exercise from book, but I'm getting error with splitter

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
Add import std.algorithm. Splitter is defined there. http://dlang.org/phobos/std_algorithm.html#splitter On Monday, 16 June 2014 at 16:38:15 UTC, Sanios wrote: Hello guys, as first I don't know, if I'm writing to correct section, but I've got a problem. I'm actually reading book of D guide and

Re: Placement of shared does not allow to set a delegate

2014-06-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
On Monday, 16 June 2014 at 15:25:51 UTC, Ali Çehreli wrote: Here is a minimal example that reproduces the issue and the hint that compiles the code: class SocketListener { public void delegate( shared(SocketListener) sender ) /* shared */// -- UNCOMMENT TO COMPILE

Re: Objects(from classes) at Compile time? no gc

2014-05-16 Thread Tolga Cakiroglu via Digitalmars-d-learn
On Friday, 16 May 2014 at 04:59:46 UTC, Taylor Hillegeist wrote: The subject says it all really. i have this example: import core.memory; class fruit{ int value=5; public int getvalue(){ return value; } } int main(string[] args) { GC.disable; static fruit myfruit; return

Re: Reading ELF Files

2014-05-01 Thread Tolga Cakiroglu via Digitalmars-d-learn
On Thursday, 1 May 2014 at 11:38:50 UTC, Nordlöw wrote: Have anybody put together some D code for reading out tables from ELF files? A range/slice based version would be nice. I don't know this though, in the morning Ubuntu has showed updates. One of them was libelf which says in its

Re: async socket programming in D?

2014-04-20 Thread Tolga Cakiroglu via Digitalmars-d-learn
On Sunday, 20 April 2014 at 22:44:28 UTC, Bauss wrote: I know the socket has the nonblocking settings, but how would I actually go around using it in D? Is there a specific procedure for it to work correctly etc. I've taken a look at splat.d but it seems to be very outdated, so that's why I

Re: How to set JSON_TYPE in 2.0.65

2014-03-31 Thread Tolga Cakiroglu
I believe for this case you would want this: JSONValue oJson = [ myEntry: MyText ]; Yeah, and unfortunately, there is no that easy way to create an empty object type json value though. (Yes, I had a need for that). I needed to work around of that.

Re: Linux Dynamic Loading of shared libraries

2014-03-09 Thread Tolga Cakiroglu
Now suppose that my D shared library contains a class, rather that just module ctors/dtors, how do I go about creating an instance of that class and using its methods? Steve For this, you create an Interface that matches to the method declaration of your class. But notice that instead of

Re: Is it possible to elegantly craft a class that can be used as shared and as normal?

2014-03-03 Thread Tolga Cakiroglu
Have you got a small example? import std.stdio; class Test{ private int number; public void setNumber( int newValue ) shared{ number = newValue; } public int getNumber() shared{ return number; } } void main(){ auto test = new Test();

Re: Is it possible to elegantly craft a class that can be used as shared and as normal?

2014-03-02 Thread Tolga Cakiroglu
On Sunday, 2 March 2014 at 20:16:42 UTC, Gary Willoughby wrote: On Sunday, 2 March 2014 at 18:04:06 UTC, Dicebot wrote: shared and non-shared entities have different implementation. You unlikely want to have one for both. It's part of my unit-testing toolkit that handles mocking of objects.

Re: undefined symbol: rt_finalize

2014-02-28 Thread Tolga Cakiroglu
http://dlang.org/dll-linux.html#dso7 dmd lib.d -shared -fPIC -debug -gc -g -w -wi -defaultlib=libphobos2.so Problem about using shared libphobos is that I need to install many different libraries on the target computer. On the web server, I don't want to install DMD. I compiled before a

Re: Dynamically calling external libraries.

2014-02-28 Thread Tolga Cakiroglu
On Friday, 28 February 2014 at 17:29:09 UTC, Setra wrote: I am using dmd_2.065.0-0_i386.deb on a 32 bit machine. Hi Setra, I am trying to make external libraries work as well, but having problems continuously. Could you test that following function in your library and call it from main

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
because there is no finalize. rt_init/rt_term is what you need https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L30 I looked at the `/usr/include/dmd/druntime` folder with `grep finalize -r`, and it brought me only one file, that is `object.di`. When I

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
On Friday, 28 February 2014 at 06:02:30 UTC, Mike wrote: On Friday, 28 February 2014 at 05:59:23 UTC, Mike wrote: On Friday, 28 February 2014 at 05:46:03 UTC, evilrat wrote: that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. I

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. Nope. No chance. I have removed all imports. All `destroy`s are replaced with `clean`, and still same. I have deleted all executables and compiled again and again. ./app:

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that.

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
rt_finalize is defined in lifetime.d (https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d). Its part of the D runtime. It just forwards to rt_finalize2. I don't know why you are getting an undefined symbol, though. Is the signature different? I made some

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that. Even Walter Bright's code doesn't use export, and goes with extern only. http://dlang.org/dll-linux.html#dso10

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
On Friday, 28 February 2014 at 06:40:27 UTC, evilrat wrote: On Friday, 28 February 2014 at 06:36:02 UTC, Tolga Cakiroglu wrote: On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing

Re: Allocating and freeing memory like this?

2014-02-26 Thread Tolga Cakiroglu
I can't remember where I read it though, in documentation probably, the `free` function calls the `delete` function as well, and it can be used to remove object from memory. Since there is garbage collector in the background already, you don't have to do it in this way (and I am not doing as

Re: Allocating and freeing memory like this?

2014-02-26 Thread Tolga Cakiroglu
2014 at 09:19:55 UTC, Tolga Cakiroglu wrote: I can't remember where I read it though, in documentation probably, the `free` function calls the `delete` function as well, and it can be used to remove object from memory. Since there is garbage collector in the background already, you don't have

undefined symbol: rt_finalize

2014-02-26 Thread Tolga Cakiroglu
I am trying to compile a shared library on Linux and use it. lib.d --- import core.runtime; class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[] c = new char[ 1024 ]; destroy( objA ); destroy( c

Unused mmap library comes as deprecation warning on compile

2014-02-24 Thread Tolga Cakiroglu
I have about 12 different separate programmes. While compiling only one of them, it gives as warning as below: /usr/include/dmd/phobos/std/mmfile.d(344): Deprecation: alias core.sys.posix.sys.mman.MAP_ANON is deprecated - Please use core.sys.linux.sys.mman for non-POSIX extensions I used

Why does object creation give segmentation fault in DLL?

2014-02-22 Thread Tolga Cakiroglu
I have written a DLL file in Linux (x86_64). It is as below: File: lib.dll = class A{} extern(C) void foo(){ Object obj = new Object(); // test 1 A objA = new A(); // test 2 char[] c = new char[ 1024 ]; // test 3 } Compilation code is below:

Re: Why does object creation give segmentation fault in DLL?

2014-02-22 Thread Tolga Cakiroglu
On Saturday, 22 February 2014 at 11:08:41 UTC, evilrat wrote: On Saturday, 22 February 2014 at 09:09:42 UTC, Tolga Cakiroglu wrote: I have written a DLL file in Linux (x86_64). It is as below: File: lib.dll = class A{} extern(C) void foo(){ Object obj = new Object

Dynamic library loading gives error about importing a module

2014-02-19 Thread Tolga Cakiroglu
I have written a programme and a library under Linux. When programme is run, it tries to load the library. Both the programme code and the library imports a module as apps.common.lib.config. Now, when I run the programme, following error is seen: Fatal Error while loading 'dll/lib.so': The

Re: Dynamic library loading gives error about importing a module

2014-02-19 Thread Tolga Cakiroglu
Simply importing should work; doing that should not bring definitions to the code. However, one side should also include the module during its build. Have you included the module on both the program's and library's builds? Ali Hi Ali, Both of them have normal import for that module. I

Importing text file, path not found

2014-02-18 Thread Tolga Cakiroglu (tcak)
I am testing with the import expression. I am using the -J flag while compiling. dmd app.d -J/home/user/include void main(){ auto test = json.parseJSON( import(/home/user/include/test.json) ); } 1. Because I am giving the full path of that file to be imported. But compiler is

Re: Importing text file, path not found

2014-02-18 Thread Tolga Cakiroglu (tcak)
On Tuesday, 18 February 2014 at 08:45:16 UTC, Tolga Cakiroglu (tcak) wrote: I am testing with the import expression. I am using the -J flag while compiling. dmd app.d -J/home/user/include void main(){ auto test = json.parseJSON( import(/home/user/include/test.json) ); } 1. Because I am

Interface file is generated wrong

2014-02-18 Thread Tolga Cakiroglu (tcak)
I have written a module as below: file: lib.d import core.sys.posix.dlfcn; private static this(){} private static ~this(){} public shared class Apps{ } --- This code is compiled with -H flag to generate an interface file. Generated interface file is below: file: lib.di // D import

Re: Importing text file, path not found

2014-02-18 Thread Tolga Cakiroglu
On Tuesday, 18 February 2014 at 09:24:50 UTC, Dicebot wrote: On Tuesday, 18 February 2014 at 08:45:16 UTC, Tolga Cakiroglu (tcak) wrote: 1. Because I am giving the full path of that file to be imported. But compiler is complaining about that it cannot find the file. If I remove the path

Re: Interface file is generated wrong

2014-02-18 Thread Tolga Cakiroglu
On Tuesday, 18 February 2014 at 10:15:51 UTC, Stanislav Blinov wrote: On Tuesday, 18 February 2014 at 10:07:37 UTC, Tolga Cakiroglu (tcak) wrote: Bug? Yup. (I don't know if I should immediately file a bug when I think it is a bug without asking what other people thinks.) 1) Do a seach

Re: Interface file is generated wrong

2014-02-18 Thread Tolga Cakiroglu
On Tuesday, 18 February 2014 at 15:02:38 UTC, Steven Schveighoffer wrote: On Tue, 18 Feb 2014 05:47:41 -0500, Tolga Cakiroglu t...@pcak.com wrote: On Tuesday, 18 February 2014 at 10:15:51 UTC, Stanislav Blinov wrote: On Tuesday, 18 February 2014 at 10:07:37 UTC, Tolga Cakiroglu (tcak) wrote