Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
c42da39
Refactor HttpUrl module to use DStrings.String for path, query, and f…
erno-szabados Jun 24, 2025
d67f440
Remove unused decodePercent procedure and add HttpUrlTokenizer module…
erno-szabados Jun 24, 2025
cbf7952
Uri parser, WIP
erno-szabados Jun 24, 2025
387133f
Refactor HttpUrlTokenizer to modularize token reading procedures and …
erno-szabados Jun 24, 2025
dc9937a
Refactor StringToInt and Parse procedures to utilize DStrings for imp…
erno-szabados Jun 25, 2025
ce003dc
Fix WriteDString procedure to correctly read from source and write to…
erno-szabados Jun 25, 2025
2ab3f59
Refactor ToString procedure to utilize DStrings for improved URL seri…
erno-szabados Jun 25, 2025
faad594
Refactor Parse procedure to use DStrings.String for lastKey managemen…
erno-szabados Jun 25, 2025
d1238ba
Refactor NextToken procedure to utilize state handlers for improved r…
erno-szabados Jun 26, 2025
51409fe
Refactor tokenizer test procedures to use RunTokenizerCase for improv…
erno-szabados Jun 26, 2025
34802c8
Add error case tests to improve robustness of URL tokenizer
erno-szabados Jun 26, 2025
d6a5627
Add DumpToken procedure for improved token debugging in URL parsing
erno-szabados Jun 26, 2025
d8b8b23
Fix HandleStateQuery to correctly handle query start tokens
erno-szabados Jun 26, 2025
c0fdc34
Refactor GetParam, extract NextQueryParam procedure for clarity.
erno-szabados Jun 26, 2025
c9116a2
Implement SetParam procedure to update or create query parameters in URL
erno-szabados Jun 26, 2025
8be5bcd
Comment out DumpToken procedure and its usage for debugging purposes
erno-szabados Jun 26, 2025
a108189
Code cleanup.
erno-szabados Jun 26, 2025
2703851
Add HttpUrl and HttpUrlTokenizer modules with definitions and documen…
erno-szabados Jun 26, 2025
3427c71
Fixed dictionary docs.
erno-szabados Jun 26, 2025
b5062d0
URL module docs update.
erno-szabados Jun 26, 2025
a98f1b1
HTTP Header stub with test stub.
erno-szabados Jun 26, 2025
2f8c2bb
More tests for HttpHeader.
erno-szabados Jun 26, 2025
0dbf385
Enhance HttpHeader module with case-insensitive key retrieval and sto…
erno-szabados Jun 26, 2025
8d11ac4
Implement WriteHeader procedure and enhance ToString test for HTTP he…
erno-szabados Jun 26, 2025
6d4545a
Add WriteHeaderState for header serialization and refactor WriteHeade…
erno-szabados Jun 26, 2025
5fb1dd6
Implement Parse procedure for HTTP header parsing and add correspondi…
erno-szabados Jun 26, 2025
0577d26
Troubleshooting Value writing.
erno-szabados Jun 27, 2025
1769649
Refactor IntKeyAdapter and StringKeyAdapter to fix latent state handl…
erno-szabados Jun 27, 2025
3887767
Add internal procedures for HTTP header parsing and update tests for …
erno-szabados Jun 27, 2025
9ede42e
Update Copilot instructions to clarify return statement rules and res…
erno-szabados Jun 27, 2025
4a72584
Fix ReadLine procedure to use Chars constants for line termination
erno-szabados Jun 27, 2025
bd66aea
Fix TrimLeft procedure to correctly delete characters and add TestTri…
erno-szabados Jun 27, 2025
ea6841b
Initialize DStrings for header values and clean up test output in Htt…
erno-szabados Jun 27, 2025
d77aff2
Add HttpHeader and HttpUrl modules with parsing and manipulation func…
erno-szabados Jun 27, 2025
eceba8c
Add HttpRequest and HttpRequestTest modules with initialization, head…
erno-szabados Jun 27, 2025
8b65d67
HttpRequest and HttpRequestTest.
erno-szabados Jun 27, 2025
055504c
Add TestSetMultilineBody to HttpRequestTest for handling multiline re…
erno-szabados Jun 27, 2025
35ce8fc
HttpResponse and HttpResponseTest module stubs.
erno-szabados Jun 28, 2025
f5d9bc7
Update Copilot instructions to clarify procedure return rules and res…
erno-szabados Jun 28, 2025
a8d4d24
HTTP Response parsing WIP.
erno-szabados Jun 28, 2025
a56ca2c
Update Copilot instructions to clarify handling of escape sequences i…
erno-szabados Jun 28, 2025
b66acc1
Add default error handling in HttpResponse and implement TestParseSta…
erno-szabados Jun 28, 2025
562a72a
Parse WIP in HttpResponse
erno-szabados Jun 28, 2025
5048cd0
Refactor HTTP header parsing to use DStrings.String type in HttpHeade…
erno-szabados Jun 28, 2025
1dad282
Refactor HTTP header and request handling to use updated DStrings.Str…
erno-szabados Jun 28, 2025
158c4c7
Enhance HttpResponse parsing and initialization; ensure safe defaults…
erno-szabados Jun 28, 2025
f9cc499
Add nil checks in HttpHeader procedures to prevent potential derefere…
erno-szabados Jun 28, 2025
99accf0
Add debug output for HTTP response parsing and body retrieval in tests
erno-szabados Jun 28, 2025
a362e8e
Remove unused output statements in HttpResponse and HttpResponseTest …
erno-szabados Jun 28, 2025
f9f947a
Add TODO for header attribute handling and support for chunked transf…
erno-szabados Jun 29, 2025
ccafa70
Add HttpClient and HttpRequest modules stubs with basic functionality…
erno-szabados Jun 29, 2025
1763256
Add instructions for creating C wrappers and Oberon modules with OBNC…
erno-szabados Jun 30, 2025
9af963c
Add SocketDStream and SocketDStreamTest module stubs for buffered soc…
erno-szabados Jun 30, 2025
783aacd
SocketDStream docs update.
erno-szabados Jul 1, 2025
9c33a76
Example DSocket Client WIP.
erno-szabados Jul 2, 2025
985193d
Refactor SocketDStream to use BYTE arrays for data transmission and e…
erno-szabados Jul 4, 2025
a741eb6
Fixes to SocketDStream.
erno-szabados Jul 4, 2025
6f41546
Refactor SocketDStream to improve buffer management and logging durin…
erno-szabados Jul 4, 2025
cadace0
SocketDStream WIP
erno-szabados Jul 5, 2025
eb853d2
SocketDStream WIP
erno-szabados Jul 5, 2025
9469f67
SocketDStream WIP, handle the case when client closes the socket.
erno-szabados Jul 5, 2025
7222868
Socket Client keeps sending until empy line.
erno-szabados Jul 5, 2025
ee0b9ff
Enhance SocketDStream initialization by adding logger parameter for i…
erno-szabados Jul 5, 2025
f0f6252
Add maxBytes parameter to ReadUntil for read size control
erno-szabados Jul 6, 2025
4c33e53
Docs update for SocketDStream.
erno-szabados Jul 6, 2025
37bca93
SocketDStream ReadNBytes test
erno-szabados Jul 7, 2025
4fa0c35
Naming cleanup for socket client example.
erno-szabados Jul 7, 2025
94a5d2e
Add ExampleSocketRecvFixed and ExampleSocketSendFixed for TCP client-…
erno-szabados Jul 7, 2025
d90e290
HttpClient wip.
erno-szabados Jul 7, 2025
ced5862
HttpClient WIP
erno-szabados Jul 7, 2025
e340bf0
HttpClient WIP
erno-szabados Jul 7, 2025
0e24894
Refactor HTTP response parsing procedures for improved clarity and fu…
erno-szabados Jul 7, 2025
d07221a
HttpClient WIP.
erno-szabados Jul 7, 2025
ade424f
Enhance HttpClient and HttpHeader modules with header handling improv…
erno-szabados Jul 7, 2025
97a05db
Enhance HandleReceiving procedure to support Content-Length header pa…
erno-szabados Jul 7, 2025
cfdc353
Enhance HttpClient to include logging and improve response handling f…
erno-szabados Jul 7, 2025
2baeace
Body reading WIP
erno-szabados Jul 7, 2025
22c7159
Refactor HandleReceiving procedure to improve Content-Length handling…
erno-szabados Jul 7, 2025
1436c34
Enhance HttpClient and HttpResponse modules with improved response ha…
erno-szabados Jul 8, 2025
e87d934
Refactor ReadUntil procedure to improve delimiter handling and buffer…
erno-szabados Jul 8, 2025
3c4ac73
Refactor ReadNBytes procedure to improve argument validation and buff…
erno-szabados Jul 8, 2025
1d25cc2
Refactor ReadUntil procedure to prevent draining the buffer when exit…
erno-szabados Jul 8, 2025
e5bf95c
Add ReadUntilClose procedure to SocketDStream for reading until socke…
erno-szabados Jul 8, 2025
a35ec64
Change logger level to DEBUG in ExampleHttpClient for enhanced loggin…
erno-szabados Jul 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
- Open array parameters are allowed as procedure parameters only.
- Function return values **must be handled**.
- Return is only allowed as the last statement in a procedure. Use a `result` variable for returning values.
- No early returns are allowed.
- Forward declarations for procedures are not allowed (only for pointers).
- Early returns are not valid in Oberon-07. EXIT is not a valid oberon keyword.
- Procedure definitions must precede their calls.
- Forward declarations for procedures are not valid in Oberon-07 (only for pointers).
- A situation requiring mutual recursion can be handled by using procedure types to make indirect calls.
- The last statement before an `END` or an `ELSE` **must not end with a semicolon**.
- For bitwise operations, use our own implementation from `Bitwise.mod`.
Expand All @@ -17,11 +18,17 @@
- You cannot substitute a procedure into SYSTEM.VAL(), use a local variable in such cases.
- Oberon-07 reintroduced FOR loops, so **use them instead of WHILE loops where appropriate**.
- There is no enumeration type in oberon 07. use INTEGER.
- Local procedures cannot be passed as procedure variables.
- Oberon does not support escape sequences,
Instead of escape sequences use a combination of a rider-based DStrings write operations
and Chars.CR and similar constants from `Chars.mod`.
- **Best Practices**
- Functions and procedures should be clear, concise, and well-structured.
- Use helper functions to avoid code duplication.
- Use modules to encapsulate functionality. Use opaque pointers to expose necessary types. Hide implementation details.
- Export only what is necessary; keep the interface clean.
- Local procedures (procedures defined inside other procedures) can promote cleaner code organization by grouping related code together.
- Local procedures can make deeply nested code. Use with care.
- Use meaningful names for modules, procedures, and variables.
- Use PascalCase for module names, constants and procedures and camelCase for variables.

Expand All @@ -48,31 +55,3 @@
- Internal procedures documentation comment lines start with `(*` and end with `*)`, so they are not included in the API documentation.
- The header should contain a copyright notice for the 3 clause BSD license, the module name, a brief description, and the author.
- Be conservative and factual in documentation statements, do not exaggerate.

## Creating C wrappers

1. Create a file named M.obn with the the exported declarations.
Proper Procedures should have empty bodies to satisfy syntax requirements.
Example: `PROCEDURE MyProc; BEGIN END MyProc;`
Function procedures should have a dummy return value to satisfy syntax requirements.
Example: `PROCEDURE MyFunc() : BOOLEAN; BEGIN RETURN TRUE END MyFunc;`

2. Create a file named MTest.obn which imports M (and preferably write
unit tests for M)
3. Build MTest with the command
obnc MTest.obn
4. Copy the generated file .obnc/M.c to the current directory. In M.c,
delete the generator comment on the first line.
5. Copy the generated file .obnc/M.h to the current directory.
6. Implement M.c. Update M.h as needed.

### Notes on C Wrappers

1. The initialization function M__Init is called each time a client
module imports M. Its statements should therefore be guarded with an
initialization flag to make sure they are executed only once.
2. To use pointers to C structures, declare INTEGERS in oberon,
OBNC_INTEGER is 32-bit, Oberon has no way to represent 64-bit integers.
Therefore you have to update the generated code: the relevant casts should be revised,
and uintptr_t should be used instead of OBNC_INTEGER.
This works as long as there is no direct access to the structure fields from Oberon code.
31 changes: 31 additions & 0 deletions .github/instructions/CreateOberonCWrapper.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
applyTo: '*.c;*.h;*.obn'
---

