amalgam-lang 16.0.0__py3-none-macosx_12_0_x86_64.whl → 16.1.0__py3-none-macosx_12_0_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of amalgam-lang might be problematic. Click here for more details.

amalgam/api.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from ctypes import (
4
- _Pointer, Array, byref, c_bool, c_char, c_char_p, c_double, c_size_t, c_uint64, c_void_p,
4
+ _Pointer, Array, byref, c_bool, c_char, c_char_p, c_size_t, c_uint64, c_void_p,
5
5
  cast, cdll, POINTER, Structure
6
6
  )
7
7
  from datetime import datetime
@@ -55,8 +55,8 @@ class LoadEntityStatus:
55
55
  self.version = ""
56
56
  else:
57
57
  self.loaded = bool(c_status.loaded)
58
- self.message = api.char_p_to_bytes(c_status.message).decode("utf-8")
59
- self.version = api.char_p_to_bytes(c_status.version).decode("utf-8")
58
+ self.message = api.char_p_to_str(c_status.message)
59
+ self.version = api.char_p_to_str(c_status.version)
60
60
 
61
61
  def __str__(self) -> str:
62
62
  """
@@ -70,6 +70,57 @@ class LoadEntityStatus:
70
70
  return f"{self.loaded},\"{self.message}\",\"{self.version}\""
71
71
 
72
72
 
73
+ class _ResultWithLog(Structure):
74
+ """The C-native version of :class:`ResultWithLog`."""
75
+ _fields_ = [
76
+ ("json", POINTER(c_char)),
77
+ ("log", POINTER(c_char))
78
+ ]
79
+
80
+
81
+ class ResultWithLog:
82
+ """
83
+ Return value from :func:`~api.Amalgam.execute_entity_json_logged`.
84
+
85
+ Parameters
86
+ ----------
87
+ json : str | None
88
+ The JSON-format response from the Amalgam invocation.
89
+ log : str | None
90
+ The Amalgam-syntax transaction-log entry.
91
+ """
92
+
93
+ def __init__(self, *, json: str | None, log: str | None):
94
+ self.json = json
95
+ """The JSON-format response from the Amalgam invocation."""
96
+
97
+ self.log = log
98
+ """The Amalgam-syntax transaction-log entry."""
99
+
100
+ @classmethod
101
+ def from_c_result(cls, api: Amalgam, c_result: _ResultWithLog) -> t.Self:
102
+ """
103
+ Construct a `ResultWithLog` from the raw C result.
104
+
105
+ Frees the strings in the C result.
106
+
107
+ Parameters
108
+ ----------
109
+ api : Amalgam
110
+ The Amalgam API layer.
111
+ c_result: _ResultWithLog
112
+ The raw C result structure.
113
+
114
+ Returns
115
+ -------
116
+ ResultWithLog
117
+ A populated Python-side structure.
118
+ """
119
+ json = api.char_p_to_str(c_result.json)
120
+ log = api.char_p_to_str(c_result.log)
121
+ return cls(json=json, log=log)
122
+
123
+
73
124
  class Amalgam:
74
125
  """
75
126
  A general python direct interface to the Amalgam library.
@@ -625,6 +676,29 @@ class Amalgam:
625
676
 
626
677
  return bytes_str
627
678
 
679
+ def char_p_to_str(self, p: _Pointer[c_char] | c_char_p) -> str | None:
680
+ """
681
+ Copy native C char pointer to UTF-8-encoded string, cleaning up memory correctly.
682
+
683
+ Parameters
684
+ ----------
685
+ p : c_char_p
686
+ The char pointer to convert
687
+
688
+ Returns
689
+ -------
690
+ str or None
691
+ The resulting string
692
+ """
693
+ b = self.char_p_to_bytes(p)
694
+ s: str | None = None
695
+ if b is not None:
696
+ try:
697
+ s = b.decode("UTF-8")
698
+ except UnicodeDecodeError:
699
+ s = None
700
+ return s
701
+
628
702
  def get_json_from_label(self, handle: str, label: str) -> bytes:
