Closed
Bug 429063
Opened 17 years ago
Closed 17 years ago
js-ctypes needs OS X/Darwin support
Categories
(Core :: js-ctypes, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: avarma, Unassigned)
Details
Attachments
(1 file)
93.56 KB,
patch
|
mfinkle
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5
Build Identifier:
js-ctypes doesn't currently build on darwin.
Reproducible: Always
Steps to Reproduce:
When compiling, the makefile thinks that darwin is linux, and subsequently dies.
Actual Results:
The build process crashes because it can't find a linux-specific include file.
Expected Results:
It should build properly.
Reporter | ||
Comment 1•17 years ago
|
||
A few things to note about this patch:
* Source code added to the new src/darwin directory was taken from the ctypes 1.0.2 source code in the source/libffi/src directory. I used the configure script to build any files requiring pre-compiling and investigated the generated fficonfig.py file to figure out what files to compile.
* I had to make a few very minor modifications to the darwin-specific libffi source files themselves to get things to compile, such as:
* Changing includes from using < and > to double-quotes so that a few include files could be found.
* Renaming source files in subdirectories so they could be stored in a single directory (for instance, powerpc/ffi_darwin.c becomes powerpc_ffi_darwin.c).
* Renaming assembly files from having a .S extension to .s, so that the Mozilla build system could recognize them as being assembly files.
* The darwin/types.c file was simply copied from linux/types.c. I'm not sure where this file was initially obtained--it wasn't contained anywhere in ctypes' libffi source code, but it managed to define symbols that the object files in the xpcom directory needed (none of the files in the darwin directory needed them).
* I fixed what appears to be a bug in nsNativeMethod::Execute in nsNativeMethod.cpp, whereby the nsresult returned to the caller is uninitialized if the foreign function call takes no parameters. I'm not sure if my fix is optimal, however--it's very basic and just initializes the result to NS_OK at the variable's definition--so feel free to change it.
* I had to make a few modifications to some Makefile.in files; I'm not very familiar with Makefile programming, though, so they kind of violate DRY and look nasty. I welcome any suggestions to make the solutions there more elegant.
Reporter | ||
Comment 2•17 years ago
|
||
Also, to test this, I compiled a simple dynamic library that the Enso project uses on OS X, located here:
http://code.google.com/p/enso/source/browse/trunk/osx/src/key_utils.m?r=20
I then used the following javascript code in xpcshell to test it:
nsINativeTypes = Components.interfaces.nsINativeTypes;
library = Components.classes["@developer.mozilla.org/js-ctypes;1"].createInstance(nsINativeTypes);
library.open("/Users/varmaa/Documents/enso-svn/osx/src/key_utils.so");
simulatePaste = library.declare("simulatePaste",
nsINativeTypes.SYSV,
nsINativeTypes.INT32);
var result = simulatePaste();
print("result is " + result);
I only used this because it happened to be the most convenient and easy thing to test at the time (Enso loads the same shared library via Python's ctypes, so I knew how it should work). Clearly there are much more suitable dynamic libraries that should be used for manual/automatic testing. :)
Reporter | ||
Comment 3•17 years ago
|
||
I also forgot to mention that I've only tested this on x86-based darwin, not powerpc. The powerpc files are in this patch, however, so it should technically compile; however, I just realized that the nsINativeTypes xpcom interface doesn't define an AIX or DARWIN calling convention type, which, from my reading of the libffi source code, are the only two calling conventions that powerpc supports (I could have misread the source, though). x86-based darwin, OTOH, only seems to support the SYSV calling convention according to the libffi source, so we should be good there.
Comment 4•17 years ago
|
||
Comment on attachment 315686 [details] [diff] [review]
Patch to add darwin support to js-ctypes.
only needed to tweak the makefiles for the move to toolkit/components/js-ctypes.
Works great and passes the basic tests. Thanks!
Attachment #315686 -
Flags: review+
Updated•17 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Updated•15 years ago
|
Product: Other Applications → Core
You need to log in
before you can comment on or make changes to this bug.
Description
•