Skip to content

Commit

Permalink
3.6.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ab25cq committed Feb 15, 2018
1 parent f91492e commit d7845a0
Show file tree
Hide file tree
Showing 28 changed files with 368 additions and 123 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

version 3.6.0

ファイルクラスにnew File("fname.txt", "w");などを入れました。内部的にはfopenやfwrite, freadされてバッファリングされます。

version 3.6.0

    I put new File ("fname.txt", "w"); etc in the file class. Internally it is fopen, fwrite, fread and buffered.

version 3.5.9

メソッドの引数で数値型の変換は暗黙で行われるようになりました。int --> ulongなど。
Expand Down
94 changes: 70 additions & 24 deletions File.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class System
}
def open(file_name:String, flags:int, mode:mode_t):static native int throws Exception;
def close(fd:int): static native int throws Exception;
def read(fd:int, buf:Buffer, size:size_t): static native int throws Exception;
def read(fd:int, buf:Buffer, size:size_t): static native ssize_t throws Exception;
def write(fd:int, buf:Buffer, size:size_t): static native ssize_t throws Exception;

def time(): static native time_t;
Expand All @@ -108,7 +108,7 @@ class System
def dirname(path:String): static native String;
def basename(path:String): static native String;
def opendir(path:String): static native DIR throws Exception;
def readdir(dir:DIR): static native String?;
def readdir(dir:DIR): static native String? throws Exception;
def closedir(dir:DIR): static native int throws Exception;
def chmod(path:String, mode:mode_t): static native throws Exception;
def lchmod(path:String, mode:mode_t): static native throws Exception;
Expand Down Expand Up @@ -143,6 +143,10 @@ class System
def fopen(path:String, mode:String): static native pointer@FILE throws Exception;
def fclose(stream:pointer) : static native throws Exception;
def fwrite(buf:Buffer, size:size_t, stream: pointer@FILE): static native size_t throws Exception;
def fread(buf:Buffer, size:size_t, stream:pointer@FILE): static native size_t throws Exception;
def feof(stream: pointer@FILE): static native bool;

def fgetc(stream:pointer@FILE): native static int;