## Creating C wrappers

1. Create a file named M.obn with the the exported declarations.
Proper Procedures should have empty bodies to satisfy syntax requirements.
Example: `PROCEDURE MyProc; BEGIN END MyProc;`
Function procedures should have a dummy return value to satisfy syntax requirements.
Example: `PROCEDURE MyFunc() : BOOLEAN; BEGIN RETURN TRUE END MyFunc;`

2. Create a file named MTest.obn which imports M (and preferably write
unit tests for M)
3. Build MTest with the command
obnc MTest.obn
4. Copy the generated file .obnc/M.c to the current directory. In M.c,
delete the generator comment on the first line.
5. Copy the generated file .obnc/M.h to the current directory.
6. Implement M.c. Update M.h as needed.

### Notes on C Wrappers

1. The initialization function M__Init is called each time a client
module imports M. Its statements should therefore be guarded with an
initialization flag to make sure they are executed only once.
2. To use pointers to C structures, declare INTEGERS in oberon,
OBNC_INTEGER is 32-bit, Oberon has no way to represent 64-bit integers.
Therefore you have to update the generated code: the relevant casts should be revised,
and uintptr_t should be used instead of OBNC_INTEGER.
This works as long as there is no direct access to the structure fields from Oberon code.
58 changes: 58 additions & 0 deletions .github/instructions/NewOberonModuleCreationOBNC.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
applyTo: '*.Mod'
---
## Creating Oberon Modules with OBNC compiler

Create a minimal stub with the opaque type and empty procedures.
Every procedure should have a body, even if it is empty, to satisfy the syntax requirements of the Oberon-07 language.
Create a minimal test module that imports the new module.
The makefile discovers the module and you can compile it with

`make MyModuleTest`

