Commit graph

8593 commits

Author SHA1 Message Date
Andreas Kling
2b7fc08db3 Documentation: Add section about structs vs. classes to CodingStyle.md 2020-04-18 11:14:05 +02:00
Andreas Kling
30de1f610d LibJS: Use enumerator macro to mark all constructors in GlobalObject
We were forgetting to mark the String constructor! So this patch fixes
that and ensures we won't forget anyone in the future.
2020-04-18 11:02:05 +02:00
Andreas Kling
bc1ece7f37 LibJS+LibWeb: Pass prototype to Object constructor
Everyone who constructs an Object must now pass a prototype object when
applicable. There's still a fair amount of code that passes something
fetched from the Interpreter, but this brings us closer to being able
to detach prototypes from Interpreter eventually.
2020-04-18 11:00:55 +02:00
Andreas Kling
f6d57c82f6 LibJS: Pass prototype to Function constructors 2020-04-18 10:28:22 +02:00
Andreas Kling
205ac0090d LibJS: Pass prototype to Error constructors 2020-04-18 10:28:22 +02:00
Andreas Kling
0df4d2823a LibJS: Pass prototype to Date constructor 2020-04-18 10:28:22 +02:00
Andreas Kling
2a15323029 LibJS: Pass prototype to BooleanObject constructor 2020-04-18 10:28:22 +02:00
Andreas Kling
298c606200 LibJS: Pass prototype to StringObject constructor 2020-04-18 10:28:22 +02:00
Andreas Kling
cf702a13b9 LibJS: Pass prototype to NumberObject constructor 2020-04-18 10:28:22 +02:00
Andreas Kling
2d7b495244 LibJS: Make Array constructor take its prototype
Let's start moving towards native JS objects taking their prototype as
a constructor argument.

This will eventually allow us to move prototypes off of Interpreter and
into GlobalObject.
2020-04-18 10:28:22 +02:00
Read H
ee5816b9c8 LibC: getprotoent() family of functions
This commit implements the getprotoent() family of functions, including

getprotoent()
getprotobyname()
getprotobynumber()
setprotoent()
endprotoent()

This implementation is very similar to the getservent family of functions,
which is what led to the discovery of a bug in the process of reading the aliases.
The ByteBuffer for the alias strings didn't include a null terminating character,
this was fixed for both the protoent and servent family of functions by appending a
null character to the end of them before adding them to the alias lists.
2020-04-18 10:11:55 +02:00
Read H
0ef2efac7c Base files: Add protocols file
This commit adds the standard /etc/protocols file to
the base files to be used by netdb's protoent family of functions.
2020-04-18 10:11:55 +02:00
Kesse Jones
4931c0feda LibJS: Add Array.prototype.concat 2020-04-17 16:14:28 +02:00
Stephan Unverwerth
63e1ea7819
LibJS: Add test for semicolon insertion (#1828) 2020-04-17 15:52:38 +02:00
Stephan Unverwerth
19cdda8000 LibJS: Fix semicolon insertion 2020-04-17 15:32:20 +02:00
Stephan Unverwerth
07f838dc4e LibJS: Implement automatic semicolon insertion 2020-04-17 15:22:31 +02:00
Stephan Unverwerth
b77ceecb02 AK: Add StringView::contains(char) 2020-04-17 15:22:31 +02:00
Nick Tiberi
1f6578ee0a LibWeb: Implement JS confirm() 2020-04-17 13:41:03 +02:00
Brendan Coles
0a483cf677 ProtocolServer: did_finish_download: Do not create 0 byte shared buffer
`PSClientConnection::did_finish_download()` no longer tries to create
a zero byte shared buffer when `download.payload().data()` is zero
bytes in length.

Fixes #1821
2020-04-17 13:30:13 +02:00
Andreas Kling
d5fb916bf0 LibWeb: Implement CanvasRenderingContext2D::stroke_rect() with lines
Stroking rects by drawing individual lines gives us line width support
without having to extend the Painter::draw_rect() code. :^)
2020-04-16 21:12:14 +02:00
Andreas Kling
ecd900b4b4 LibGfx: Add FloatPoint::to_int_point() 2020-04-16 21:11:13 +02:00
Andreas Kling
0d93e249c3 LibWeb: Add some basic path drawing functionality to the canvas element
This patch adds the following methods to CanvasRenderingContext2D:

- beginPath()
- moveTo(x, y)
- lineTo(x, y)
- closePath()
- stroke()

We also add the lineWidth property. :^)
2020-04-16 21:06:03 +02:00
Andreas Kling
60c2e41079 LibGfx: Add Gfx::Path, a basic 2D path with <canvas> semantics
This will be used to implement painting of 2D paths. This first patch
adds support for line_to(), move_to() and close().

It will try to have the same semantics as the HTML <canvas> element.

