Re: [Chicken-users] How to compile chicken scheme to Windows DLL?

2015-02-16 Thread Chris Vine
On Mon, 16 Feb 2015 09:09:03 +0100
Christian Kellermann  wrote:
> "Ryuho Yokoyama"  writes:
> 
> >>Do you have any special reason to be using such an old CHICKEN?
> >
> > Yes, as stating in reply mail to Mr. Oleg Kolosov,  I am now
> > converting all my CL code to Scheme(Chicken, Gambit).
> > In original code there are many "define-macro".  Because  Chicken
> > Ver 4 does not support "define-macro"  I am
> > using the Ver 3.
> 
> Please note that with CHICKEN 4 it is still possible to write
> unhygienic macros using explicit / implicit renaming macros.
> 
> In my experience this is trivial to do most of the time, so instead of
> using an old version of chicken that is unsupported and misses a lot
> of performance enhancements (specialisations of code, improvements in
> the number tower, scheduler bugfixes to name a few) I urge you to
> reconsider using a recent version.

I think it should also be relatively straightforward to emulate
define-macro using two nested explicit renaming macros, if the
idea is to use define-macro as a lowest common denominator of all
schemes.  Of course it would suffer from all the lack of hygiene
that define-macro does, but it might be acceptable as a stop gap
while working code is moved to using renaming macros properly.