### Minimal Test Example:

```Oberon-07
(** MyModuleTest.Mod - Tests for MyModule.Mod.

Copyright (C) 2025 Artemis Project Contributors

Released under The 3-Clause BSD License.
*)
MODULE MyModuleTest;
IMPORT MyModule, Tests;

VAR
ts: Tests.TestSet;

PROCEDURE TestExample(): BOOLEAN;
VAR
pass: BOOLEAN; (* Other variable declarations*)
BEGIN
pass := TRUE;

(* Perform the test *)

Tests.ExpectedBool(TRUE, MyModule.MyFunc(), "MyModule.MyFunc() pass", pass)

RETURN pass
END TestExample;

(* Other testcases as needed. *)

BEGIN
Tests.Init(ts, "Example Tests");
Tests.Add(ts, TestExample);

ASSERT(Tests.Run(ts));
END MyModuleTest.

```

### Best practices

- Use modules to encapsulate functionality. Use opaque pointers to expose necessary types. Hide implementation details.
- Export only what is necessary; keep the interface clean.
- Local procedures (procedures defined inside other procedures) can promote cleaner code organization by grouping related code together.
- Local procedures can make deeply nested code. Use with care.

8 changes: 4 additions & 4 deletions DStrings.Mod
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ BEGIN
c := Get(r); INC(l);
END;
IF l > 0 THEN
Delete(source, 0, (l - 1));
Delete(source, 0, l);
END;
END TrimLeft;

Expand Down Expand Up @@ -860,9 +860,9 @@ END WriteString;
PROCEDURE WriteDString*(VAR r : Rider; source : String);
VAR c : CHAR; s : Rider;
BEGIN
Set(s, source, 0); c := Get(r);
Set(s, source, 0); c := Get(s);
WHILE c # 0X DO
Put(s, c); c := Get(r);
Put(r, c); c := Get(s);
END;
END WriteDString;

Expand Down Expand Up @@ -936,7 +936,7 @@ BEGIN
END WriteSet;

(**WriteFixed writes a renumber with a fixed number of decimal places
to a string. E.g. write out dollar ammounts as 1.32 rather then E
to a string. E.g. write out dollar amounts as 1.32 rather then E
notation *)
PROCEDURE WriteFixed*(VAR r : Rider; value : REAL; n : INTEGER);
VAR tmp : ARRAY 64 OF CHAR; ok : BOOLEAN;
Expand Down
12 changes: 12 additions & 0 deletions DStringsTest.Mod
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,17 @@ BEGIN test := TRUE;
RETURN test
END TestWriteProcs;

PROCEDURE TestTrimSpace() : BOOLEAN;
VAR test: BOOLEAN; s, expected: DStrings.String;
BEGIN
test := TRUE;
DStrings.Init(" hello world ", s);
DStrings.Init("hello world", expected);
DStrings.TrimSpace(s);
ExpectedDString(expected, s, "TrimSpace(' hello world ')", test);
RETURN test
END TestTrimSpace;

BEGIN
T.Init(ts, "Test DStrings");
T.Add(ts,TestInit);
Expand All @@ -535,6 +546,7 @@ BEGIN
T.Add(ts,TestReplace);
T.Add(ts,TestCap);
T.Add(ts,TestStartsWith);
T.Add(ts,TestTrimSpace);

(* Test the Files base procedures *)
T.Add(ts,TestReadProcs);
Expand Down
8 changes: 2 additions & 6 deletions Dictionary.Mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@ VAR
intKey: CollectionKeys.IntegerKeyPtr;
key: INTEGER;
value: Collections.ItemPtr;
dictState: DictVisitorState;
result: BOOLEAN;
BEGIN
pair := item(HashMap.KeyValuePairPtr);
keyPtr := HashMap.PairKey(pair);
intKey := keyPtr(CollectionKeys.IntegerKeyPtr);
key := intKey.value;
value := HashMap.PairValue(pair);
dictState := state(DictVisitorState);
result := dictState.intVisitor(key, value, state);
result := state(DictVisitorState).intVisitor(key, value, state);
RETURN result
END IntKeyAdapter;

Expand All @@ -54,15 +52,13 @@ VAR
keyPtr: CollectionKeys.KeyPtr;
strKey: CollectionKeys.StringKeyPtr;
value: Collections.ItemPtr;
dictState: DictVisitorState;
result: BOOLEAN;
BEGIN
pair := item(HashMap.KeyValuePairPtr);
keyPtr := HashMap.PairKey(pair);
strKey := keyPtr(CollectionKeys.StringKeyPtr);
value := HashMap.PairValue(pair);
dictState := state(DictVisitorState);
result := dictState.stringVisitor(strKey.value, value, state);
result := state(DictVisitorState).stringVisitor(strKey.value, value, state);
RETURN result
END StringKeyAdapter;

Expand Down
Loading