~ubuntu-branches/ubuntu/hardy/ocaml-doc/hardy

« back to all changes in this revision

Viewing changes to examples/dlls/modwrap.c

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-08 01:49:22 UTC
  • mfrom: (0.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070908014922-lvihyehz0ndq7suu
Tags: 3.10-1
* New upstream release.
* Removed camlp4 documentation since it is not up-to-date.
* Updated to standards version 3.7.2, no changes needed.
* Updated my email address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* File modwrap.c -- wrappers around the Caml functions */
2
 
 
3
 
#include <wtypes.h>
4
 
#include <winbase.h>
5
 
#include <stdio.h>
6
 
#include <string.h>
7
 
#include <caml/mlvalues.h>
8
 
#include <caml/callback.h>
9
 
 
10
 
int fib(int n)
11
 
{
12
 
  static value * fib_closure = NULL;
13
 
  if (fib_closure == NULL) fib_closure = caml_named_value("fib");
14
 
  return Int_val(callback(*fib_closure, Val_int(n)));
15
 
}
16
 
 
17
 
char * format_result(int n)
18
 
{
19
 
  static value * format_result_closure = NULL;
20
 
  if (format_result_closure == NULL)
21
 
    format_result_closure = caml_named_value("format_result");
22
 
  return strdup(String_val(callback(*format_result_closure, Val_int(n))));
23
 
  /* We copy the C string returned by String_val to the C heap
24
 
     so that it remains valid after garbage collection. */
25
 
}
26
 
 
27
 
BOOL APIENTRY DllMain(HANDLE module, DWORD reason, void *reserved)
28
 
{
29
 
  char * argv[2];
30
 
 
31
 
  switch (reason) {
32
 
  case DLL_PROCESS_ATTACH:
33
 
    argv[0] = "mydll";
34
 
    argv[1] = NULL;
35
 
    caml_startup(argv);
36
 
    break;
37
 
  }
38
 
  return TRUE;
39
 
}
 
 
b'\\ No newline at end of file'