Re: Create object from a library's Class returns Null

2019-05-29 Thread dangbinghoo via Digitalmars-d-learn



change gwlib buildtype to sourceLibrary solves the problem, but 
it should work for static or shared library.


Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn

On Wednesday, 29 May 2019 at 05:04:54 UTC, dangbinghoo wrote:

On Wednesday, 29 May 2019 at 02:42:23 UTC, Adam D. Ruppe wrote:
Object.factory is pretty unreliable and has few supporters 
among the developers. I wouldn't suggest relying on it and 
instead building your own factory functions.


oh, that's bad news, but the hibernated library is using this 
feature. what should I do with this?


now we found that, class from a module library won't work, if I 
move gwlib to testobj/source, it works.


Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn

On Wednesday, 29 May 2019 at 02:42:23 UTC, Adam D. Ruppe wrote:
Object.factory is pretty unreliable and has few supporters 
among the developers. I wouldn't suggest relying on it and 
instead building your own factory functions.


oh, that's bad news, but the hibernated library is using this 
feature. what should I do with this?


Re: Create object from a library's Class returns Null

2019-05-28 Thread Adam D. Ruppe via Digitalmars-d-learn
Object.factory is pretty unreliable and has few supporters among 
the developers. I wouldn't suggest relying on it and instead 
building your own factory functions.


Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn

On Tuesday, 28 May 2019 at 14:24:30 UTC, dangbinghoo wrote:

On Tuesday, 28 May 2019 at 14:16:44 UTC, Nick Treleaven wrote:

On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote:




yeah, I made a typo mistake in the forum post, but the code in 
github repo is really with no typo problem.


This seems to be a serious problem, I found it works when I 
using Ldc2 1.12 version even on ARM target.


hi there,

Anyone help with this?

Not a typo problem, even this
---
writeln(Object.factory(ns.toString()));
---

result in `null`.

just try the github demo project:

https://github.com/dangbinghoo/DObjectCreatTest.git



Thanks!
---
binghoo dang


Re: Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn

On Tuesday, 28 May 2019 at 14:16:44 UTC, Nick Treleaven wrote:

On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote:


class NSconf
{
String name;
...
}


Does this class have a non-default constructor?


yes, I didn't provide constructor, as Class will have a default 
one if not supplied.



Typo, should be NSconf.


yeah, I made a typo mistake in the forum post, but the code in 
github repo is really with no typo problem.


This seems to be a serious problem, I found it works when I using 
Ldc2 1.12 version even on ARM target.





Re: Create object from a library's Class returns Null

2019-05-28 Thread Nick Treleaven via Digitalmars-d-learn

On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote:


class NSconf
{
String name;
...
}


Does this class have a non-default constructor?


Re: Create object from a library's Class returns Null

2019-05-28 Thread Nick Treleaven via Digitalmars-d-learn

On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote:

writeln(Object.factory("gwlib.entity.nsconf.NSConf"));


Typo, should be NSconf.


Create object from a library's Class returns Null

2019-05-28 Thread dangbinghoo via Digitalmars-d-learn

hi there,

I have a set of DB entity class in a library and creating Object 
from another project which linked with the library returns Null.


I don't know what's wrong there.

the source is like this:

  a. I have a library with such a structure:
 gwlib/source/gwlib/entity/nsconf.d

with content:

   --
module gwlib.entity.nsconf;

class NSconf
{
String name;
...
}
   --

  b. I use this gwlib library in another project named testobj

 testobj/source/app.d :

--
 import gwlib.entity.nsconf;

 void main()
 {
  writeln(Object.factory("gwlib.entity.nsconf.NSConf"));
 }
--

 this print out `null`.

dub file cofig is :
-
"dependencies": {
"gwlib": {"path":"../gwlib"}
},
-

And I just tested with DMD and LDC2, the result is a little 
different, but all the two is returning a null object.


I don't know what's the reason.


Could someone help with this? Thanks!

  > I posted the dub version of the whole project on github:
https://github.com/dangbinghoo/DObjectCreatTest
one can just clone and reproduce the result.


---
binghoo dang