To stroke a Path, simply pass it to Painter::stroke_path().
2020-04-16 21:04:46 +02:00
Andreas Kling
72df9c7417 LibJS: Dump a JavaScript backtrace when throwing exceptions 2020-04-16 20:23:03 +02:00
Andreas Kling
2db2b8b0ef AK: Add FlyString::is_empty() 2020-04-16 20:22:54 +02:00
Andreas Kling
905519bc76 Kernel: Fix dumb logic typo in HardwareTimer::handle_irq() 2020-04-16 18:53:38 +02:00
Andreas Kling
c891c87cb5 Kernel: Rename HardwareTimer::change_function() => set_callback()
Also make it non-virtual since nothing needs to override it.
2020-04-16 18:51:39 +02:00
Andreas Kling
b035267afa Kernel: Remove "stale callback" concept from time management
If a hardware timer doesn't have a callback registered, it's now simply
represented by a null m_callback.
2020-04-16 18:50:22 +02:00
Andreas Kling
4b1f056e3a Kernel: Rename HardwareTimer::m_function_to_call => m_callback 2020-04-16 18:49:20 +02:00
Andreas Kling
1e89f7d64e Kernel: Remove an unnecessary indirection between timer and scheduler
We don't need a wrapper Function object that just forwards the timer
callback to the scheduler tick function. It already has the same
signature, so we can just plug it in directly. :^)

Same with the clock updating function.
2020-04-16 18:49:20 +02:00
Andreas Kling
44d58b85ef Kernel: Simplify the way we pass HardwareTimers around a bit
Instead of passing around indices into the m_hardware_timers vector,
just pass around a HardwareTimer* instead.
2020-04-16 18:49:20 +02:00
Kesse Jones
b0b204822f LibJS: Add String.prototype.substring 2020-04-16 18:47:24 +02:00
Andreas Kling
60d1ef6af4 LibJS: Remove no-op code in ScriptFunction constructor 2020-04-16 16:58:44 +02:00
Andreas Kling
6833004a45 js: Tweak the live syntax highlighting colors a bit 2020-04-16 16:37:32 +02:00
Kesse Jones
7725b1970e LibJS: Add String.prototype.concat 2020-04-16 16:36:51 +02:00
Andreas Kling
e72a537033 LibJS: Make Value::m_type default to Type::Empty
This is not effectful since all constructors overwrite the type anyway,
but it seems reasonable that the default value of m_type would match
what Value() would give you.
2020-04-16 16:11:11 +02:00
Andreas Kling
1b391d78ae LibJS: Allow cells to mark null pointers
This simplifies the cell visiting functions by letting them not worry
about the pointers they pass to the visitor being null.
2020-04-16 16:10:38 +02:00
Read H
1f4e3dd073 LibC netdb: Requested Changes
fix all requested changes including:

- remove explicit vector initialization
- change keep_service_file_open to boolean
- closing service file on seek error
- change C level char allocation to use ByteBuffer instead
- simplified getservby* loops to a single loop
- change fill_getserv_buffers return to early-return style
2020-04-16 15:55:45 +02:00
Read H
844e5faf84 LibC: Service entry API
This commit implements the getservent family of functions:
getservent()
setservent()
endservent()
getservbyname()
getservbyport()

for accessing the /etc/services file.

This commit has addressed the issues identified by utilizing more C++ structures,
addressing unchecked error possibilities, strncpy bounds checking, and other issues
found in the initial pull request
2020-04-16 15:55:45 +02:00
Read H
ce572c9cb5 Base Files: Add services file.
Adding the services database file to /etc/services. This is the most
common location for this file in *nix systems.
2020-04-16 15:55:45 +02:00
Jack Byrne
f65c55791e LibWeb: Scroll back to the top when a new page is loaded 2020-04-16 14:13:03 +02:00
Itamar
1642fdf82d Debugger: Use LibLine 2020-04-16 12:22:59 +02:00
Itamar
ef6dc61291 functrace: Log syscalls 2020-04-16 11:17:33 +02:00
Itamar
af338a34c0 LibDebug: Add ContinueBreakAtSyscall decision
When the user of the DebugSession uses this decision, the debugged
program will be continued until it is either stopped by a singal (e.g
as a reuslt of a breakpoint), or enters a syscall.
2020-04-16 11:17:33 +02:00
Itamar
f4418361c4 Userland: Add "functrace" utility
functrace traces the function calls a program makes.
It's like strace, but for userspace.

It works by using Debugging functionality to insert breakpoints
at call&ret instructions.
2020-04-16 11:17:33 +02:00
Andreas Kling
13865c7c3d LibJS: Remove unreachable code in Interpreter::enter_scope()
Functions are handled and short-circuited at the head of enter_scope().
2020-04-16 10:25:00 +02:00
Andreas Kling
9b9086dcf0 LibJS: Oops, fix StringPrototype build 2020-04-16 10:24:32 +02:00
Andreas Kling
1108dd1659 LibJS: Add some missing |this| checks in StringPrototype
Also some style tweaks
2020-04-16 10:04:21 +02:00
Linus Groh
9eb9b46640 LibWeb: Support alert() with no arguments
No idea why someone would use that though.
2020-04-16 09:45:39 +02:00
Linus Groh
640a24dce8 LibJS: Remove outdated FIXME now that we have lexical environments 2020-04-16 09:41:07 +02:00