Fully remove C utility functions
This commit is contained in:
parent
1bfd8906b6
commit
2e8343f9bc
@ -541,79 +541,6 @@ namespace Matrix {
|
||||
}
|
||||
}
|
||||
|
||||
public class StateEvent : JsonCompact {
|
||||
public string? state_key { get; set; default = null; }
|
||||
public Json.Node? content { get; set; default = null; }
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("state_key");
|
||||
builder.add_string_value(state_key);
|
||||
|
||||
builder.set_member_name("content");
|
||||
builder.add_value(content);
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
private Json.Node?
|
||||
_json_node_deep_copy(Json.Node? node)
|
||||
{
|
||||
Json.Node ret;
|
||||
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ret = new Json.Node(node.get_node_type());
|
||||
|
||||
switch (node.get_node_type()) {
|
||||
case Json.NodeType.OBJECT:
|
||||
var new_obj = new Json.Object();
|
||||
|
||||
node.get_object().foreach_member(
|
||||
(old_obj, member_name, member_node) => {
|
||||
new_obj.set_member(
|
||||
member_name,
|
||||
_json_node_deep_copy(member_node));
|
||||
});
|
||||
|
||||
ret.set_object(new_obj);
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.ARRAY:
|
||||
var new_ary = new Json.Array();
|
||||
|
||||
node.get_array().foreach_element(
|
||||
(old_ary, idx, element_node) => {
|
||||
new_ary.add_element(
|
||||
_json_node_deep_copy(element_node));
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.VALUE:
|
||||
ret.set_value(node.get_value());
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.NULL:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold unsigned event data, like event age, redact
|
||||
* reason or a transaction ID.
|
||||
@ -962,4 +889,53 @@ namespace Matrix {
|
||||
|
||||
return new_node;
|
||||
}
|
||||
|
||||
public Json.Node?
|
||||
_json_node_deep_copy(Json.Node? node)
|
||||
{
|
||||
Json.Node ret;
|
||||
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ret = new Json.Node(node.get_node_type());
|
||||
|
||||
switch (node.get_node_type()) {
|
||||
case Json.NodeType.OBJECT:
|
||||
var new_obj = new Json.Object();
|
||||
|
||||
node.get_object().foreach_member(
|
||||
(old_obj, member_name, member_node) => {
|
||||
new_obj.set_member(
|
||||
member_name,
|
||||
_json_node_deep_copy(member_node));
|
||||
});
|
||||
|
||||
ret.set_object(new_obj);
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.ARRAY:
|
||||
var new_ary = new Json.Array();
|
||||
|
||||
node.get_array().foreach_element(
|
||||
(old_ary, idx, element_node) => {
|
||||
new_ary.add_element(
|
||||
_json_node_deep_copy(element_node));
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.VALUE:
|
||||
ret.set_value(node.get_value());
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.NULL:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user