phobos/std/internal/encodinginit.d
Martin Nowak 9d73d18c0c fix Issue 16291 - EncodingScheme.create fails
- add EncodingScheme.register overload that references the registered class
- just adding the FQN name of a class does not reference that class, so
  it must not end up in the binary and subsequently EncodingScheme.create failed
- This used to work by chance b/c all the EncodingScheme implementations
  were in a module w/ static ctor. Any user of std.encoding did drag in
  that ModuleInfo, which in turn referenced all classes of std.encoding.
  Since moving the static ctor to std.internal.phobosinit to break a
  cycle, the classes were no longer referenced by a ModuleInfo w/ shared
  ctor, so they wouldn't end up in the binary unless explicitly
  referenced elsewhere.
- deprecate the old EncodingScheme.register(string fqn) b/c relying on
  Object.factory is slow, error prone (linkage), and really unnecessary
- import encodinginit in std.encoding so that the
  std_encoding_shared_static_this callback actually gets run
2016-10-05 01:54:22 +02:00

19 lines
559 B
D

// Written in the D programming language.
/++
The purpose of this module is to perform static construction away from the
normal modules to eliminate cyclic construction errors.
Copyright: Copyright 2011 - 2016
License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: Martin Nowak, Steven Schveighoffer
Source: $(PHOBOSSRC std/internal/_encodinginit.d)
+/
module std.internal.encodinginit;
extern(C) void std_encoding_shared_static_this();
shared static this()
{
std_encoding_shared_static_this();
}