[NTLK] Developer news...
Matthias Melcher
m.melcher at robowerk.de
Tue Mar 10 18:28:08 EDT 2020
> On Mar 10, 2020, at 02:46, Steven Frank via NewtonTalk <newtontalk at newtontalk.net> wrote:
>
>
>> On Mar 9, 2020, at 4:50 PM, Jake Bordens <jake at allaboutjake.com> wrote:
>>
>> Awesome. My Inspector replacement was limited to 32-bit but if Newt64 is viable it should be an easy replacement. (https://github.com/jake-b/NewtonInspector)
>
> (chanting) Do it, do it!
[joining in]
> So, my next question in all this is what is the process for implementing NOS system calls?
Any NewtonScript function can call native code. The Frame needs to look like this:
SomeCall := {
class: 'NativeFunc,
funcPtr: <address of "C" function>,
numArgs: 1
};
where funcPtr is the address of the function in 64 bit, shifted right by 2. The compiler should shift the value back and be a 4-byte aligned pointer again. You saw the shifting already in your newt64 test. NewtonScript uses the last two bit in immediate data to indicate what type of data it is. 00 indicates an integer, and the remaining 30 bit (62 bits) then hold the signed integer value (whic h is why we have the y10k problem, as seconds-since-decade are store in 30 bits only). Newt64 may not be able to set a 62 bit integer correctly from script yet.
> For example, what would be a minimally viable NewtonScript to open a view or a window, and how do we create a binding for that in Newt64 so it does something on the host system when it runs?
It's probably a bit more complicated than that. But lemme try:
A minimal app for NOS 2.1 looks like this:
tmp0001 :=
{title: "Application",
viewBounds: {left: 0, top: 26, right: 188, bottom: 310},
viewFormat: 83951953,
_proto: @157 /* protoApp */
};
constant |layout_test.lyt| := tmp0001;
You need to add some frames around that to make a .pkg file with newt/0 or NTK on BasiliskII. Then the package is installed on the device, which means that it is copied into a Soup in Flash memory.
To launch that package, you call, um, Launch(), but I don't know any more details (which proto, what arguments) yet.
Launch() calls LookupSoupPackageAndActivate(). Activation in this case means, that the view structure is taken from the package and pretty much cloned as a slot in the main view (GetRoot()). In the cloning process, child views are made into stepChild views and a few other things to "instantiate" the app.
Then, NewtonOS class GetRoot().|Test:SIG|.Open(); which in turn calls |Test:SIG|.viewSetupFormScript() on the view and all children, and some other callbacks, until the view is finally set up. It's then marked "dirty" and one of the following idle functions will look through all views that are derity and call their viewDrawScript().
Similarly, if a touch event happens, NewtonOS calls the appropriate Script for the view that receives the event.
A lot of that can be traced using the Inspector in NTK. Here is the NewtonScript call trace for clicking into the Extras Drawer to launch my test application:
(#C63B309):Launch()
(#C63A8E9):TapAction()
(#C63A8E9):LookupSoupPackageAndActivate()
(#C63A8E9):LookupSoupPackage()
(#C63A8E9):store()
IsSoupEntry(#C6102FD)
=> TRUE
EntryStore(#C6102FD)
=> #C606875
=> #C606875
GetPackageEntry(#C63DF2D, #C606875)
(#C606875):GetSoup(#5A74D1)
=> #C609265
(#C609265):Query(#C63E049)
=> #C63E145
(#C63E145):entry()
=> #C60F2B9
=> #C60F2B9
=> #C60F2B9
not(#C60F2B9)
=> NIL
SetContains(#C6104E9, #C60F229)
=> 5
=> alreadyActive
(#C6102FD):TapAction()
=> NIL
GetRoot()
=> #C610365
(#C63A8E9):_Open(#C61034D)
not(NIL)
=> TRUE
GetUserConfig(ExtraAlwaysClose)
=> TRUE
AddDeferredSend(#C61034D, ButtonToggle, NIL)
=> TRUE
=> TRUE
=> TRUE
(#C60E5B9):Close()
(#C60B3E9):viewDrawScript()
not(TRUE)
=> NIL
=> NIL
(#C60B8B9):viewDrawScript()
(#C60B8B9):LocalBox()
=> #C63E441
-(480, 2)
=> 478
MakeRect(2, 4, 478, 6)
=> #C63E45D
(#C60B8B9):DrawShape(#C63E45D, NIL)
=> NIL
=> NIL
(#C60BA9D):viewDrawScript()
(#C60BA9D):LocalBox()
=> #C63E471
MakeShape(#94B)
=> #C63E4A1
-(13, 5)
=> 8
>>(8, 1)
=> 4
OffsetShape(#C63E4A1, 1, 4)
=> #C63E4A1
(#C60BA9D):DrawShape(#C63E4A1, #4296D5)
=> NIL
=> NIL
(#C60E5B9):viewQuitScript()
UnRegFolderChanged(ExtrasDrawer)
RemoveSlot(#C611619, ExtrasDrawer)
=> #C611619
=> NIL
UnRegStoreChange(ExtrasDrawer)
RemoveSlot(#C60E729, ExtrasDrawer)
=> #C60E729
=> NIL
=> NIL
(#C6365E9):viewQuitScript()
UnRegFolderChanged(|showBar.52017896|)
RemoveSlot(#C611619, |showBar.52017896|)
=> #C611619
=> NIL
=> NIL
(#C636601):viewQuitScript()
not(NIL)
=> TRUE
UnRegUserConfigChange(|VolumeSlider.52018552|)
RemoveSlot(#C611655, |VolumeSlider.52018552|)
=> #C611655
=> NIL
=> NIL
(#C63B801):viewQuitScript()
=> NIL
(#C63BBE9):viewQuitScript()
SetRemove(#C611669, #C63BBE9)
=> #C611669
=> NIL
(#C63BC01):viewQuitScript()
(#C63BC01):viewQuitScript()
=> NIL
=> NIL
(#C63BC19):viewQuitScript()
(#C63BC19):viewQuitScript()
=> NIL
=> NIL
(#C63BC31):viewQuitScript()
(#C63BC31):viewQuitScript()
=> NIL
=> NIL
=> TRUE
=> NIL
(#C61034D):ButtonToggle()
not(NIL)
=> TRUE
GetRoot()
=> #C610365
(#C610365):ChildViewFrames()
=> #C63E4C1
=> 2
-(2, 1)
=> 1
aref(#C63E4C1, 1)
=> #C60AA65
GetViewFlags(#C60AA65)
=> 2561
=(0, 0)
=> TRUE
aref(#C63E4C1, 1)
=> #C60AA65
(#C61034D):buttonToggleScript(#C60AA65)
=> NIL
Visible(#C61034D)
GetViewFlags(#C61034D)
=> 0
=> 0
<>(0, 0)
=> NIL
(#C61034D):Toggle()
not(NIL)
=> TRUE
(#C61034D):Open()
=> NIL
(#C61034D):_Open()
(#C61034D):viewSetupFormScript()
BreakLoop()
Entering break loop: level 1
More information about the NewtonTalk
mailing list