-
Content Count
83 -
Joined
-
Last visited
-
Days Won
3
Posts posted by Ondrej Kelle
-
-
Your fix looks fine to me. Apart from the var parameter declaration the rest should be the same. Pass it the form's Handle (like in my example, I'm passing it Self.Handle where Self is the instance of the form).
Good luck with the Dentist! 😉
-
18 hours ago, Ondrej Kelle said:Node comes with a huge online ecosystem of Javascript modules
...just came across this visualisation. 🙂
-
GetMenuBarInfo API should help.
I have no Delphi at hand at the moment but the following quick test works in Lazarus:
function GetWindowMenuItemRect(Handle: THandle; Index: Integer): TRect; var Info: MENUBARINFO; begin FillChar(Info, SizeOf(Info), 0); Info.cbSize := SizeOf(Info); Win32Check(GetMenuBarInfo(Handle, $FFFFFFFD, Index, @Info)); Result := Info.rcBar; end; function GetScreenCanvas: TCanvas; begin Result := TCanvas.Create; try Result.Handle := GetDC(0); Result.Pen.Style := psSolid; Result.Pen.Color := clRed; Result.Brush.Style := bsClear; except Result.Free; raise; end; end; procedure TForm1.Button1Click(Sender: TObject); var C: TCanvas; I: Integer; begin C := GetScreenCanvas; try for I := 0 to MainMenu1.Items.Count - 1 do C.Rectangle(GetWindowMenuItemRect(Handle, I + 1)); finally C.Free; end; end;
-
2 hours ago, Rollo62 said:I considered Node as a small excutable wrapper (a main loop if you will) around the V8 engine, and all the rest done by additional JS modules.
There's a lot implemented natively:
C:\>node --version v11.0.0 C:\>node > require('module').builtinModules [ 'async_hooks', 'assert', 'buffer', 'child_process', 'console', 'constants', 'crypto', 'cluster', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'http2', '_http_agent', '_http_client', '_http_common', '_http_incoming', '_http_outgoing', '_http_server', 'https', 'inspector', 'module', 'net', 'os', 'path', 'perf_hooks', 'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', '_stream_readable', '_stream_writable', '_stream_duplex', '_stream_transform', '_stream_passthrough', '_stream_wrap', 'string_decoder', 'sys', 'timers', 'tls', '_tls_common', '_tls_wrap', 'trace_events', 'tty', 'url', 'util', 'v8', 'vm', 'zlib', 'v8/tools/splaytree', 'v8/tools/codemap', 'v8/tools/consarray', 'v8/tools/csvparser', 'v8/tools/profile', 'v8/tools/profile_view', 'v8/tools/logreader', 'v8/tools/arguments', 'v8/tools/tickprocessor', 'v8/tools/SourceMap', 'v8/tools/tickprocessor-driver', 'node-inspect/lib/_inspect', 'node-inspect/lib/internal/inspect_client', 'node-inspect/lib/internal/inspect_repl' ] >
I believe (most of) those things are compiled and linked directly into Node executable as native code.
2 hours ago, Rollo62 said:the question would be if there is any advantage of such ChakraCode-Node over V8-Node ?
I'm not sure. It does seem like a lot of work.
-
ChakraCore is a Javascript (and WebAssembly) engine, comparable to Google's V8, Mozilla's SpiderMonkey or other similar implementations.
Node.js is much more - a runtime host environment (native executable for the target platform) embedding V8, it implements some (native code) services and exposes them to the engine through an API. For example, you can instantiate a simple web server from Javascript run by Node as described here.
There's also Node.js on ChakraCore, a fork of Node, using ChakraCore instead of V8 (by providing a V8 API shim layer and delegating to the ChakraCore engine).
Node comes with a huge online ecosystem of Javascript modules and a package manager (npm) to manage the dependencies.
Node modules can reuse other modules through an established ("require") method - you could think of it as Node's runtime equivalent of Delphi's "uses" clause in Javascript.
My example shows a way to implement this "require" mechanism in a Delphi or Free Pascal host application, reading npm's "package.json" files where the module metadata is declared and resolving the "require" clauses to full-path file names so they can be loaded and evaluated at runtime with ChakraCore. It doesn't provide any of Node's extra services, so modules relying on them won't work. For example, an attempt to call require('http'); from a script will raise an exception since my host application doesn't provide the "http" module and the implementation of its API (which could be done with some extra work, e.g. using Indy).
A hint on how one might provide those services to the engine can be found in the NodeProcess unit which is an incomplete stub implementation of the 'process' module (I just wanted to satisfy graphql for the demo).
- 1
-
https://tondrej.blogspot.com/2019/01/node-modules-with-delphi-and-free-pascal.html
chakracore-delphi now comes with NodeSample, a new sample console application showing (as of now very limited) support for Node modules. Included are:
- commonmark
- graphql
- json-query
- lodash
- momentThe sample only shows how Node modules can be resolved and used in Delphi and Free Pascal applications. It doesn't implement Node's event loop or any of its internal modules or native bindings like path, fs or http; any scripts referencing them will - for now - raise an exception.
Screencast (YouTube)
- 1
-
11 minutes ago, Steve Maughan said:How to get access to quality.embarcadero.com?
-
1 hour ago, Rollo62 said:Thanks for the nice project.
Sorry, I don't want to be negative, but do you know more about the future of ChakraCore ?
Since Edge browser has moved to Chromium, this is probably a not too bright future.
I would not try to launch big projects based on ChakraCore any longer.Thanks, I'm glad you like it.
Of course, what the move to Chromium really means in practice remains to be seen.
For now, ChakraCore still seems to be active, with bug fixes and new features, too. Quoting from their statement:
QuoteChakraCore is currently being used in various projects outside the browser. So, despite the change of direction for Microsoft Edge, our team will continue supporting ChakraCore. We will ensure that any security vulnerability is patched in a timely manner, apart from bringing other enhancements to the engine. The project will also continue taking public contributions.
As far as I know, ChakraCore is used in:
Node-ChakraCore (e.g. also on Windows 10 IoT Core)
Azure DocumentDb (not sure about CosmosDb)
Outlook.com
Cortana
-
https://tondrej.blogspot.com/2019/01/webassembly-with-delphi-and-chakracore.html
chakracore-delphi now contains WasmSample, a new sample project using ChakraCore to load and run a WebAssembly module (in this case, an implementation of Conway's Game of Life).
It's based on Colin Eberhardt's blog post Writing WebAssembly By Hand (you can run the code in your browser here).
-
40 minutes ago, ertank said:I appreciate a sign in link, please.
According to https://quality.embarcadero.com/secure/Dashboard.jspa you can "create an EDN account or recover your login credentials" at https://members.embarcadero.com/newuser.aspx
-
On 12/30/2018 at 1:35 PM, Ondrej Kelle said:produces no warnings, no hints for me with 10.3 Tokyo.
I meant 10.3 Rio, sorry. 🙂
-
5 minutes ago, Berocoder said:Ok so basically it is not possible to have direct references in both directions between two classes if they are stored in separate units...
That's correct.
-
The following
function HasCheckedSubItems(AMenuItem: TMenuItem): Boolean; var I: integer; begin Result := False; for I := 0 to AMenuItem.Count - 1 do if AMenuItem.Items[I].Checked then begin Result := True; Exit; end; end;
produces no warnings, no hints for me with 10.3 Tokyo.
- 1
-
The scope of a forward declaration is the type declaration section (typically the unit, or the enclosing type declaration section of a nested class). If the classes directly reference each other you'll have to put them in the same declaration section (unit or enclosing type).
There are workarounds, depending on what you need. For example, you could reference a generic ancestor (e.g. TTestBase, or even TObject) in the interface section, and typecast to the actual class in implementation, or use polymorphism. Circular unit references in the implementation section are allowed.
-
3 hours ago, dummzeuch said:The "Console in ..." entries don't work for me. I had to add a /d to the cd command:
e.g. Parameters: /k cd /d $PATH($EDNAME)
because my sources are on a different drive.
Sure. Also, enclose the path in quotes if it contains spaces.
-
FillChar expects a byte value as the last paramater. You're filling a memory block with byte value 4 and your results show it (67372036 decimal is $04040404).
- 1
-
FWIW, as a workaround I use external tool setting (to launch explorer to show the current editor file).
- 2
-
Your memories might have been about delphisvn (now outdated and abandoned).
"RAD Studio Version Insight" and "RAD Studio Version Insight Plus" developed further, try searching for a recent/maintained fork.
-
On 11/5/2018 at 7:01 AM, Tommi Prami said:Any idea where that saves the info, Registry maybe?
The info is stored in .dct files:
https://stackoverflow.com/questions/38672329/how-to-restore-or-copy-component-templates
- 2
- 1
-
I've just pushed some updates to chakracore-delphi.
A new feature worth mentioning is support for inheritance (I mean Javascript-style, "prototypical inheritance") in both directions. Suppose the following hierarchy:https://tondrej.blogspot.com/2018/11/inheritance-with-chakracore-delphi.html
- 1
-
Great idea!
How to get position of Top-level TMenuItem of Main menu
in Windows API
Posted · Edited by Ondrej Kelle
I've checked it with Delphi XE. The declaration of TMenuBarInfo in Windows unit seems to be wrong (packed record, 29 bytes). Simply redeclare it in your unit:
which makes the record size 32 bytes, then it works:
BTW, it's already fixed in Rio.