objc-generator: update to latest nominated Zig
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
6e2f937026
commit
03a8445b90
2 changed files with 18 additions and 18 deletions
|
|
@ -737,7 +737,7 @@ pub const Converter = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convertEnumDecl(self: *Self, n: std.json.Value) !void {
|
fn convertEnumDecl(self: *Self, n: std.json.Value) !void {
|
||||||
var name = getString(n, "name");
|
const name = getString(n, "name");
|
||||||
if (name.len == 0) {
|
if (name.len == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -752,7 +752,7 @@ pub const Converter = struct {
|
||||||
for (getArray(n, "inner")) |child| {
|
for (getArray(n, "inner")) |child| {
|
||||||
const childKind = getString(child, "kind");
|
const childKind = getString(child, "kind");
|
||||||
if (std.mem.eql(u8, childKind, "EnumConstantDecl")) {
|
if (std.mem.eql(u8, childKind, "EnumConstantDecl")) {
|
||||||
var v = try self.convertEnumConstantDecl(child);
|
const v = try self.convertEnumConstantDecl(child);
|
||||||
try e.values.append(v);
|
try e.values.append(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -773,7 +773,7 @@ pub const Converter = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convertConstantExpr(_: *Self, n: std.json.Value) i64 {
|
fn convertConstantExpr(_: *Self, n: std.json.Value) i64 {
|
||||||
var value = getString(n, "value");
|
const value = getString(n, "value");
|
||||||
return std.fmt.parseInt(i64, value, 10) catch 0;
|
return std.fmt.parseInt(i64, value, 10) catch 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -794,8 +794,8 @@ pub const Converter = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convertObjCCategoryDecl(self: *Self, n: std.json.Value) !void {
|
fn convertObjCCategoryDecl(self: *Self, n: std.json.Value) !void {
|
||||||
var interfaceDecl = getObject(n, "interface").?;
|
const interfaceDecl = getObject(n, "interface").?;
|
||||||
var container = try registry.getInterface(getString(interfaceDecl, "name"));
|
const container = try registry.getInterface(getString(interfaceDecl, "name"));
|
||||||
try self.convertContainer(container, n);
|
try self.convertContainer(container, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -846,20 +846,20 @@ pub const Converter = struct {
|
||||||
|
|
||||||
for (getArray(n, "protocols")) |protocolJson| {
|
for (getArray(n, "protocols")) |protocolJson| {
|
||||||
const protocolName = getString(protocolJson, "name");
|
const protocolName = getString(protocolJson, "name");
|
||||||
var protocol = try registry.getProtocol(protocolName);
|
const protocol = try registry.getProtocol(protocolName);
|
||||||
try container.protocols.append(protocol);
|
try container.protocols.append(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (getArray(n, "inner")) |child| {
|
for (getArray(n, "inner")) |child| {
|
||||||
const childKind = getString(child, "kind");
|
const childKind = getString(child, "kind");
|
||||||
if (std.mem.eql(u8, childKind, "ObjCTypeParamDecl")) {
|
if (std.mem.eql(u8, childKind, "ObjCTypeParamDecl")) {
|
||||||
var type_param = try self.convertTypeParam(child);
|
const type_param = try self.convertTypeParam(child);
|
||||||
try container.type_params.append(type_param);
|
try container.type_params.append(type_param);
|
||||||
} else if (std.mem.eql(u8, childKind, "ObjCPropertyDecl")) {
|
} else if (std.mem.eql(u8, childKind, "ObjCPropertyDecl")) {
|
||||||
var property = try self.convertProperty(child);
|
const property = try self.convertProperty(child);
|
||||||
try container.properties.append(property);
|
try container.properties.append(property);
|
||||||
} else if (std.mem.eql(u8, childKind, "ObjCMethodDecl")) {
|
} else if (std.mem.eql(u8, childKind, "ObjCMethodDecl")) {
|
||||||
var method = try self.convertMethod(child);
|
const method = try self.convertMethod(child);
|
||||||
try container.methods.append(method);
|
try container.methods.append(method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -871,18 +871,18 @@ pub const Converter = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convertProperty(self: *Self, n: std.json.Value) !Property {
|
fn convertProperty(self: *Self, n: std.json.Value) !Property {
|
||||||
var ty = try self.convertType(getObject(n, "type").?);
|
const ty = try self.convertType(getObject(n, "type").?);
|
||||||
return Property.init(getString(n, "name"), ty);
|
return Property.init(getString(n, "name"), ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convertMethod(self: *Self, n: std.json.Value) !Method {
|
fn convertMethod(self: *Self, n: std.json.Value) !Method {
|
||||||
var return_type = try self.convertType(getObject(n, "returnType").?);
|
const return_type = try self.convertType(getObject(n, "returnType").?);
|
||||||
var params = std.ArrayList(Param).init(registry.allocator);
|
var params = std.ArrayList(Param).init(registry.allocator);
|
||||||
|
|
||||||
for (getArray(n, "inner")) |child| {
|
for (getArray(n, "inner")) |child| {
|
||||||
const childKind = getString(child, "kind");
|
const childKind = getString(child, "kind");
|
||||||
if (std.mem.eql(u8, childKind, "ParmVarDecl")) {
|
if (std.mem.eql(u8, childKind, "ParmVarDecl")) {
|
||||||
var param = try self.convertParam(child);
|
const param = try self.convertParam(child);
|
||||||
try params.append(param);
|
try params.append(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -980,7 +980,7 @@ fn Generator(comptime WriterType: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addProtocol(self: *Self, name: []const u8) !void {
|
pub fn addProtocol(self: *Self, name: []const u8) !void {
|
||||||
var container = registry.protocols.get(name) orelse {
|
const container = registry.protocols.get(name) orelse {
|
||||||
std.debug.print("Protocol {s} not found\n", .{name});
|
std.debug.print("Protocol {s} not found\n", .{name});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -989,7 +989,7 @@ fn Generator(comptime WriterType: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addInterface(self: *Self, name: []const u8) !void {
|
pub fn addInterface(self: *Self, name: []const u8) !void {
|
||||||
var container = registry.interfaces.get(name) orelse {
|
const container = registry.interfaces.get(name) orelse {
|
||||||
std.debug.print("Interface {s} not found\n", .{name});
|
std.debug.print("Interface {s} not found\n", .{name});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -998,7 +998,7 @@ fn Generator(comptime WriterType: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn addEnum(self: *Self, name: []const u8) !void {
|
pub fn addEnum(self: *Self, name: []const u8) !void {
|
||||||
var e = registry.enums.get(name) orelse {
|
const e = registry.enums.get(name) orelse {
|
||||||
std.debug.print("Enum {s} not found\n", .{name});
|
std.debug.print("Enum {s} not found\n", .{name});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -194,11 +194,11 @@ pub const Registry = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getEnum(self: *Self, name: []const u8) !*Enum {
|
pub fn getEnum(self: *Self, name: []const u8) !*Enum {
|
||||||
var v = try self.enums.getOrPut(name);
|
const v = try self.enums.getOrPut(name);
|
||||||
if (v.found_existing) {
|
if (v.found_existing) {
|
||||||
return v.value_ptr.*;
|
return v.value_ptr.*;
|
||||||
} else {
|
} else {
|
||||||
var e = try self.allocator.create(Enum);
|
const e = try self.allocator.create(Enum);
|
||||||
e.* = Enum.init(self.allocator, name);
|
e.* = Enum.init(self.allocator, name);
|
||||||
v.value_ptr.* = e;
|
v.value_ptr.* = e;
|
||||||
return e;
|
return e;
|
||||||
|
|
@ -220,7 +220,7 @@ pub const Registry = struct {
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
is_interface: bool,
|
is_interface: bool,
|
||||||
) !*Container {
|
) !*Container {
|
||||||
var v = try primary.getOrPut(name);
|
const v = try primary.getOrPut(name);
|
||||||
var container: *Container = undefined;
|
var container: *Container = undefined;
|
||||||
if (v.found_existing) {
|
if (v.found_existing) {
|
||||||
container = v.value_ptr.*;
|
container = v.value_ptr.*;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue