Page 1 of 5 123 ... LastLast
Results 1 to 10 of 41

Thread: Cdecl (-> dll)

  1. #1

    Cdecl (-> dll)


    Charles (any one else) ,

    Is it possible to set up CDECL call convensions from DLLs written O2 (ThinBasic + O2.dll or Oxygen Basic ) ?

    (Working on some DLLs for Lisp (all based on alien Win32 products (Linux) ,
    Using the Aurora compiler as an Ersatz (but I think O2 produces faster code) .. I have to do something as

    export foo
    declare cdecl foo( x as "type" , .. , z as "type" .. ) , "type"
    function foo ( ..... ) , "type"
    return ...
    end function

    but even then single-floats givs a NaN , doubles work ... (Lisp is very secure on number typesn(like conversion is not done automatically )

    t.i.a. Rob
    Last edited by RobbeK; 30-04-2014 at 00:48.

  2. #2
    Hi Rob,

    For individual functions:

    function foo cdecl (...) as double, export
    end function

    For groups of functions

    an extern block can be used:

    extern cdecl export

    function foo(...) as double
    end function

    function bah(...) as double
    end function

    end extern

  3. #3

    Thumbs up

    Thanks Charles !

  4. #4

    I remember we had a disussion about index bases. In recent releases of Oxygen, I added support for negative index bases. They could be useful for carrying array-header information in the negative range, or you may have a mathematical use for negatively biased indices

    indexbase -100
    sys a[100]={0,1,2,3,4,5,6,7}
    print a[-99] '1
    indexbase 0
    print a[1] '1

  5. #5
    Ah, thanks ;-)

    O2 module for tB or Oxygen Basic (or both) ?

    O2 works perfectly .. code runs ~4x faster than if compiled with the previous compiler.
    (attached -- this Lisp had no Win32 graphical output -- so far so good )

    best Rob
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	O2 inside.jpg 
Views:	108 
Size:	150.6 KB 
ID:	9027  

  6. #6


    Has anybody ever thought about the possibility of wrapping the indices of a BASIC array so that the iterator never goes out of bounds but rather wraps around automatically to its minimum or maximum again and again? Can there be any practical sense in it?


    I'm dying to know what exactly is there in that Luminance HDR folder on your desktop?


    Just wondering...
    (3.6GHz i5 Core Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, x64 Windows 7 Ultimate Sp1)

  7. #7

    indexbase is confined to Oxygen. All thinBasic arrays always start with 1, as far as I know.


    Cyclical indexing is a bit too specialised to become core, but it has uses in feeding wave audio buffer loops, for instance.

    If the array size is a binary multiple - like 64k, then a simple bit mask can be applied to the index:

    indexbase 0
    i and=0xffff
    Last edited by Charles Pegge; 03-05-2014 at 11:02.

  8. #8
    Mike , : High Density Range mapping / composing of images.
    In digital photography the captured range is (or can be) rather low (film is better because it has a thickness , modern films have several layers to catch light with different wavelengths / intensities resulting in a wider density range ) .. however, the modern equivalent is to take several pictures of a scene at different exposure parameters -- it is then processed in a (super) additive way.
    Aligning of the seperate images (in this case) is done by another formidable program : Hugin (Hugin was one of the raven of Odin (the poor man gave up one eye for wisdom ) -- the bird kept an eye on things (especially at the back - the old Germanic Gods were always in a mood for a fight ;-) .. IIRC the other raven was called Munin or something like ...

    Charles & Mike ...
    Indices : the Lisp / Scheme way
    (in Scheme - that's the easiest -- you can set up the indices on forehand --
    1) as a list (range 2 6) is identical with '(2 3 4 5) this can be fed to a macro -- here you see it is not restricted to a pure linear sturcture it is easy to set up '(2 4 8 16 etc.. )
    thus : for ( [i '(1 2 3) ] ..... identical with [ i (range 1 4) ] ...
    (as said) of course you can replace (range ... ) with any definition that outputs a sequence of numbers ..
    2) Now it comes -> you also can turn this into a stream -- while (range) outputs a list , (in-range) outputs a stream (there are many constructions in lisp doing smae things sequential or paralel.
    Now you can define something as (in-naturals ..) which takes the whole range of natural numbers (0 to infinity ) !!
    Because this is a stream and not a list it can be interupted at the needed place/time/position. (i mean without the computer hanging on constructing an infinite list)

    I'm not very familiar with it, but i do think Haskell goes even a little further , in a way trying to combine both by lazy lazy evaluation.
    It will only do something if needed p.e. (in human language)
    a=a lot of calculations , taking a lot of time ....
    (nothing happens, because the output is not needed)
    print (a) ... it starts calculating a
    reversed -> if condition1 or condition2 or cond3 ... it will not evaluate/compile cond2 , cond3 ... when condition1 = t
    with the opposite in the "and" construction ..

    if false and .... / ends here

    (I think Mike told me C has similar constructions .. )
    (in (some) Lisp(s) you can turn this off by (do-all) forcing it into strict evaluation )

    .. but I only used Haskell writing a few lines / it seems to works this way at first sight .. (Lisp - more than a decade )

    best Rob
    Last edited by RobbeK; 03-05-2014 at 12:00.

  9. #9
    I deploy lazy evaluation on conditional expressions but it can be improved. in a nested expression: some of the components are calculated in advance and stored to temporary variables. These component calculations need to be in-lined, so that lazy-eval can jump over them. My next task

    In Oxygen, local macros and functions can be used to customise the behaviour of array indices:

    '3d static array example

    indexbase 0
    def xe 100
    def ye 100
    def ze 8

    float b[xe*ye*ze]

    macro bm(x,y,z) b[z*xe*ye+y*xe+x]


  10. #10
    Hi Charles,

    I think deep inside Lisp must use something similar, which makes a difference with languages like Haskell.
    I mean Lazy Eval can only happen when controled by a macro ( if , when , cond , etc .... ), but it seems Haskell is 100% functional , (if is a function and not a macro ), for this reason lazy evalution will cover the whole code , for this reason calculations will not be done before the result is needed. But as it is very easy to write macro's in Lisp (using the same language syntax) this is not a big thing.
    (btw even in assigning, Lisp can use paralel and sequential structures ,
    p.e. (let ... ) binds locals paralel , (let* ... ) serial/sequencial ;-)
    (maybe I will download Haskell (and the Glasgow Haskell Compiler) and play a little with it .

    btw donwloaded the latest Oxygen now (i was working with 2012 one ) , that IUP stuff seems most interesting ;-)

    best Rob
    Last edited by RobbeK; 03-05-2014 at 13:25.

Page 1 of 5 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts