<commit_before>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  refines: 'foam.core.StubMethod',
  properties: [
    {
      name: 'swiftCode',
      expression: function(swiftName, swiftReturns, swiftArgs, swiftThrows) {
        return swiftThrows ? this.swiftCodeGenerator() : 'fatalError()';
      }
    }
  ],
  templates: [
    {
      name: 'swiftCodeGenerator',
      args: [],
      template: function() {/*
<% if (this.swiftReturns) { %>
let replyBox = ReplyBox_create([
  "delegate": RPCReturnBox_create()
])
let registeredReplyBox = (registry as! BoxRegistry).register(
  replyBox.id,
  delegateReplyPolicy as? BoxService,
  replyBox)
<% } %>

let msg = Message_create([
  "object": RPCMessage_create([
    "name": "<%=this.swiftName%>",
    "args": [<%=this.swiftArgs.map(function(a) { return a.localName }).join(', ')%>] as [Any?],
  ]),
])

<% if (this.swiftReturns) { %>
msg.attributes["replyBox"] = registeredReplyBox
msg.attributes["errorBox"] = registeredReplyBox
<% } %>

try? delegate.send(msg)

<% if (this.swiftReturns) { %>
  <% if (this.swiftReturns == 'Any?') { %>
return try (replyBox.delegate as? RPCReturnBox)?.future.get()
  <% } else { %>
let o = try (replyBox.delegate as? RPCReturnBox)?.future.get()
replyBox.detach()
(registeredReplyBox as? Detachable)?.detach()
msg.detach()
if let o = o as? <%=this.swiftReturns%> {
  return o
}
throw FoamError(o ?? "Failed to cast response to <%=this.swiftName%> as <%=this.swiftReturns%>")
  <% } %>
<% } %>
      */},
    },
  ],
});

foam.CLASS({
  refines: 'foam.core.Stub',
  properties: [
    {
      name: 'swiftType',
      value: 'Box',
    }
  ]
});<commit_msg>Add Swift support for StubNotification.<commit_after>/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  refines: 'foam.core.StubMethod',
  properties: [
    {
      name: 'swiftCode',
      expression: function(swiftName, swiftReturns, swiftArgs, swiftThrows) {
        return swiftThrows ? this.swiftCodeGenerator() : 'fatalError()';
      }
    }
  ],
  templates: [
    {
      name: 'swiftCodeGenerator',
      args: [],
      template: function() {/*
<% if (this.swiftReturns) { %>
let replyBox = ReplyBox_create([
  "delegate": RPCReturnBox_create()
])
let registeredReplyBox = (registry as! BoxRegistry).register(
  replyBox.id,
  delegateReplyPolicy as? BoxService,
  replyBox)
<% } %>

let msg = Message_create([
  "object": RPCMessage_create([
    "name": "<%=this.swiftName%>",
    "args": [<%=this.swiftArgs.map(function(a) { return a.localName }).join(', ')%>] as [Any?],
  ]),
])

<% if (this.swiftReturns) { %>
msg.attributes["replyBox"] = registeredReplyBox
msg.attributes["errorBox"] = registeredReplyBox
<% } %>

try? delegate.send(msg)

<% if (this.swiftReturns) { %>
  <% if (this.swiftReturns == 'Any?') { %>
return try (replyBox.delegate as? RPCReturnBox)?.future.get()
  <% } else { %>
let o = try (replyBox.delegate as? RPCReturnBox)?.future.get()
replyBox.detach()
(registeredReplyBox as? Detachable)?.detach()
msg.detach()
if let o = o as? <%=this.swiftReturns%> {
  return o
}
throw FoamError(o ?? "Failed to cast response to <%=this.swiftName%> as <%=this.swiftReturns%>")
  <% } %>
<% } %>
      */},
    },
  ],
});


foam.CLASS({
  refines: 'foam.core.StubNotification',
  properties: [
    {
      name: 'swiftCode',
      expression: function(swiftName, swiftReturns, swiftArgs, swiftThrows) {
        return swiftThrows ? this.swiftCodeGenerator() : 'fatalError()';
      }
    }
  ],
  templates: [
    {
      name: 'swiftCodeGenerator',
      args: [],
      template: function() {/*
let msg = Message_create([
  "object": RPCMessage_create([
    "name": "<%=this.swiftName%>",
    "args": [<%=this.swiftArgs.map(function(a) { return a.localName }).join(', ')%>] as [Any?],
  ]),
])
try? delegate.send(msg)
      */},
    },
  ],
});

foam.CLASS({
  refines: 'foam.core.Stub',
  properties: [
    {
      name: 'swiftType',
      value: 'Box',
    }
  ]
});
{'fraction_non_alphanumeric': 0.18915633357646486, 'fraction_numerical': 0.0029175784099197666, 'mean_word_length': 3.50109409190372, 'pattern_counts': {'":': 11, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493131', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1404, 'n_words': 279}