def put_fun_to_hash_for_native_method(path:String, fun_name:String, native_method:pointer): static native;
}
Expand Down Expand Up @@ -378,25 +382,33 @@ class File
{
fd:int;
fileName:String?;
stream:pointer?@FILE;

def initialize() {
self.fd = -1;
self.fileName = null;
self.stream = null;
}

def initialize(file_name:String, flags:int, mode:mode_t) throws Exception {
def initialize(file_name:String, flags:int, mode:mode_t) throws Exception
{
self.fd = System.open(file_name, flags, mode);
self.fileName = file_name;
self.stream = null;
}

def initialize(file_name:String, mode:String) throws Exception {
self.fd = -1;
self.fileName = file_name;
self.stream = System.fopen(file_name, mode);
}

def initialize(file_name:String) throws Exception {
self.initialize(file_name, System.O_RDONLY, 0);
self.initialize(file_name, "r");
}

def finalize() {
if(self.fd != -1) {
System.close(self.fd);
}
self.close();
}

def close() {
Expand All @@ -406,16 +418,29 @@ class File
self.fd = -1;
self.fileName = null;
}
if(self.stream != null) {
System.fclose(self.stream);

self.stream = null;
self.fileName = null;
}
}

def read(size:size_t): Buffer throws Exception {
if(self.fd == -1) {
if(self.fd == -1 && self.stream == null) {
throw new Exception("File is not opened");
}

result:Buffer = new Buffer(size+1.to_ulong);
System.read(self.fd, result, size);
return result;

if(self.stream != null) {
result:Buffer = new Buffer(size+1.to_ulong);
System.fread(result, size, self.stream);
return result;
}
else {
result:Buffer = new Buffer(size+1.to_ulong);
System.read(self.fd, result, size);
return result;
}
}

def to_stat(): stat throws Exception {
Expand All @@ -442,38 +467,59 @@ class File
}

def read(): Buffer throws Exception {
if(self.fd == -1) {
if(self.fd == -1 && self.stream == null) {
throw new Exception("File is not opened");
}

size:size_t = self.to_stat().size();
if(self.stream != null) {
size:size_t = self.to_stat().size();

result:Buffer = new Buffer(size+1.to_ulong);
System.read(self.fd, result, size);
return result;
result:Buffer = new Buffer(size+1.to_ulong);
System.fread(result, size, self.stream);
return result;
}
else {
size:size_t = self.to_stat().size();

result:Buffer = new Buffer(size+1.to_ulong);
System.read(self.fd, result, size);
return result;
}
}

def write(buf:Buffer, size:size_t):int throws Exception {
if(self.fd == -1) {
if(self.fd == -1 && self.stream == null) {
throw new Exception("File is not opened");
}

return System.write(self.fd, buf, size);
if(self.stream != null) {
return System.fwrite(buf, size, self.stream);
}
else {
return System.write(self.fd, buf, size);
}
}

def write(buf:Buffer):int throws Exception {
return self.write(buf, buf.len);
}

def write(file_name:String, buf:Buffer, mode:mode_t): static int throws Exception {
def write(file_name:String, buf:Buffer, mode:mode_t): static int throws Exception
{
f:File = new File(file_name, System.O_CREAT|System.O_TRUNC|System.O_WRONLY, mode);
result:int = f.write(buf);
f.close();

return result;
}
def write(file_name:String, buf:Buffer): static int throws Exception {
return File.write(file_name, buf, 0644);
def write(file_name:String, buf:Buffer, mode:String): static throws Exception
{
f:File = new File(file_name, mode);
f.write(buf);
f.close();
}
def write(file_name:String, buf:Buffer): static throws Exception {
File.write(file_name, buf, "w");
}
}

Expand Down Expand Up @@ -544,8 +590,8 @@ class Path
def read(): Buffer {
return File.read(self.path);
}
def write(buf:Buffer):int {
return File.write(self.path, buf);
def write(buf:Buffer) {
File.write(self.path, buf);
}

def chmod(mode:mode_t) throws Exception {
Expand Down
38 changes: 1 addition & 37 deletions Fundamental.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class System

def srand(value:uint): static native;
def rand(): static native int;
def time(): static native time_t;
def time(): static native time_t throws Exception;

def getenv(name:String): static native String;
def setenv(name:String, value:String, overwrite:int): static native throws Exception;
Expand Down Expand Up @@ -295,10 +295,6 @@ class Byte
self.value = value;
}

def initialize(value:int) {
self.value = value.to_byte;
}

def getValue(): byte {
return self.value;
}
Expand Down Expand Up @@ -334,10 +330,6 @@ class UByte
self.value = value;
}

def initialize(value:int) {
self.value = value.to_ubyte;
}

def getValue(): ubyte {
return self.value;
}
Expand Down Expand Up @@ -373,10 +365,6 @@ class Short
self.value = value;
}

def initialize(value:int) {
self.value = value.to_short;
}

def getValue(): short {
return self.value;
}
Expand Down Expand Up @@ -412,10 +400,6 @@ class UShort
self.value = value;
}

def initialize(value:int) {
self.value = value.to_ushort;
}

def getValue(): ushort {
return self.value;
}
Expand Down Expand Up @@ -492,10 +476,6 @@ class UInteger
self.value = value;
}

def initialize(value:int) {
self.value = value.to_uint;
}

def getValue(): uint {
return self.value;
}
Expand Down Expand Up @@ -527,10 +507,6 @@ class Long
self.value = 0.to_long;
}

def initialize(value:int) {
self.value = value.to_long;
}

def initialize(value:long) {
self.value = value;
}
Expand Down Expand Up @@ -570,10 +546,6 @@ class ULong
self.value = value;
}

def initialize(value:int) {
self.value = value.to_long;
}

def getValue(): long {
return self.value;
}
Expand Down Expand Up @@ -609,10 +581,6 @@ class Float
self.value = value;
}

def initialize(value:int) {
self.value = value.to_float;
}

def getValue(): float {
return self.value;
}
Expand Down Expand Up @@ -644,10 +612,6 @@ class Double
self.value = value;
}

def initialize(value:int) {
self.value = value.to_double;
}