629
703
  """
630
704
  Get a label from amalgam and returns it in json format.
@@ -1058,6 +1132,56 @@ class Amalgam:
1058
1132
 
1059
1133
  return result
1060
1134
 
1135
+ def execute_entity_json_logged(
1136
+ self,
1137
+ handle: str,
1138
+ label: str,
1139
+ json: str | bytes
1140
+ ) -> ResultWithLog:
1141
+ """
1142
+ Execute a label, and also return a transaction log.
1143
+
1144
+ Parameters
1145
+ ----------
1146
+ handle : str
1147
+ The handle of the amalgam entity.
1148
+
1149
+ label : str
1150
+ The label to execute.
1151
+ json : str or bytes
1152
+ A json representation of parameters for the label to be executed.
1153
+
1154
+ Returns
1155
+ -------
1156
+ ResultWithLog
1157
+ Both a JSON-encoded response and the Amalgam-format transaction log entry.
1158
+
1159
+ """
1160
+ self.amlg.ExecuteEntityJsonPtrLogged.restype = _ResultWithLog
1161
+ self.amlg.ExecuteEntityJsonPtrLogged.argtypes = [
1162
+ c_char_p, c_char_p, c_char_p]
1163
+ handle_buf = self.str_to_char_p(handle)
1164
+ label_buf = self.str_to_char_p(label)
1165
+ json_buf = self.str_to_char_p(json)
1166
+
1167
+ self._log_time("EXECUTION START")
1168
+ self._log_execution((
1169
+ "EXECUTE_ENTITY_JSON_LOGGED "
1170
+ f"\"{self.escape_double_quotes(handle)}\" "
1171
+ f"\"{self.escape_double_quotes(label)}\" "
1172
+ f"{json}"
1173
+ ))
1174
+ result = ResultWithLog.from_c_result(self, self.amlg.ExecuteEntityJsonPtrLogged(
1175
+ handle_buf, label_buf, json_buf))
1176
+ self._log_time("EXECUTION STOP")
1177
+ self._log_reply(result)
1178
+
1179
+ del handle_buf
1180
+ del label_buf
1181
+ del json_buf
1182
+
1183
+ return result
1184
+
1061
1185
  def eval_on_entity(
1062
1186
  self,
1063
1187
  handle: str,
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "58.0.0"
2
+ "version": "58.1.1"
3
3
  }
amalgam/lib/version.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": {
3
- "amalgam": "58.0.0",
4
- "amalgam_sha": "f797e187f376c7a45cc70be01a253edef8d01e5e",
5
- "amalgam_url": "https://github.com/howsoai/amalgam/releases/tag/58.0.0",
3
+ "amalgam": "58.1.1",
4
+ "amalgam_sha": "410684e7abf7872f0fbd37acf53155c69c534111",
5
+ "amalgam_url": "https://github.com/howsoai/amalgam/releases/tag/58.1.1",
6
6
  "amalgam_build_date": "",
7
7
  "amalgam_display_title": ""
8
8
  }
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: amalgam-lang
3
- Version: 16.0.0
3
+ Version: 16.1.0
4
4
  Summary: A direct interface with Amalgam compiled DLL, dylib, or so.
5
5
  Author: Howso Incorporated
6
6
  Author-email: support@howso.com
@@ -0,0 +1,13 @@
1
+ amalgam/__init__.py,sha256=oHu7Zr4eGDUqj93pLwz8t7gLa8lpAx6Q-xbGiJ3nJx0,18
2
+ amalgam/api.py,sha256=bVIMAuMsb55ELy6Ja1UmR3kqajfmPZbpFFBKjzVKT2o,42697
3
+ amalgam/lib/version.json,sha256=ggK6Zwl5Z1zN8z7fYTYuzQuap3qN0mzd2Yl-hlIiEgo,250
4
+ amalgam/lib/darwin/amd64/amalgam-mt-noavx.dylib,sha256=RFzzfGnde7ZyWn8enRnNm0Namw3b_-9iPQ0VgtyLvvI,3463032
5
+ amalgam/lib/darwin/amd64/amalgam-mt.dylib,sha256=URB4fk-XEMLLv0GLVxpRC5_1Ce2Pbrswp6RTXmtnAAQ,3785008
6
+ amalgam/lib/darwin/amd64/amalgam-omp.dylib,sha256=tOw6vYbhxapfqOIzK-iDnMph-6nSk1XPUDGQTAShL9w,4167936
7
+ amalgam/lib/darwin/amd64/amalgam-st.dylib,sha256=Qdoza36VmKKouFPojJY5KK-cUo_E94qeG1FsOGYaHrc,3630792
8
+ amalgam/lib/darwin/amd64/docs/version.json,sha256=ayfGJDNHt-UaNSy3ODSSETY0WK11GxIfz796ALRtUF8,25
9
+ amalgam_lang-16.1.0.dist-info/LICENSE.txt,sha256=2xqHuoHohba7gpcZZKtOICRjzeKsQANXG8WoV9V35KM,33893
10
+ amalgam_lang-16.1.0.dist-info/METADATA,sha256=C-Al2wnKqoV0HiHuCYIHNbQu4N9XEcSUHdjBg0MULrM,43807
11
+ amalgam_lang-16.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
12
+ amalgam_lang-16.1.0.dist-info/top_level.txt,sha256=rmPHU144SyaB25u5-FAQyECAQnJ39NvuJEcKXMRcdBo,8
13
+ amalgam_lang-16.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,13 +0,0 @@
1
- amalgam/__init__.py,sha256=oHu7Zr4eGDUqj93pLwz8t7gLa8lpAx6Q-xbGiJ3nJx0,18
2
- amalgam/api.py,sha256=-iK6AmVZk5fJuBVRmllT3Jmv-GbGq2I7XKIURo-ByO0,39296
3
- amalgam/lib/version.json,sha256=ZqDqmXt4mkYPFUFGe-DKdmBQztBXr9lZNPP3mXjHhV4,250
4
- amalgam/lib/darwin/amd64/amalgam-mt-noavx.dylib,sha256=LEdma0lgtQ34yYCcUym0wDGP2KFAh8OnU5e4v2DPurw,3481520
5
- amalgam/lib/darwin/amd64/amalgam-mt.dylib,sha256=fdqqIfhPK9GxbYBys_HJNzUDGUQwwfYwKbYEXb9COK8,3803504
6
- amalgam/lib/darwin/amd64/amalgam-omp.dylib,sha256=8oW-E9rgXgiwvolYbomIWQ1LHOF3GEb3Cj5uwTtPMd0,4195400
7
- amalgam/lib/darwin/amd64/amalgam-st.dylib,sha256=2TPKysg_XeAJbX5dgiQtGc5eAJC06jzHxEmwf57-1Rw,3674656
8
- amalgam/lib/darwin/amd64/docs/version.json,sha256=vkT3SE1CNlzjDD1Twp5CLdApAO1e4MYnFbnLN41BW5I,25
9
- amalgam_lang-16.0.0.dist-info/LICENSE.txt,sha256=2xqHuoHohba7gpcZZKtOICRjzeKsQANXG8WoV9V35KM,33893
10
- amalgam_lang-16.0.0.dist-info/METADATA,sha256=nLchDWzZVCctfoyVN8AYZCOLZSLOXk5tEfe6Jv1dfps,43807
11
- amalgam_lang-16.0.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
12
- amalgam_lang-16.0.0.dist-info/top_level.txt,sha256=rmPHU144SyaB25u5-FAQyECAQnJ39NvuJEcKXMRcdBo,8
13
- amalgam_lang-16.0.0.dist-info/RECORD,,