News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Continuation-passing-style

Started by LiaoMi, September 02, 2016, 10:55:04 PM

Previous topic - Next topic

LiaoMi

Hallo,

learning algorithms I came across this interesting library - Continuation-passing-style (CPS) in C

You can read about it in Wikipedia - https://en.wikipedia.org/wiki/Continuation-passing_style
The library is located here - https://github.com/redjack/copse

Unfortunately I could not make the library, I would like to translate this code to assembler, interesting point is that the some part of the procedure already been written in assembly language for various systems, including windows. Here is an example of these procedures - copse-develop\src\libcopse\context

My stupid question looks like, how to build this library ?!  :redface:

GoneFishing


K_F

Sounds more like a run-away COM object code, something similar to a 'COM Cancer virus', if the recursive calling loop goes for a 'ball of turkey'

I thought it sounded more like a different Artificial Intelligence, maybe it is in a way, that can replicate itself - but this is in itself it's own problem.
:biggrin:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

CPS seems just another word for "callback". Whether that is efficient is another question: the examples at Wikipedia seem much more complicated than the "direct" old-fashioned style we are practicing here...

When the first CPS version of MS Office comes out, I'll have a closer look.

LiaoMi

Quote from: GoneFishing on September 02, 2016, 11:07:35 PM
Looks like library uses  CMAKE build system .

Unfortunately, this method does not help me  ::) I have tried by yourself to make the assembled kit, with Visual Studio 14 compiler. I am sure that I correctly added all the header files, but I get an error.

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'copse\cps.h': No such file or directory cpss E:\DATA\Continuation-passing-style\copse-develop\src\libcopse\round-robin.c 13
Error (active) cannot open source file "core.h" cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 11
Error (active) cannot open source file "context.h" cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 12
Error (active) cannot open source file "cps.h" cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 13
Error (active) cannot open source file "fiber.h" cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 14
Error (active) identifier "cork_free_f" is undefined cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 31
Error (active) identifier "cps_fiber_f" is undefined cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 32
Error (active) incomplete type is not allowed cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 35
Error (active) identifier "true" is undefined cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 48
Error (active) identifier "true" is undefined cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 60
Error (active) expected an expression cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 79
Error (active) identifier "cork_free_f" is undefined cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 83
Error (active) identifier "cps_fiber_f" is undefined cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 83
Error (active) expected an expression cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 86
Error (active) identifier "true" is undefined cpss e:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 125
Error C1083 Cannot open include file: 'core.h': No such file or directory cpss E:\DATA\Continuation-passing-style\copse-develop\src\libcopse\context.c 12
Error C1083 Cannot open include file: 'core.h': No such file or directory cpss E:\DATA\Continuation-passing-style\copse-develop\src\libcopse\cps.c 10
Error C1083 Cannot open include file: 'core.h': No such file or directory cpss E:\DATA\Continuation-passing-style\copse-develop\src\libcopse\fiber.c 11


http://www.file-upload.net/download-11927674/src.zip.html

How can I add files to a universal way?

GoneFishing

Quote from: LiaoMi on September 11, 2016, 11:04:32 PM
...
Unfortunately, this method does not help me  ::)
...

Contact the author of the library

GuruSR

Just a thought, the CreateProcess that you're doing to create the Wordpad, are you defining the security section (not looked at your code) to include the inherit?  If not, the process will not inherit the current thread's permissions and your code won't have "full rights" to talk to the Wordpad Application.  I have seen that done before (long time ago I actually did the similar with the same results).  One of the things you need to do is once you have the parenting done:

Filter all the default window messages from Wordpad, relating to resizing, maximizing, hiding, etc.  Those you should handle yourself by telling the window itself to hide, show, minimize or maximize, resizing should be done yourself as well.  If the window is maximized, you need to make it redraw itself to the new size on your windows main redraw message.  You can't maximize a window and resize it later, at least thats not the sane way to do it, doing a maximized window (child) and telling it to resize by passing the message through to it, is doomed to cause resize loop, lockup and crash. :dazzled:

Most importantly, the security needs to inherit on that CreateProcess otherwise some window functions will be blocked by the UAC.  And now that I think about this, there was a tutorial somewhere about actually putting Wordpad into another window, was wondering why this sounded familiar, perhaps google Wordpad in your app.

Had a thought (I'm procrastinating on sifting through log data, I know, I'll do it in the morning), WordPad isn't going to make a proper MDI child, create an MDI child for it and SetParent Wordpad to it, may solve your issues with the mdi child not showing the min/max/close buttons, because Wordpad isn't an MDI child.  Technically Wordpad *is* parented as is every program you run, to your Desktop.

GuruSR.
Learned 68k Motorola Asm instruction set in 30 minutes on the way to an Amiga Developer's Forum meeting.
Following week wrote a kernel level memory pool manager in 68k assembler for fun.