digitalmars.D.learn - Create object from a library's Class returns Null
- dangbinghoo (41/41) May 28 2019 hi there,
- Nick Treleaven (2/8) May 28 2019 Does this class have a non-default constructor?
- dangbinghoo (7/16) May 28 2019 yes, I didn't provide constructor, as Class will have a default
- dangbinghoo (13/20) May 28 2019 hi there,
- Nick Treleaven (2/3) May 28 2019 Typo, should be NSconf.
- Adam D. Ruppe (3/3) May 28 2019 Object.factory is pretty unreliable and has few supporters among
- dangbinghoo (3/6) May 28 2019 oh, that's bad news, but the hibernated library is using this
- dangbinghoo (3/9) May 28 2019 now we found that, class from a module library won't work, if I
- dangbinghoo (2/2) May 29 2019 change gwlib buildtype to sourceLibrary solves the problem, but
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
May 28 2019
On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote:class NSconf { String name; ... }Does this class have a non-default constructor?
May 28 2019
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:yes, I didn't provide constructor, as Class will have a default one if not supplied.class NSconf { String name; ... }Does this class have a non-default constructor?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.
May 28 2019
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: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 dangOn 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.
May 28 2019
On Tuesday, 28 May 2019 at 09:25:51 UTC, dangbinghoo wrote:writeln(Object.factory("gwlib.entity.nsconf.NSConf"));Typo, should be NSconf.
May 28 2019
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.
May 28 2019
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?
May 28 2019
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:now we found that, class from a module library won't work, if I move gwlib to testobj/source, it works.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?
May 28 2019
change gwlib buildtype to sourceLibrary solves the problem, but it should work for static or shared library.
May 29 2019