Skip to content

Commit

Permalink
Release k8-1.0 (r124)
Browse files Browse the repository at this point in the history
  • Loading branch information
attractivechaos committed Aug 10, 2023
1 parent dbb2d6d commit 892bddb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Release 1.0-r121 (10 August 2023)
Release 1.0-r124 (10 August 2023)
---------------------------------

The previous version of k8, v0.2.5, was built on top of v8-3.16.4 released on
Expand Down Expand Up @@ -45,4 +45,4 @@ Removed functions (BREAKING):
* `Bytes.prototype.cast()` - Bytes only supports `uint8_t`
* `Bytes[]` - not possible to implement. Use `Bytes.buffer` as a partial remedy

(1.0: 10 August 2023, r119)
(1.0: 10 August 2023, r124)
18 changes: 10 additions & 8 deletions k8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define K8_VERSION "1.0-r121"
#define K8_VERSION "1.0-r124"

#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -358,20 +358,22 @@ static void k8_write_string(FILE *fp, const v8::FunctionCallbackInfo<v8::Value>
v8::HandleScope handle_scope(args.GetIsolate());
if (args[i]->IsString()) {
int64_t len = args[i].As<v8::String>()->Length();
K8_GROW(uint8_t, buf->s, len-1, buf->m);
args[i].As<v8::String>()->WriteOneByte(args.GetIsolate(), buf->s);
fwrite(buf->s, 1, len, fp);
if (len > 0) {
K8_GROW(uint8_t, buf->s, len, buf->m);
args[i].As<v8::String>()->WriteOneByte(args.GetIsolate(), buf->s);
fwrite(buf->s, 1, len, fp);
}
return;
} else if (args[i]->IsArrayBuffer()) {
void *data = args[i].As<v8::ArrayBuffer>()->GetBackingStore()->Data();
int64_t len = args[i].As<v8::ArrayBuffer>()->GetBackingStore()->ByteLength();
fwrite(data, 1, len, fp);
if (len > 0) fwrite(data, 1, len, fp);
return;
} else if (args[i]->IsObject()) {
if (args[i].As<v8::Object>()->InternalFieldCount() > 0) {
k8_bytes_t *a = (k8_bytes_t*)args[i].As<v8::Object>()->GetAlignedPointerFromInternalField(0);
if (a && a->magic == K8_BYTES_MAGIC) {
fwrite(a->buf.s, 1, a->buf.l, fp);
if (a->buf.l > 0) fwrite(a->buf.s, 1, a->buf.l, fp);
return;
}
}
Expand Down Expand Up @@ -706,14 +708,14 @@ static void k8_file_write(const v8::FunctionCallbackInfo<v8::Value> &args)
void *data = args[0].As<v8::ArrayBuffer>()->GetBackingStore()->Data();
int64_t len = args[0].As<v8::ArrayBuffer>()->GetBackingStore()->ByteLength();
assert(len >= 0 && len < INT32_MAX);
fwrite(data, 1, len, ks->fpw);
if (len > 0) fwrite(data, 1, len, ks->fpw);
args.GetReturnValue().Set((int32_t)len);
} else if (args[0]->IsString()) {
int32_t len = args[0].As<v8::String>()->Length();
uint8_t *buf;
buf = K8_MALLOC(uint8_t, len);
args[0].As<v8::String>()->WriteOneByte(args.GetIsolate(), buf);
fwrite(buf, 1, len, ks->fpw);
if (len > 0) fwrite(buf, 1, len, ks->fpw);
free(buf);
args.GetReturnValue().Set(len);
}
Expand Down

0 comments on commit 892bddb

Please sign in to comment.