def getValue(): double {
return self.value;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/ab25cq/clover2.svg?branch=master)](https://travis-ci.org/ab25cq/clover2)


version 3.5.9
version 3.6.0

サポートしている機能

Expand Down
8 changes: 4 additions & 4 deletions String.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class System
def pcre_exec(regex:regex, str:Buffer, offset:int, ovec_max:int, ovec:PcreOVec): native static int;
def atoi(str:String):native static int;
def atof(str:String):native static float;
def strtod(str:String): native static double;
def strtod(str:String): native static double throws Exception;
def strcmp(str1:String, str2:String): native static int;
def strcasecmp(str1:String, str2:String): native static int;
def strtol(str:String, base:int): native static long;
def strtoul(str:String, base:int): native static ulong;
def mbstowcs(dest:pointer@wchar[], src:pointer@utf8-string-memory, size:size_t): static native int throws Exception;
def strtol(str:String, base:int): native static long throws Exception;
def strtoul(str:String, base:int): native static ulong throws Exception;
def mbstowcs(dest:pointer@wchar[], src:pointer@utf8-string-buffer, size:size_t): static native int throws Exception;
def wcstombs(dest:pointer@byte[], src:char[]): static native int throws Exception;

MB_LEN_MAX:static int;
Expand Down
11 changes: 11 additions & 0 deletions code/FileTest.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,16 @@ class FileTest {

p"d.txt".write(b"GGG\n");
Clover.test("file test17", p"d.txt".read().equals(b"GGG\n"));


f3 := new File("zzz.txt", "w");
f3.write(b"ABC");
f3.close();

f4 := new File("zzz.txt", "r");
buf4 := f4.read();
f4.close();

Clover.test("file test18", buf4.equals(b"ABC"));
}
}
22 changes: 22 additions & 0 deletions code/SystemCallTest.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,27 @@ class SystemCallTest
System.fclose(f);

Clover.test("sys call test", p"sys.txt".read().equals(b"ABC"));

g := System.fopen("sys.txt", "r");
buf := new Buffer(30);
System.fread(buf, 30, g);
System.fclose(g);

Clover.test("sys call test2", buf.equals(b"ABC"));

wcs:char[]? = null;
b:Buffer = b"あいう";
System.mbstowcs(&wcs, b.buffer, b.len);

Clover.test("sys call test3", wcs[0] == 'あ' && wcs[1] == 'い' && wcs[2] == 'う' && wcs[3] == '\0');


c := new ULong(123);

Clover.test("sys call test4", c == 123);

d := new Float(123);

Clover.test("sys call test5", d == 123.0f);
}
}
2 changes: 1 addition & 1 deletion debian/.debhelper/clover2/dbgsym-build-ids
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1adf9367db259f4e7525af19e0305b7a9e401178 5394c8557f675ade932f643721417597e74360f3 5b784d29484e75f05305810766001b216de6cb56
5394c8557f675ade932f643721417597e74360f3 8b10a3aef4aef0a344474775bef49ad6bbc835f5 fb620f531c1b5063f11acaced48cc7f61c2f759b
2 changes: 1 addition & 1 deletion debian/.debhelper/clover2/dbgsym-root/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Section: debug
Priority: extra
Homepage: https://github.com/ab25cq/clover2/wiki
Description: Debug symbols for clover2
Build-Ids: 1adf9367db259f4e7525af19e0305b7a9e401178 5394c8557f675ade932f643721417597e74360f3 5b784d29484e75f05305810766001b216de6cb56
Build-Ids: 5394c8557f675ade932f643721417597e74360f3 8b10a3aef4aef0a344474775bef49ad6bbc835f5 fb620f531c1b5063f11acaced48cc7f61c2f759b
4 changes: 2 additions & 2 deletions debian/.debhelper/clover2/dbgsym-root/DEBIAN/md5sums
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
e84a164cfe522329936d18b55ff32abf usr/lib/debug/.build-id/1a/df9367db259f4e7525af19e0305b7a9e401178.debug
c2fe717aee59dedc61f0d5427a0465e0 usr/lib/debug/.build-id/53/94c8557f675ade932f643721417597e74360f3.debug
c15b16b5578b7ee39a6717fc71a0eafa usr/lib/debug/.build-id/5b/784d29484e75f05305810766001b216de6cb56.debug
ce5d9083eed53d5be317b2fad14327d3 usr/lib/debug/.build-id/8b/10a3aef4aef0a344474775bef49ad6bbc835f5.debug
d3ad1527a0d7a85d47069eded518c657 usr/lib/debug/.build-id/fb/620f531c1b5063f11acaced48cc7f61c2f759b.debug
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
clover2 (3.6.0-1) unstable; urgency=medium

   * I put new File ("fname.txt", "w"); etc in the file class. Internally it is fopen, fwrite, fread and buffered.

clover2 (3.5.9-1) unstable; urgency=medium

* Numeric type conversion is now implicit in method arguments. int -> ulong and so on.
Expand Down
Loading

0 comments on commit d7845a0

Please sign in to comment.