Author Topic: embedding oxygen (inspiring?)  (Read 4759 times)

0 Members and 3 Guests are viewing this topic.

pber

  • Guest
embedding oxygen (inspiring?)
« on: June 17, 2014, 11:21:01 PM »
hi all,

I would write an application that hosts oxygen as extension language.
The main thread handles the win32 gui,
a second thread should be the one used by oxygen.

I figure out three kind of issues:
1.a) in order to make the oxygen state persistent
     procedures should be saved as source and recompiled when needed
1.b) they could be saved as op-code, but it's not clear to me if/how
     they should be relocated after loading
2.a) data should be saved as well as code, pointers between objects (i.e. a variable
     that points to a string) should be restored. This way implies complete
     and deep insight of oxygen internals.
2.b) as an alternative: types and data could be defined and instanciated at
     an higher level that the native (oxygen ruled) one.
3)   host and oxygen should be synchronized, since they must run in parallel

Do i miss other macro-categories?

Aurel

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #1 on: June 18, 2014, 03:47:32 AM »
Quote
The main thread handles the win32 gui,
what mean MAIN aplication will be winGUI program written or created in another
programming language ....right?
I ask why ?
Of course i understand if you already have something created and as addition
you can build dll with oxygen for fast execution
if your main program is slow to execute some complex things or is complex to
create dll in that programming tool?

pber

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #2 on: June 18, 2014, 04:06:00 AM »
hi Aurel, thanks for the reply

You are not wrong:
why do not building the whole app with oxygen.
And it is probably the way i could try ... if i was able to do that.
At now i'm coding with freebasic.
And i would try to embed code-script as well as oxygen.

Why? just to rewrite an emacs in scale 1:1000 :-)

i would realize a "minimum" core with freebasic/fltk
then extending the system with the extension-language.

Another point i'd like to have the time to realize is the possibility
for the end-user to modify the whole system, as in Smalltalk envs.

At now i'm working on two things: embedding and parsing basic code.
It's the first time i try to learn hand-written parsers.

Oxygen produces opcode, it does not spend time on providing the host
with meta-tags about what it compiles, and this is good.

Charles sources is very hard to learn: i simply do not understand the old
way of giving variables names that are very close to mnemonics.


Charles Pegge

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #3 on: June 18, 2014, 08:55:50 AM »
Hi Paolo,

To make an Oxygen program persistent, so that it retains procedures and all state data, after the program is executed. All you have to do is provide a "finish" procedure, which is to be called when the Oxygen program, and all its procedures are no longer required.

Here is a very simple example, where thinBasic is the host.

Code: [Select]
uses "oxygen"

dim as string src
dim as long pHypot3d
dim as long pFinish

src="
  function hypot3d(double a,double b, double c) as double  link #pHypot3d
  return sqr( a*a+b*b+c*c)
  end function

  sub finish() link #pFinish
  terminate
  end sub
"
o2_basic src
if o2_error then
  msgbox 0,o2_error
  stop
else
  o2_exec
end if

declare function Hypot3d(byval double, byval double, byval double ) as double at pHypot3d
declare sub Finish() at pFinish

msgbox 0,Hypot3d(2,3,4)
Finish()

ThinBasic uses customised extension modules, so Oxygen.dll, in this case, is embedded in thinBasic_Oxygen.dll, which provides linkage for procedures and shared variables.

Perhaps I should provide a FreeBasic Host example. The Oxygen compilers, gxo2 and exo2 are written in FreeBasic, but the compiled program does not interact with the host. So I need to show you how this might be done with a  FreeBasic host.
« Last Edit: June 18, 2014, 09:05:39 AM by Charles Pegge »

Aurel

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #4 on: June 18, 2014, 09:36:21 AM »
emacs...?
Is this a editor with scripting capability ?

Quote
i would realize a "minimum" core with freebasic/fltk

Hmm...FLTK....well ,i look into fltk-FB long time ago and i even think to try something
but i gave up simply because i prefer native winGUI api  but fltk looks good to me.
you say parser...heh yes sometimes is a hard to understand Charles code
because is very simple and sometimes too minimalistic BUT once you get how things work
it is not to tuff. :D
anyway ..you can look into awinh ...include for winGUI functions
and if you whish you may also look into mine ultra-simple interpreter for parsing.
It is not advanced  :-\ at all  ;D

JRS

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #5 on: June 18, 2014, 11:09:57 AM »
Aurel,

Do you work for Walmart in the complaint department when not programming?


pber

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #6 on: June 18, 2014, 12:55:55 PM »
Thanks Charles now i try the directions you suggested me.

John: I argue Aurel does not know the concept of not-programming (other implications omitted)

Aurel: which ultra-simple parser?
Do you mean rubendev: RCode2.exe and ruben2.exe?
I have the executables, but i missed sources... could you suggest me a link to download them?

About emacs: yes it is an editor with scripting capabilities, ruled by an ancient lisp (EmacsLIsp).
Actually EmacsLIsp does much more than scripting, since the 75%(?) of the functionallities
of Emacs are based on lisp. It implements a way of extending the system more powerful
and interactive than other architectures based on plug-in concept.


Aurel

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #7 on: June 18, 2014, 01:43:45 PM »
ok ...
files are in next post...
« Last Edit: June 18, 2014, 09:47:32 PM by Aurel »

pber

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #8 on: June 18, 2014, 02:00:49 PM »
sorry: i'm in trouble with registration at rubendev,
it does not send me the confirmation mail,

so i can't (still) download your sources

JRS

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #9 on: June 18, 2014, 02:12:58 PM »
Don't ya just love FREE hosted forums? BaCon has the same issues. (can't view /download attachments unless you're a member) When joining these FREE forums your e-mail address is sold to any spammer that has a few bucks and your cookies are shared with their advertisers.
« Last Edit: June 18, 2014, 05:10:02 PM by John »

Aurel

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #10 on: June 18, 2014, 09:45:56 PM »
Quote
Don't ya just love FREE hosted forums? BaCon has the same issues. (can't view /download attachments unless you're a member)

John
And you really must repeat again how much you are stupid.
My forum don't have nothing with BaCon or any other forum.
you or anyone else who is not member cannot view or download attachment...
And what is a problem ? create account?
just unswer on a one simple question  ok  :D

sorry paolo i forget about that ... ::)
I will add it here
(and your account is activ  ;) )

.
« Last Edit: June 18, 2014, 10:05:23 PM by Aurel »

JRS

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #11 on: June 18, 2014, 10:07:23 PM »
Do you pay for anything?




pber

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #12 on: June 18, 2014, 10:51:20 PM »
i'm facing the example posted by charles in this thread.
FreeBasic does not implements the at semanthic as oxygen and thinbasic do.

I believe this should go in freeBasic:

Code: [Select]
Dim pHypot3d As Function (As  Double, As  Double, As  Double ) as Double
dim pFinish As sub () 

but oxygen does not see the two symbols.
Maybe a matter of how the exe is compiled?
-export does not help.

pber

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #13 on: June 19, 2014, 02:19:47 AM »
ops... a freebasic example appeared!
many thanks Charles

Peter

  • Guest
Re: embedding oxygen (inspiring?)
« Reply #14 on: June 19, 2014, 02:54:21 AM »
Quote
And you really must repeat again how much you are stupid.
  ;D

Code: [Select]
include "sw.inc"
Window 640,480,1

LoadBmp "image/esel.bmp",1
DrawBmp 1,160,120,320,240,0
c = GetBmpPixel 1,0,0
FloodFill 1,1,sw_white,c

WaitKey
CloseWindow

.