This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
1,980 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Test.dll | ||
Test.pdb | ||
cilc.pdb | ||
*.mdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
2009-10-23 Alp Toker <alp@nuanti.com> | ||
|
||
* cilc.cs: Introduce and start to make use of disable_glib. | ||
|
||
2007-03-13 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.exe.sources: | ||
* cilc.cs: | ||
* CodeWriter.cs: Split out CodeWriter class. | ||
|
||
2007-03-13 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Use String.Empty. | ||
|
||
2006-08-23 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Relicense from GPL to MIT License | ||
|
||
2006-08-23 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Add more GInterface support, both defining and implementing | ||
|
||
2005-12-27 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Start work on GInterface support | ||
* Test.cs: Update tests | ||
|
||
2005-12-24 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Fix generation of mono method signature a bit (still needs work), | ||
Make JIT parse default config files before init | ||
|
||
2005-12-22 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Add support for string return types and properties, begin work to | ||
improve GObject tie-in | ||
* Test.cs, demo.c: Update tests | ||
|
||
2005-12-22 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Add support for char, sbyte, byte and double | ||
* Test.cs, demo.c: Update tests | ||
|
||
2005-05-08 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Add null check to NsToC and fix warnings. | ||
|
||
2005-01-20 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Name the glib handle getter helper method by namespace for now to | ||
fully support assemblies with multiple namespaces. Would be better to | ||
generate a toplevel Cindex file in future. | ||
|
||
2004-12-13 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: | ||
Use the GObject of the object if it already has one, rather than creating a | ||
new GObject instance of our own. Store the reference to the MonoObject in | ||
a GObject data field. | ||
Explicit casts in generated code to avoid compiler warnings. | ||
|
||
2004-12-12 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: | ||
* Test.cs: | ||
* demo.c: | ||
First stab at return values, and associated updates to the demo. | ||
Consider types registered ByVal but not in main registry as unregistered. | ||
Mark out some more ByVal types. | ||
* cilc.cs: | ||
Initial support for namespaceless assemblies. | ||
C keyword avoidance. | ||
|
||
2004-12-11 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: | ||
First stab at initialising delegates using method pointers. | ||
Convert the type registry management and reporting methods to use strings, | ||
making way for tie-in with native GObject hierarchies. | ||
Recursive conflict avoidance for the GObject class struct etc. | ||
Add check to see if a registered type IsExternal | ||
Treat byref values properly. | ||
Support tie-in with existing GObject hierarchy. | ||
Use argc parity to decide the generation mode. | ||
Update usage help string. | ||
* res-Makefile: | ||
Use passed CFLAGS. | ||
Only rebuild modified targets if bundle is defined, not everything. | ||
* README: | ||
More usage examples. | ||
|
||
2004-12-10 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: | ||
The generated makefile now optionally uses mkbundle to include the assembly | ||
into the generated library (when 'bundle' is defined for make). | ||
The assembly is automatically copied into the generated directory. | ||
Use a resource for the static makefile | ||
If only one argument is given, generate sources to a temporary directory, | ||
build them (as bundle), and install them to the current directory. | ||
Otherwise, the old behaviour applies. | ||
Don't indent the __cplusplus ifdef block in generated headers. | ||
Include the Mono headers in the sources, not the headers. | ||
Identify and report disparity in the order of type registration. | ||
Start support for some more primitive types. | ||
Fix with/and separator logic in overloaded method generation. | ||
Generate enums. | ||
Cleanups. | ||
* README: | ||
Update with details of the new bundle feature and single-argument operation. | ||
* Makefile: | ||
We no longer need to copy the assembly to the generated directory manually. | ||
Include res-Makefile as a resource for cilc.exe | ||
* res-Makefile: | ||
The static makefile resource | ||
Tweak the library output directory. | ||
|
||
2004-12-09 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: | ||
Support inheritance (within a single namespace). | ||
Enhance CodeWriter. | ||
Handle nested namespaces properly. | ||
Generate forward type declarations. | ||
Use the real type, not MonoObject, for function parameters. | ||
Ignore non-public types for now. | ||
Handle multiple namespaces in a single assembly. | ||
Name the generated .so according to the input assembly name. | ||
Code generator access modifier cleanups. | ||
Use base name of input as default output target directory. | ||
Report missed type registry hits after generation, using FullName if needed. | ||
Reduce verbosity. | ||
* Makefile: | ||
Build Demo.dll, not Test.dll. | ||
|
||
2004-12-08 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: | ||
Produce genuine GObjects. | ||
Start support for events/signals and enums. | ||
Handle overloaded methods. | ||
Report ignored types, warn on potentially incorrect code generation. | ||
More conflict avoidance. | ||
Cleaned up warnings. | ||
* README: Update test instructions. | ||
|
||
2004-12-06 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Update to new embedding API: use mono_assembly_get_image() | ||
Avoid conflicting parameter and internal variable names. | ||
Use intermediary object files before linking. | ||
|
||
2004-06-09 Raja R Harinath <rharinath@novell.com> | ||
|
||
* Makefile (HAS_TEST): Remove. | ||
(run-test-local): Move rules to and depend on ... | ||
(run-cilc-test): ... this. | ||
|
||
2003-05-02 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Print usage info | ||
|
||
2003-05-01 Alp Toker <alp@atoker.com> | ||
|
||
* cilc.cs: Support arguments, clean up some gcc warnings | ||
* Test.cs, demo.c: More extensive test | ||
|
||
2003-04-25 Alp Toker <alp@atoker.com> | ||
|
||
* Initial release of cilc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// cilc -- a CIL-to-C binding generator | ||
// Copyright (C) 2003, 2004, 2005, 2006, 2007 Alp Toker <alp@atoker.com> | ||
// Licensed under the terms of the MIT License | ||
|
||
using System; | ||
using System.IO; | ||
|
||
class CodeWriter | ||
{ | ||
private StreamWriter w; | ||
|
||
public CodeWriter (string fname) | ||
{ | ||
Init (fname); | ||
} | ||
|
||
public bool IsDuplicate = false; | ||
|
||
void Init (string fname) | ||
{ | ||
if (File.Exists (fname)) { | ||
string newfname = fname + ".x"; | ||
//Console.WriteLine ("Warning: File " + fname + " already exists, using " + newfname); | ||
IsDuplicate = true; | ||
Init (newfname); | ||
return; | ||
} | ||
|
||
FileStream fs = new FileStream (fname, FileMode.OpenOrCreate, FileAccess.Write); | ||
w = new StreamWriter (fs); | ||
} | ||
|
||
public string Indenter = " "; | ||
string cur_indent = String.Empty; | ||
int level = 0; | ||
|
||
public void Indent () | ||
{ | ||
level++; | ||
cur_indent = String.Empty; | ||
for (int i = 0; i != level ; i++) cur_indent += Indenter; | ||
} | ||
|
||
public void Outdent () | ||
{ | ||
level--; | ||
cur_indent = String.Empty; | ||
for (int i = 0; i != level ; i++) cur_indent += Indenter; | ||
} | ||
|
||
public void Write (string text) | ||
{ | ||
w.Write (text); | ||
} | ||
|
||
public void WriteLine (string text) | ||
{ | ||
WriteLine (text, true); | ||
} | ||
|
||
public void WriteLine (string text, bool autoindent) | ||
{ | ||
char[] opentags = {'{', '('}; | ||
char[] closetags = {'}', ')'}; | ||
|
||
if (autoindent && text.TrimStart (closetags) != text) | ||
Outdent (); | ||
|
||
w.Write (cur_indent); | ||
w.WriteLine (text); | ||
|
||
if (autoindent && text.TrimEnd (opentags) != text) | ||
Indent (); | ||
} | ||
|
||
public void WriteLine (string text, CodeWriter cc) | ||
{ | ||
WriteLine (text, String.Empty, cc, String.Empty); | ||
} | ||
|
||
public void WriteLine (string text, CodeWriter cc, string suffix) | ||
{ | ||
WriteLine (text, String.Empty, cc, suffix); | ||
} | ||
|
||
public void WriteLine (string text, string prefix, CodeWriter cc) | ||
{ | ||
WriteLine (text, prefix, cc, String.Empty); | ||
} | ||
|
||
public void WriteLine (string text, string prefix, CodeWriter cc, string suffix) | ||
{ | ||
WriteLine (text); | ||
cc.WriteLine (prefix + text + suffix); | ||
} | ||
|
||
public void WriteComment (string text) | ||
{ | ||
w.WriteLine ("/* " + text + " */"); | ||
} | ||
|
||
public void WriteLine () | ||
{ | ||
w.WriteLine (String.Empty); | ||
} | ||
|
||
public void Close () | ||
{ | ||
w.Flush (); | ||
w.Close (); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
thisdir = tools/cilc | ||
SUBDIRS = | ||
include ../../build/rules.make | ||
|
||
PROGRAM = cilc.exe | ||
|
||
# fixme: make clean doesn't know to rm -rf generated. | ||
# and we can't extend the make clean target. | ||
|
||
CLEAN_FILES = generated Demo.dll Demo.pdb | ||
|
||
OTHER_RES = res-Makefile | ||
|
||
RESOURCE_FILES = $(OTHER_RES) | ||
|
||
EXTRA_DISTFILES = demo.c README TODO Test.cs $(RESOURCE_FILES) | ||
|
||
include ../../build/executable.make | ||
|
||
LOCAL_MCS_FLAGS=-r:Mono.Posix.dll $(OTHER_RES:%=-resource:%) | ||
|
||
cilc.exe: $(RESOURCE_FILES) | ||
|
||
test-local: Demo.dll | ||
|
||
run-test-local: run-cilc-test | ||
|
||
run-cilc-test: cilc.exe Demo.dll | ||
rm -rf generated | ||
$(RUNTIME) $(RUNTIME_FLAGS) cilc.exe Demo.dll generated | ||
$(MAKE) -C generated | ||
$(CCOMPILE) -Wall `pkg-config --cflags --libs glib-2.0 mono` -Igenerated -Lgenerated -ldemo demo.c -o generated/demo | ||
|
||
Demo.dll: Test.cs | ||
$(CSCOMPILE) /target:library /out:$@ $^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
cilc | ||
==== | ||
|
||
cilc is a CIL-to-C binding generator. It can be used to expose any CIL library | ||
to the C (and C++) world using the GObject object model and coding style. This | ||
should be of particular interest to GNOME developers who wish to make use of | ||
libraries developed in C#, perhaps Gtk# widgets, within their own C | ||
applications. Developers who use a generated binding need no specific knowledge | ||
pertaining to Mono and runtime embedding -- almost everything is done behind | ||
the scenes. | ||
|
||
Right now, cilc is in an early stage of development. See TODO for a list of | ||
pending tasks. | ||
|
||
For a demonstration, see Test.cs and demo.c to get an idea of what's going on. | ||
Then run: | ||
|
||
$ make run-test-local | ||
$ cd generated | ||
$ ./demo | ||
|
||
To make a redistributable shared object that includes the assembly, you can | ||
then: | ||
|
||
$ make clean | ||
$ make bundle=true | ||
$ rm *.dll | ||
$ ./demo | ||
|
||
Note that you must have Mono's mkbundle tool installed to use the bundle | ||
feature. | ||
|
||
If all you want to do is generate a binding for an assembly, you can simply | ||
pass the assembly name as a single argument to cilc and it will automatically | ||
generate bindings in a temporary directory, compile them using the bundle | ||
feature, and install the produced shared library in the lib/ subdirectory and | ||
the headers in include/. | ||
|
||
$ cilc Assembly.dll | ||
|
||
To tie-in with existing GOjbect hierarchies, pass pairs of pkg-config package | ||
and comma-separated namespaces. For example: | ||
|
||
If you want to use a Gtk# widget in a Gtk+ application: | ||
|
||
$ cilc Widget.dll gtk+-2.0 gtk | ||
|
||
To bind gtk-sharp, but tying it into the native hierarchy for gdk: | ||
|
||
$ cilc gtk-sharp.dll gtk+-2.0 gdk | ||
|
||
-- | ||
Alp Toker <alp@atoker.com> |
Oops, something went wrong.