Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
August 12, 2012 [Issue 8544] New: Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8544 Summary: Expose "cArgs" in druntime Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-08-12 14:22:34 PDT --- When interfacing with C/C++ libraries one common problem is having to extract argc/argv arguments from D main() and passing them back to library functions. A common solution is: // Array of pointers to command line parameters. char*[] argv = args.map!((a)=>(a.dup~'\0').ptr).array; But it would be much simpler (and more efficient) if argc & argv were stored somewhere in druntime. There's a Runtime.args() function in core.runtime which exports the runtime args as a D-friendly array, so we could provide a cArgs equivalent which returns a struct with argc/argv. druntime/src/rt/dmain2.d is where main is called from: extern (C) int main(int argc, char** argv) { ... } From there we could easily store argc+argv into a global struct variable, similar to how _d_args is exposed as a __gshared string[]. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 12, 2012 [Issue 8544] Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8544 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 02, 2012 [Issue 8544] Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8544 --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-02 16:53:34 PDT --- I'd like to fix this myself. But I'm not sure how this should be exposed in the Runtime struct. Should it be two properties, 'argc' and 'argv', or a single property such as the following, in core.runtime: extern (C) CArgs rt_cArgs(); static @property string[] cArgs() { return rt_cArgs(); } and in src\rt\dmain2.d: struct CArgs { int argc char** argv; } __gshared CArgs _cArgs = null; extern (C) string[] rt_cArgs() { return _cArgs; } extern (C) int main(int argc, char** argv) { _cArgs.argc = argc; _cArgs.argv = argv; ... } Thoughts? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 02, 2012 [Issue 8544] Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8544 --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-02 16:54:34 PDT --- (In reply to comment #1) > I'd like to fix this myself. But I'm not sure how this should be exposed in the Runtime struct. Should it be two properties, 'argc' and 'argv', or a single property such as the following, in core.runtime: > > extern (C) CArgs rt_cArgs(); > > static @property string[] cArgs() > { > return rt_cArgs(); > } That should be: > static @property CArgs cArgs() and > extern (C) CArgs rt_cArgs() Obviously I'm just pseudocoding. :) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 03, 2012 [Issue 8544] Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8544 Alex Rønne Petersen <alex@lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alex@lycus.org --- Comment #3 from Alex Rønne Petersen <alex@lycus.org> 2012-10-03 02:00:47 CEST --- I suppose it wouldn't be a problem to have a cArgs property on the Runtime struct. I'd prefer returning a struct over two separate properties. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2012 [Issue 8544] Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8544 --- Comment #4 from github-bugzilla@puremagic.com 2012-10-23 13:56:59 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/2e73c0fd3139af781f3afe926c4485b20f88a16d Fixes Issue 8544 - Expose cArgs in Druntime struct for easier interfacing with C libraries. https://github.com/D-Programming-Language/druntime/commit/84beb97864444e11b419cfa5eb4792d7fbdc8e1a Merge pull request #336 from AndrejMitrovic/Fix8544 Fix Issue 8544 - Expose cArgs in Druntime struct for C interfacing -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2012 [Issue 8544] Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8544 Alex Rønne Petersen <alex@lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 27, 2012 [Issue 8544] Expose "cArgs" in druntime | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=8544 --- Comment #5 from github-bugzilla@puremagic.com 2012-10-27 08:22:06 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/14cdab6fc079b2d99e159e7a7e85e80f87251bf8 Add test for druntime Issue 8544 https://github.com/D-Programming-Language/dmd/commit/e19b894ca972b559137708258744ea781935c1cb Merge pull request #1211 from AndrejMitrovic/Fix8544 Add test for druntime Issue 8544 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation