Skip to content

Instantly share code, notes, and snippets.

@CyberShadow
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CyberShadow/e088c1f2bbfc24f2bbba to your computer and use it in GitHub Desktop.
Save CyberShadow/e088c1f2bbfc24f2bbba to your computer and use it in GitHub Desktop.
Phobos public names diff generator
*.exe
*.pdb
*.ilk
*.txt
*.json
*.diff
@echo off
rdmd makelists 2.067.1 master
diff 2.067.1.txt master.txt | grep "^[<>]" | sed -e "s/^</-/" -e "s/^>/+/" > names.diff
import std.range;
import std.algorithm;
import std.file;
import std.path;
import std.stdio;
import ae.utils.json;
void main(string[] args)
{
static struct Member
{
string file, name, kind;
uint line;
@JSONName("char")
uint char_;
string protection;
string[] selective;
string[] storageClass;
string deco;
string originalType;
Member[] parameters;
string init;
Member[] members;
string type;
uint endline, endchar;
uint offset;
@JSONName("default")
string default_;
string defaultDeco;
string defaultValue;
string base;
string baseDeco;
string specValue;
string defaultAlias;
@JSONName("in")
Member* in_;
@JSONName("out")
Member* out_;
string[] overrides;
string[string] renamed;
string[] interfaces;
@JSONName("alias")
string alias_;
@JSONName("align")
uint align_;
string specAlias;
string value;
string constraint;
// @property auto children() { return chain(parameters, members, in_ ? [*in_] : [], out_ ? [*out_] : []); }
@property auto children() { return /*parameters ~ */members ~ (in_ ? [*in_] : []) ~ (out_ ? [*out_] : []); }
}
foreach (dir; args[1..$])
{
string[] names;
auto fn = dir ~ "/phobos.json";
auto modules = fn.readText.jsonParse!(Member[]);
void scan(string[] prefixes, Member[] members)
{
foreach (d; members)
{
// if (m.name.startsWith("std.internal."))
// continue;
if (d.protection == "private"
|| d.protection == "package"
|| d.type == "import"
|| d.type == "static import"
|| d.name.startsWith("__unittest")
|| d.name.startsWith("__invariant")
|| d.name.startsWith("_staticCtor")
|| d.name.startsWith("_staticDtor")
|| d.name.startsWith("_sharedStaticCtor")
|| d.name.startsWith("_sharedStaticDtor")
)
continue;
auto fullName = prefixes ~ d.name;
names ~= fullName.join(".");
scan(fullName, d.children);
}
}
scan(null, modules);
auto f = File(dir ~ ".txt", "wb");
names.sort().uniq().each!(line => f.writeln(line));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment