Skip to content

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Sep 27, 2011

std.windows.registry changes:

  • Use *W functions when std.__fileinit.useWfuncs equals to true.

    This is core improvement of this pull request. Current std.windows.registry unittest is broken, because Unicode code points are sometimes lack in MBS environment depending on CodePage setting, and in Japanese locale the unittest for registry write/read is always breaking!
    This change can fix the serious problem.

  • Support ddoc.

    Old doc comment is not ddoc formatting.
    See http://d-programming-language.org/phobos/std_windows_registry.html

std.datetime changes:

  • Use std.windows.registry for getting TimeZones.

    *A functions were also used in std.datetime for getting TimeZone, but was is broken in Japanese locale, because
    Std and Dlt Keys in Software\Microsoft\Windows NT\CurrentVersion\Time Zones\(TimeZone Name) have Japanese values, and getting them with *A function caused Invalid UTF sequence error.

    But, this fix introduce cycle dependency with current unittest system in Windows.
    (datetime -> windows.registry -> exception -> array -> algorithm => random -> datetime)
    -> ... dependency required by module features
    => required by module _unittest_s

    To fix it, we need to merge Each unittest in Windows #280 first.

}

useWfuncs = save_useWfuncs;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about scope(exit) useWfunc = save_useWfuncs;
right after line 2098?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. I'll fix it.

@9rnsr
Copy link
Contributor Author

9rnsr commented Sep 29, 2011

Improve code pointed by blackwhale, and add datetime.unittest fixes.
@jmdavis, please review this fix. Your unittest code is breaks Phbos testings in Japan every day.

@jmdavis
Copy link
Member

jmdavis commented Sep 30, 2011

The changes in std.datetime look good, though I'm going to have to go and make some changes later to make it work with wine (wine doesn't use the correct keys in its registry, which is why the code was the way that it was). That doesn't affect what you did though. It looks solid, and it's probably cleaner than I would have done, since it's using std.windows.registry.

{
template SelUni(Char)
{
static if (is(Char == char))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first inclination is to think that Unqual should be used on the tests in this template, but I don't know. Certainly, in general, this sort of check requires Unqual.

/**
Represents the local system registry.
*/
abstract final class Registry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstract final? Is this an attempt to make Registry unconstructable? Couldn't you just use @disable on the default constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, Is it better the final class with @disable this();?
OK. I'll fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstract final is just plain weird. It works, but using @disable on the default constructor is the way that the language provides to make a type unconstructable, so that's what should be done IMHO. I don't think that it matters one way or another whether it's final (since without a valid constructor in the base class, you can't construct derived types anyway), but it certainly doesn't hurt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A class that has @disable this() is not constructable, but it does't forbid inheritance.
In some cases, the derived class will work like a namespace inherits base namespace.
Therefore final is need for Registry class, it is isolated namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I'm not sure that being able to inherit from a class that's unconstructable is really an issue, but as I said, it doesn't hurt to use final, so feel free to do so. However, now that I think of it, Walter has pointed out in the past that there is extra overhead in having a class rather than a struct (since it still ends up creating a vtable and all that), so it would probably be better to make it a struct rather than a class, which solves the inheritance issue too. I should probably do the same to Clock in std.datetime too, but I keep forgetting. I'll have to try and remember to do that in my next set of revisions to std.datetime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it would probably be better to make it a struct rather than a class, which solves the inheritance issue too

Unfortunately, @disable this() in struct S does not disable its instantiation. It allows an explicit initialization like S s = S.init;.

I think that is still better, final class with @disable this().

@jmdavis
Copy link
Member

jmdavis commented Oct 1, 2011

Wow. That's a lot of changes.

@jmacdonagh
Copy link
Contributor

You can see the effective changes using GitHub's compare view, rather than having to look at each commit individually:

9rnsr/phobos@D-Programming-Language:master...9rnsr:regwide

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 1, 2011

Thanks for your many points, jmdavis.

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 2, 2011

Updated from the review comments. Thanks very well, @jmdavis!

9rnsr added 4 commits October 3, 2011 03:34
- Use std.utf.toUTF16z
- Fix array operations
- Add next parameter for exceptions constructors
- Remove unused code
- Put the brace on its own line
- Fix conditional compilation with endian
- Move default case to the last of a switch block
- Add more @safe pure
- Fix ddoc comments.
- Change auto to immutable
- Add enforceSucc, and use enforce family
- Change uint to size_t around indexing
@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 2, 2011

Fixing bug 6746 had been detecting true cycle dependency of std.datetime, and we couldn't fix the issue by #280.
Then, I did moved static ctor/dtor into internal module to avoid the error.

With this change, this pull request does not require #280 anymore.

jmdavis added a commit that referenced this pull request Oct 7, 2011
Improve std.windows.registry and fix datetime unit test
@jmdavis jmdavis merged commit 11dbf95 into dlang:master Oct 7, 2011
@jmdavis
Copy link
Member

jmdavis commented Oct 7, 2011

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants