Re: dmdtags 1.0.0: an accurate tag generator for D source code
On Friday, 27 August 2021 at 21:38:58 UTC, Paul Backus wrote: `dmdtags` is a tags file generator for D source code that uses the DMD compiler frontend for accurate parsing. This release supports 100%-accurate parsing of arbitrary D code (tested on DMD and Phobos sources), as well as the most commonly-used command line options, `-R`, `-o`, and `-a`. The generated tags file has been tested for compatibility with Vim and is compliant with the [POSIX standard for `ctags`][posix], so any editor with `ctags` support should be able to use it. [posix]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ctags.html ### What? A _tags file_ is a lightweight plain-text index of the symbols in a project. Editors that support tags files, such as Vim and Emacs, can use this index to help with things like project navigation and tab completion. A _tags file generator_ is, as you might expect, a program that reads source code and generates a tags file with entries for the symbols in that code. ### Why? [`universal-ctags`][uctags], the current most-popular and best-maintained tags file generator, claims support for many programming languages, including D. However, its D parser is not well-maintained, and it often excludes large numbers of symbols from its output due to parsing failures. Because `dmdtags` uses the DMD frontend for parsing, its results will always be accurate and up-to-date. For pure D projects, it can be used as a replacement for `universal-ctags`. For mixed-language projects, it can be used together with other tag generators with the `--append` option. [uctags]: https://ctags.io ### Where? * On Github: https://github.com/pbackus/dmdtags * On Dub: https://code.dlang.org/packages/dmdtags ``` # dmdtags -R ./source/ -o - !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ App ./source/ui/app.d 13;" T App ./source/ui/app.d 15;" a App ./source/ui/app.d 19;" T App ./source/ui/app.d 21;" s __ctor ./source/ui/app.d 27;" f __ctor ./source/ui/app.d 30;" f _result ./source/ui/app.d 23;" v app ./source/ui/app.d 1;"M defaultEventLoop./source/ui/app.d 48;" f defaultInitFunc ./source/ui/app.d 62;" T defaultInitFunc ./source/ui/app.d 62;" f window ./source/ui/app.d 26;" v ``` Perfecto! i can use it in Sublime Text editor... Need to thinks, how it will be implemented...
Re: From the D Blog -- Interfacing D with C: Strings Part One
On Thursday, 27 May 2021 at 03:52:32 UTC, Виталий Фадеев wrote: On Thursday, 27 May 2021 at 03:40:02 UTC, Виталий Фадеев wrote: On Wednesday, 26 May 2021 at 16:35:36 UTC, Ali Çehreli wrote: On 5/25/21 9:00 PM, Виталий Фадеев wrote: // cString[ $-1 ] != '\'0'; // cString[ $ ] != '\'0';
Re: From the D Blog -- Interfacing D with C: Strings Part One
On Thursday, 27 May 2021 at 03:40:02 UTC, Виталий Фадеев wrote: On Wednesday, 26 May 2021 at 16:35:36 UTC, Ali Çehreli wrote: On 5/25/21 9:00 PM, Виталий Фадеев wrote: > immutable(char)* toStringz( ref string s ) > { > if ( s.capacity <= s.length ) > s.reserve( s.length + 1 ); > > char* cptr = cast( char* ) s.ptr; // C ptr > char* zptr = cptr + s.length; // zero ptr > *zptr = '\0'; That's undefined behavior because that location does not belong to the string. Here is an example that defeats the proposed toStringz: void main() { string s; s = "D string"; auto c_string = toStringz( s ); auto other = s; other ~= 'X';// <-- Seemingly unrelated operation // ... } puts accesses that unrelated 'X' and more bytes after that: C string: D stringX1^ Ali Yes. True. reserve/capacity - not for all cases. Zero terminator not keeped after concatenate source string with other string. auto dString = "D string" ~ 2.to!string; auto cString = dString.toStringz(); dString = dString ~ "new tail"; // cString[ $-1 ] != '\'0';
Re: From the D Blog -- Interfacing D with C: Strings Part One
On Wednesday, 26 May 2021 at 16:35:36 UTC, Ali Çehreli wrote: On 5/25/21 9:00 PM, Виталий Фадеев wrote: > immutable(char)* toStringz( ref string s ) > { > if ( s.capacity <= s.length ) > s.reserve( s.length + 1 ); > > char* cptr = cast( char* ) s.ptr; // C ptr > char* zptr = cptr + s.length; // zero ptr > *zptr = '\0'; That's undefined behavior because that location does not belong to the string. Here is an example that defeats the proposed toStringz: void main() { string s; s = "D string"; auto c_string = toStringz( s ); auto other = s; other ~= 'X';// <-- Seemingly unrelated operation // ... } puts accesses that unrelated 'X' and more bytes after that: C string: D stringX1^ Ali Yes. True. reserve/capacity - not for all cases.
Re: From the D Blog -- Interfacing D with C: Strings Part One
On Wednesday, 26 May 2021 at 04:27:16 UTC, Виталий Фадеев wrote: On Wednesday, 26 May 2021 at 04:00:17 UTC, Виталий Фадеев wrote: On Monday, 24 May 2021 at 14:02:14 UTC, Mike Parker wrote: The blog: https://dlang.org/blog/2021/05/24/interfacing-d-with-c-strings-part-one/ Test code: https://run.dlang.io/is/xZwwtw Example for using reserve. Test code 2: https://run.dlang.io/is/aQsr8n Pull request to std.string: https://github.com/dlang/phobos/pull/8111 Review code, please.
Re: From the D Blog -- Interfacing D with C: Strings Part One
On Wednesday, 26 May 2021 at 04:00:17 UTC, Виталий Фадеев wrote: On Monday, 24 May 2021 at 14:02:14 UTC, Mike Parker wrote: The blog: https://dlang.org/blog/2021/05/24/interfacing-d-with-c-strings-part-one/ Test code: https://run.dlang.io/is/xZwwtw Example for using reserve. Test code 2: https://run.dlang.io/is/aQsr8n
Re: From the D Blog -- Interfacing D with C: Strings Part One
On Monday, 24 May 2021 at 14:02:14 UTC, Mike Parker wrote: The blog: https://dlang.org/blog/2021/05/24/interfacing-d-with-c-strings-part-one/ Good! toStringz() Technically we can use 'reserve()' for reserve memory. Possible, memory already reserved. s.reserve( s.length + 1 ); Then we can set trailing zero. s[ $ ] = '\0'; And return pointer. return s.ptr; In this case we prevent memory allocation. Operations will be faster. In other case we cam: auto copy = new char[s.length + 1]; copy[0 .. s.length] = s[]; copy[s.length] = 0; return &assumeUnique(copy)[0]; Example: immutable(char)* toStringz( ref string s ) { if ( s.capacity <= s.length ) s.reserve( s.length + 1 ); char* cptr = cast( char* ) s.ptr; // C ptr char* zptr = cptr + s.length; // zero ptr *zptr = '\0'; return cast( immutable(char)* ) cptr; } Test code: https://run.dlang.io/is/xZwwtw
Re: turtle v0.0.6
On Wednesday, 19 May 2021 at 16:41:54 UTC, Guillaume Piolat wrote: https://code.dlang.org/packages/turtle "The turtle package provides a friendly, software-rendered, and hi-DPI drawing solution, for when all you want is a Canvas API. It depends on SDL for windowing." [...] dplug:canvas, dplug:graphcis is interesting. fillStyle = gradient; beginPath(); moveTo(-1, -1); lineTo( 0, -3); lineTo(+1, -1); lineTo(+3, 0); lineTo(+1, +1); lineTo( 0, +3); lineTo(-1, +1); lineTo(-3, 0); closePath(); fill(); Looks readable.
Re: Article: Why I use the D programming language for scripting
On Tuesday, 2 February 2021 at 04:24:48 UTC, Виталий Фадеев wrote: On Tuesday, 2 February 2021 at 03:53:43 UTC, Виталий Фадеев wrote: On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote: It's finally out! https://opensource.com/article/21/1/d-scripting If the article is about scripting, then the article will contain examples of scripts used in business. And we see what it not simple as windows .bat Perhaps the best version would be a high-level add-on over rdmd with Dlang syntax. . "main()" and "import std" will be hidden. For example, the final result will look like this: dirEntries( args[0].dirName, SpanMode.shallow ) .filter!( a => a.isDir ) .map!( a => buildPath( a.name, ".dub" ) ) .filter!( a => a.exists ) .each!( ( a ) { writeln( a ); rmdirRecurse( a ); } ); and the file will have the extension ".ds"
Re: Article: Why I use the D programming language for scripting
On Tuesday, 2 February 2021 at 03:53:43 UTC, Виталий Фадеев wrote: On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote: It's finally out! https://opensource.com/article/21/1/d-scripting If the article is about scripting, then the article will contain examples of scripts used in business. For example, to delete all dub caches in a directory: Remove dub cache in subsirectories: module dubcache; // Reason: // each cache take 50 - 200 MB of disk space // Goal: // scan dirs and remove caches // // ./ // a/ // b/ // .dub/ <- target // c/ import std; void main( string[] args ) { dirEntries( args[0].dirName, SpanMode.shallow ) .filter!( a => a.isDir ) .map!( a => buildPath( a.name, ".dub" ) ) .filter!( a => a.exists ) .each!( ( a ) { writeln( a ); rmdirRecurse( a ); } ); } Source: https://run.dlang.io/is/ah1Vtp And we see what it not simple as windows .bat
Re: Article: Why I use the D programming language for scripting
On Sunday, 31 January 2021 at 20:36:43 UTC, aberba wrote: It's finally out! https://opensource.com/article/21/1/d-scripting If the article is about scripting, then the article will contain examples of scripts used in business. For example, to delete all dub caches in a directory: Version via Windows .bat: @echo off FOR /D %%f IN ( .\* ) DO ( IF EXIST .\%%f\.dub ( echo .\%%f\.dub rmdir /q /s .\%%f\.dub ) ) Version via Dlang: module dubcache; import std.file; import std.path; import std.stdio; void main( string[] args ) { foreach( dir; dirEntries( args[0].dirName, SpanMode.shallow ) ) { if ( dir.baseName == ".dub" ) { writeln( "REMOVED: ", dir ); rmdirRecurse( dir.name ); } } } or module dubcache; import std; void main( string[] args ) { dirEntries( args[0].dirName, SpanMode.shallow ) .filter!( a => a.baseName == ".dub" ) .each!( ( a ) { writeln( a ); rmdirRecurse( a ); } ); }
Re: Chimpfella - new library to do benchmarking with ranges (even with templates!)
On Saturday, 19 December 2020 at 08:30:09 UTC, Виталий Фадеев wrote: On Saturday, 19 December 2020 at 05:08:56 UTC, Max Haughton wrote: https://code.dlang.org/packages/chimpfella Haven't finished documenting it yet. [...] ... @wrapper function() ... I like it! and I want some like this for memory: save process memory call func() print memory delta
Re: Chimpfella - new library to do benchmarking with ranges (even with templates!)
On Saturday, 19 December 2020 at 05:08:56 UTC, Max Haughton wrote: https://code.dlang.org/packages/chimpfella Haven't finished documenting it yet. [...] ... @wrapper function() ... I like it!
Re: D GUI Framework (responsive grid teaser)
On Tuesday, 23 June 2020 at 17:41:35 UTC, Robert M. Münch wrote: On 2020-06-23 04:29:48 +, Виталий Фадеев said: [...] Not sure if this is a question or some project you do. However, yes on all points for what we do. [...] Yes. [...] Well, beauty lies in the eye of the beholder. [...] :-) [...] Cool... so, anything to see? Of course, when we are will ready. You, I, and job! )
Re: D GUI Framework (responsive grid teaser)
On Monday, 22 June 2020 at 16:43:12 UTC, Robert M. Münch wrote: On 2019-05-19 21:01:33 +, Robert M. Münch said: Hi, we are currently build up our new technology stack and for this create a 2D GUI framework. Some now teaser, again might not look like a lot had happend but we move forward, slow but steady: https://www.dropbox.com/s/jjefzyneqnxr7pb/dgui_teaser-1.mp4 The framework can now handle 9-patch images for decoration of any widget parts. And here an older one I think I never posted, about text editing: https://www.dropbox.com/s/cfqy21q4s7d0zxr/Bildschirmaufnahme%202020-04-07%20um%2017.08.24.mov?dl=0 Cut & Paste, marking, cursor movement etc. is all working correctly. All text stuff (rendering and handling) is done in Unicode. What we first get to work is a way to create simple applications with input-forms, text-lists feed from a database and single line text-editing. Width of the element can be set: - by hand --- fixed - by automate --- inherited from parent --- from childs ( calculated max width ) --- generated by parent layout ( like a HBox, VBox, may be CircleLayout... ) and for each case: - check min width - check max width https://drive.google.com/file/d/1ZbeSkQD2BY06JB1R17CT17te1H9ecRnI/view?usp=sharing and childs can be aligned in container cell to: left. center, right, stretched. https://drive.google.com/file/d/1Xm4m7DLaUoPu5wzvPSalgW3i1-WkTeek/view?usp=sharing It will be good. I love beauty UI too. :) I love fast perfect UI too. And I do D Windows GUI too. :)
Sublime 3 Color Scheme. A specially for D.
Sublime 3 Color Scheme. A specially for D. Dark colors. Main idea is: focus on important words. Demo: https://github.com/vitalfadeev/MainThings
Sublime 3 plugin DlangAutoModuleName
Plugin will be add "mmodule name;". Module name detected from first "class name" or "interface name" or "struct name". Demo: https://github.com/vitalfadeev/SublimeDlangAutoModuleName
wlanapi.h
I was writed "wlanapi.h". It is WLAN API windows header. I will be happy to see it in public D distributive. What I must to do for it ? What I must to do for add new file to "C:\D\dmd2\src\druntime\src\core\sys\windows\" ? Where to send it ? // cat import core.sys.windows.windows; enum UINT WLAN_MAX_NAME_LENGTH = 256; enum UINT DOT11_SSID_MAX_LENGTH = 32; enum UINT WLAN_MAX_PHY_TYPE_NUMBER = 8; enum UINT WLAN_AVAILABLE_NETWORK_CONNECTED= 1; enum UINT WLAN_AVAILABLE_NETWORK_HAS_PROFILE = 2; struct WLAN_PROFILE_INFO { WCHAR[WLAN_MAX_NAME_LENGTH] strProfileName; DWORD dwFlags; }; alias WLAN_PROFILE_INFO* PWLAN_PROFILE_INFO; struct WLAN_PROFILE_INFO_LIST { DWORD dwNumberOfItems; DWORD dwIndex; WLAN_PROFILE_INFO[1] ProfileInfo; }; alias WLAN_PROFILE_INFO_LIST* PWLAN_PROFILE_INFO_LIST; enum WLAN_INTERFACE_STATE { wlan_interface_state_not_ready = 0, wlan_interface_state_connected, wlan_interface_state_ad_hoc_network_formed, wlan_interface_state_disconnecting, wlan_interface_state_disconnected, wlan_interface_state_associating, wlan_interface_state_discovering, wlan_interface_state_authenticating }; alias WLAN_INTERFACE_STATE* PWLAN_INTERFACE_STATE; struct WLAN_INTERFACE_INFO { GUIDInterfaceGuid; WCHAR[WLAN_MAX_NAME_LENGTH] strInterfaceDescription; WLAN_INTERFACE_STATEisState; }; alias WLAN_INTERFACE_INFO* PWLAN_INTERFACE_INFO; struct WLAN_INTERFACE_INFO_LIST { DWORD dwNumberOfItems; DWORD dwIndex; WLAN_INTERFACE_INFO[1] InterfaceInfo; }; alias WLAN_INTERFACE_INFO_LIST* PWLAN_INTERFACE_INFO_LIST; struct DOT11_SSID { ULONG uSSIDLength; UCHAR[DOT11_SSID_MAX_LENGTH]ucSSID; }; alias DOT11_SSID* PDOT11_SSID; enum DOT11_BSS_TYPE { dot11_BSS_type_infrastructure = 1, dot11_BSS_type_independent = 2, dot11_BSS_type_any = 3 }; alias DOT11_BSS_TYPE* PDOT11_BSS_TYPE; enum DOT11_PHY_TYPE { dot11_phy_type_unknown = 0, dot11_phy_type_any = dot11_phy_type_unknown, dot11_phy_type_fhss = 1, dot11_phy_type_dsss = 2, dot11_phy_type_irbaseband = 3, dot11_phy_type_ofdm = 4, dot11_phy_type_hrdsss = 5, dot11_phy_type_erp = 6, dot11_phy_type_ht = 7, }; alias DOT11_PHY_TYPE* PDOT11_PHY_TYPE; enum DOT11_AUTH_ALGORITHM { DOT11_AUTH_ALGO_80211_OPEN = 1, DOT11_AUTH_ALGO_80211_SHARED_KEY= 2, DOT11_AUTH_ALGO_WPA = 3, DOT11_AUTH_ALGO_WPA_PSK = 4, DOT11_AUTH_ALGO_WPA_NONE= 5, DOT11_AUTH_ALGO_RSNA= 6, DOT11_AUTH_ALGO_RSNA_PSK= 7, }; alias DOT11_AUTH_ALGORITHM* PDOT11_AUTH_ALGORITHM; enum DOT11_CIPHER_ALGORITHM { DOT11_CIPHER_ALGO_NONE = 0x00, DOT11_CIPHER_ALGO_WEP40 = 0x01, DOT11_CIPHER_ALGO_TKIP = 0x02, DOT11_CIPHER_ALGO_CCMP = 0x04, DOT11_CIPHER_ALGO_WEP104= 0x05, DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100, DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100, DOT11_CIPHER_ALGO_WEP = 0x101, }; alias DOT11_CIPHER_ALGORITHM* PDOT11_CIPHER_ALGORITHM; struct WLAN_AVAILABLE_NETWORK { WCHAR[WLAN_MAX_NAME_LENGTH] strProfileName; DOT11_SSID dot11Ssid; DOT11_BSS_TYPE dot11BssType; ULONG uNumberOfBssids; BOOLbNetworkConnectable; DWORD wlanNotConnectableReason; ULONG uNumberOfPhyTypes; DOT11_PHY_TYPE[WLAN_MAX_PHY_TYPE_NUMBER]dot11PhyTypes; BOOLbMorePhyTypes; ULONG wlanSignalQuality; BOOLbSecurityEnabled; DOT11_AUTH_ALGORITHM dot11DefaultAuthAlgorithm; DOT11_CIPHER_ALGORITHM dot11DefaultCipherAlgorithm; DWORD dwFlags; DWORD dwReserved; }; alias WLAN_AVAILABLE_NETWORK* PWLAN_AVAILABLE_NETWORK; struct WLAN_AVAILABLE_NETWORK_LIST { DWORD dwNumberOfItems; DWORD dwIndex; WLAN_AVAILABLE_NETWORK[1] Network; }; alias WLAN_AVAILABLE_NETWORK_LIST* PWLAN_AVAILABLE_NETWORK_LIST; extern ( Windows ) { DWORD WlanDeleteProfile ( HANDLE, const GUID*, LPCWSTR, PVOID ); DWORD WlanSetProfile