If the OP is using normal define-macro syntax I think this will work
(on a couple of trivial tests it seems to do what is wanted, your
mileage may vary):

 (define-syntax define-macro
   (er-macro-transformer
(lambda (exp0 r0 c0)
  (let ([name (caadr exp0)]
[formals (cdadr exp0)]
[body (cddr exp0)])
 `(define-syntax ,name
(er-macro-transformer
 (,(r0 'lambda) (,(r0 'exp1) ,(r0 'r1) ,(r0 'c1))
   (,(r0 'apply) (,(r0 'lambda) ,formals ,@body) (,(r0 'cdr) ,(r0 
'exp1))

If the OP is using defmacro syntax it would require some tweaks to
the opening let clauses.

Chris

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] How to compile chicken scheme to Windows DLL?

2015-02-16 Thread Christian Kellermann
"Ryuho Yokoyama"  writes:

>>Do you have any special reason to be using such an old CHICKEN?
>
> Yes, as stating in reply mail to Mr. Oleg Kolosov,  I am now
> converting all my CL code to Scheme(Chicken, Gambit).
> In original code there are many "define-macro".  Because  Chicken Ver
> 4 does not support "define-macro"  I am
> using the Ver 3.

Please note that with CHICKEN 4 it is still possible to write unhygienic
macros using explicit / implicit renaming macros.

In my experience this is trivial to do most of the time, so instead of
using an old version of chicken that is unsupported and misses a lot of
performance enhancements (specialisations of code, improvements in the
number tower, scheduler bugfixes to name a few) I urge you to reconsider
using a recent version.

Kind regards,

Christian

-- 
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] How to compile chicken scheme to Windows DLL?

2015-02-14 Thread Ryuho Yokoyama

Thank you very much for replying.

I did not understood your intention. Assuming that DLLs produced by MinGW 
gcc is not what you want ...


It isn't explained sufficiently by last mail, I am sorry.

I am now converting all my CL code to Scheme(Chicken, Gambit). I chose two 
Schemes
for comparing the time (compiling time, run time).  I almost finished 
converting code

except creating the Windows DLL by Chicken and MinGW gcc.
By reference, I managed to make the Windows DLL by Gambit and MinGW gcc as 
following,


Gambit-C v4.6.0
MinGW(mingw-get-inst-20110802.exe)

sample.scm
--

;; Initialize Gambit-C runtime system when "sample.dll" is loaded.

(c-declare #<(c-define (mycalc aa bb cc dd) (double double double double) double "mycalc" 
""

 (mycalc1 aa bb cc dd))

(define (mycalc1 aa bb cc dd)
 (apply + `(,aa ,bb ,cc ,dd)))

-END

makefile
-
CDRV = E:

SFILE= sample.scm
CFILE= sample.c
LKFILE   = sample_.c
TARGET   = sample.dll

OBJS_DIR = obj
PROG_DIR = prog

CC   = $(CDRV)/MinGW/bin/gcc
GSC  = $(CDRV)/Gambit-C/v4.6.0/bin/gsc

INCLUDE  = -I$(CDRV)/Gambit-C/v4.6.0/include
LIB  = $(CDRV)/Gambit-C/v4.6.0/lib/libgambc.a

CFLAG 
  = -D_WINDOWS -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math 
-fno-strict-aliasing -fwrapv -fno-common -mieee-fp

CFLAG1   = -shared
LDFLAG   = -lws2_32
LDFLAG1  = -lwsock32
RM   = rm
DFLG = -debug
GFLAG= -link
GFLAGS   = $(DFLG) -c -o $(OBJS_DIR)

CFILES   = $(addprefix $(OBJS_DIR)/, $(CFILE))
OFILES   = $(addprefix $(OBJS_DIR)/, $(CFILE:.c=.o))
LOFILE   = $(addprefix $(OBJS_DIR)/, $(LKFILE:.c=.o))

all : $(TARGET)

$(TARGET) : $(OFILES) $(LOFILE)
   $(CC) $(CFLAG1) $(INCLUDE) -o $@ $^ $(LIB) $(LDFLAG1) $(LDFLAG)

$(OBJS_DIR)/%.o : $(OBJS_DIR)/%.c
   $(CC) $(CFLAG) $(INCLUDE) -c -o $@ $<

$(OBJS_DIR)/$(LKFILE) : $(CFILES)
   $(GSC) $(GFLAG) $^

$(OBJS_DIR)/%.c : $(PROG_DIR)/%.scm
   $(GSC) $(GFLAGS) $<

clean :
   -$(RM) $(OBJS_DIR)/*.o $(TARGET)
-END

In my case my Windows apprication can import dll as below,

test_call_dll.mq4
-
#import "sample.dll"
 double mycalc (double,double,double,double);
#import

void OnStart()
 {
  Alert(mycalc(1,2,3,4));
 }
-END

So I gess the Chicken version "sample.scm" might be,

sample.scm
--

;; Initialize Chicken runtime system when "sample.dll" is loaded.

#>

#define LINKER ??_sample__





BOOL WINAPI DllMain (HINSTANCE hinst, DWORD reason, LPVOID ptr)
{
  switch (reason)
{
case DLL_PROCESS_ATTACH:
  ???
  ? = LINKER;

??
case DLL_PROCESS_DETACH:
   ?
}
  return FALSE;
}
<#

;; Procedures exported by "sample.dll":

(define-external (mycalc (double aa) (double bb) (double cc) (double dd)) 
double

  (mycalc1 aa bb cc dd))


(define (mycalc1 aa bb cc dd)
 (apply + `(,aa ,bb ,cc ,dd)))

-END

May someone who know inside Chicken be able to fill the ? part?



... you can try my
https://github.com/bazurbat/chicken-scheme next branch which can produce 
Windows native DLLs using Visual Studio compiler with the >help of CMake. 
Be careful though as this branch contains a lot of other experimental 
changes and not supported by the CHICKEN >developers.


Thank you very much for your suggestion.  After conversion work ends, I'll 
check your system.



-Original Message- 
From: Oleg Kolosov

Sent: Friday, February 13, 2015 11:18 PM
To: Ryuho Yokoyama
Cc: chicken-users@nongnu.org
Subject: Re: [Chicken-users] How to compile chicken scheme to Windows DLL?

On 13 Feb 2015, at 15:44, Ryuho Yokoyama  wrote:


Hello,

I am attempting to compile the chicken scheme code down to C
and then compile it into a Windows DLL.

But I can not how to initialize chicken scheme runtime system
in the DllMain function.

Please someone show how to write a scheme code which produce a Windows DLL
and compile option etc.

Chicken Ver 3.4.0
MinGW(mingw-get-inst-20110802.exe)



I did not understood your intention. Assuming that DLLs produced by MinGW 
gcc is not what you want you can try my 
https://github.com/bazurbat/chicken-scheme next branch which can produce 
Windows native DLLs using Visual Studio compiler with the help of CMake. Be 
careful though as this branch contains a lot of other experimental changes 
and not supported by the CHICKEN developers.


--
Regards, Oleg
Art System 



___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] How to compile chicken scheme to Windows DLL?

2015-02-14 Thread Ryuho Yokoyama

Thank you very much for replying.


Do you have any special reason to be using such an old CHICKEN?


Yes, as stating in reply mail to Mr. Oleg Kolosov,  I am now converting all 
my CL code to Scheme(Chicken, Gambit).
In original code there are many "define-macro".  Because  Chicken Ver 4 does 
not support "define-macro"  I am

using the Ver 3.


I'm not sure I understand your question.  Do you want to embed CHICKEN
into a C application as a dll?


Please refer to reply mail to Mr. Oleg Kolosov.


-Original Message- 
Date: Fri, 13 Feb 2015 15:48:06 +

From: Mario Domenech Goulart 
To: chicken-users@nongnu.org
Subject: Re: [Chicken-users] How to compile chicken scheme to Windows
DLL?
Message-ID: <87sie9ke2x@email.parenteses.org>
Content-Type: text/plain

Hi,

On Fri, 13 Feb 2015 21:44:08 +0900 "Ryuho Yokoyama"  
wrote:



I am attempting to compile the chicken scheme code down to C
and then compile it into a Windows DLL.
But I can not how to initialize chicken scheme runtime system
in the DllMain function.
Please someone show how to write a scheme code which produce a Windows
DLL
and compile option etc.
Chicken Ver 3.4.0
MinGW(mingw-get-inst-20110802.exe)


CHICKEN 3.4.0 is very old.  We've switched to the major version 4 ~6
years ago.  The most recent release is 4.9.0.1, which you can find here:
http://code.call-cc.org/

Do you have any special reason to be using such an old CHICKEN?  If you
don't, I strongly suggest you to update to the latest release.

I'm not sure I understand your question.  Do you want to embed CHICKEN
into a C application as a dll?

Best wishes.
Mario
--
http://parenteses.org/mario


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] How to compile chicken scheme to Windows DLL?

2015-02-13 Thread Mario Domenech Goulart
Hi,

On Fri, 13 Feb 2015 21:44:08 +0900 "Ryuho Yokoyama"  wrote:

> I am attempting to compile the chicken scheme code down to C 
> and then compile it into a Windows DLL.
> But I can not how to initialize chicken scheme runtime system
> in the DllMain function.
> Please someone show how to write a scheme code which produce a Windows
> DLL
> and compile option etc.
> Chicken Ver 3.4.0
> MinGW(mingw-get-inst-20110802.exe)

CHICKEN 3.4.0 is very old.  We've switched to the major version 4 ~6
years ago.  The most recent release is 4.9.0.1, which you can find here:
http://code.call-cc.org/

Do you have any special reason to be using such an old CHICKEN?  If you
don't, I strongly suggest you to update to the latest release.

I'm not sure I understand your question.  Do you want to embed CHICKEN
into a C application as a dll?

Best wishes.
Mario
-- 
http://parenteses.org/mario

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] How to compile chicken scheme to Windows DLL?

2015-02-13 Thread Oleg Kolosov
On 13 Feb 2015, at 15:44, Ryuho Yokoyama  wrote:
> 
> Hello,
>  
> I am attempting to compile the chicken scheme code down to C
> and then compile it into a Windows DLL.
>  
> But I can not how to initialize chicken scheme runtime system
> in the DllMain function.
>  
> Please someone show how to write a scheme code which produce a Windows DLL
> and compile option etc.
>  
> Chicken Ver 3.4.0
> MinGW(mingw-get-inst-20110802.exe)
>  

I did not understood your intention. Assuming that DLLs produced by MinGW gcc 
is not what you want you can try my https://github.com/bazurbat/chicken-scheme 
next branch which can produce Windows native DLLs using Visual Studio compiler 
with the help of CMake. Be careful though as this branch contains a lot of 
other experimental changes and not supported by the CHICKEN developers.

-- 
Regards, Oleg
Art System


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] How to compile chicken scheme to Windows DLL?

2015-02-13 Thread Ryuho Yokoyama
Hello,

I am attempting to compile the chicken scheme code down to C 
and then compile it into a Windows DLL.

But I can not how to initialize chicken scheme runtime system
in the DllMain function.

Please someone show how to write a scheme code which produce a Windows DLL
and compile option etc.

Chicken Ver 3.4.0
MinGW(mingw-get-inst-20110802.exe)

Thanks in advance.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users