servo: Initial dump of codegen work. Requires manual running of various python scripts to build servo.

Source-Repo: https://github.com/servo/servo
Source-Revision: ebd1ce8055fcca488ca91fff768afdbf34d24a5f
This commit is contained in:
Josh Matthews 2013-01-16 15:04:36 +01:00
parent db6b9635af
commit 95d4204bfd
19 changed files with 5921 additions and 5 deletions

5
servo/.gitignore vendored
View File

@ -6,9 +6,12 @@
*.dSYM
*.dll
*.dummy
*.pkl
*.pyc
servo-test
Makefile
Servo.app
build
config.mk
config.stamp
config.stamp
parser.out

View File

@ -2,11 +2,14 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import sys
sys.path.append("./parser/")
sys.path.append("./ply/")
import os
import cPickle
import WebIDL
from Configuration import *
from Codegen import CGBindingRoot, replaceFileIfChanged
from CodegenRust import CGBindingRoot, replaceFileIfChanged
# import Codegen in general, so we can set a variable on it
import Codegen
@ -32,6 +35,19 @@ def generate_binding_cpp(config, outputprefix, webidlfile):
if replaceFileIfChanged(filename, root.define()):
print "Generating binding implementation: %s" % (filename)
def generate_binding_rs(config, outputprefix, webidlfile):
"""
|config| Is the configuration object.
|outputprefix| is a prefix to use for the header guards and filename.
"""
filename = outputprefix + ".rs"
root = CGBindingRoot(config, outputprefix, webidlfile)
#root2 = CGBindingRoot(config, outputprefix, webidlfile)
#if replaceFileIfChanged(filename, root.declare() + root2.define()):
if replaceFileIfChanged(filename, root.define()):
print "Generating binding implementation: %s" % (filename)
def main():
# Parse arguments.
@ -42,7 +58,7 @@ def main():
help="When an error happens, display the Python traceback.")
(options, args) = o.parse_args()
if len(args) != 4 or (args[0] != "header" and args[0] != "cpp"):
if len(args) != 4 or (args[0] != "header" and args[0] != "cpp" and args[0] != "rs"):
o.error(usagestring)
buildTarget = args[0]
configFile = os.path.normpath(args[1])
@ -62,6 +78,8 @@ def main():
generate_binding_header(config, outputPrefix, webIDLFile);
elif buildTarget == "cpp":
generate_binding_cpp(config, outputPrefix, webIDLFile);
elif buildTarget == "rs":
generate_binding_rs(config, outputPrefix, webIDLFile);
else:
assert False # not reached

View File

@ -113,6 +113,11 @@ DOMInterfaces = {
}
}],
'ClientRect': [
{
'nativeType': 'ClientRect',
}],
'ClientRectList': [
{
'nativeType': 'nsClientRectList',
@ -509,7 +514,7 @@ addExternalHTMLElement('HTMLOptGroupElement')
addExternalHTMLElement('HTMLVideoElement')
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
addExternalIface('ClientRect')
#addExternalIface('ClientRect')
addExternalIface('CSSRule')
addExternalIface('CSSValue')
addExternalIface('DOMStringList', nativeType='nsDOMStringList',

View File

@ -0,0 +1,14 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
interface ClientRect {
readonly attribute float top;
readonly attribute float right;
readonly attribute float bottom;
readonly attribute float left;
readonly attribute float width;
readonly attribute float height;
};

View File

@ -0,0 +1,85 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
interface ClientRect;
interface ClientRectList {
readonly attribute unsigned long length;
getter ClientRect? item(unsigned long index);
};
/* Helpers
unsafe fn unwrap<T>(obj: *JSObject) -> *rust_box<T> {
let val = JS_GetReservedSlot(obj, 0);
cast::reinterpret_cast(&RUST_JSVAL_TO_PRIVATE(val))
}
trait ToJsval {
fn to_jsval(cx: *JSContext) -> jsval;
}
impl Option : ToJsval {
fn to_jsval(cx: *JSContext) -> jsval {
match self {
Some(v) => v.to_jsval(),
None => JSVAL_NULL
}
}
}
*/
/*
trait ClientRectList {
fn getLength() -> u32;
fn getItem(u32 index) -> Option<@ClientRect>;
}
mod ClientRectList {
mod bindings {
fn getLength(cx: *JSContext, argc: c_uint, argv: *jsval) -> JSBool unsafe {
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
if obj.is_null() {
return 0;
}
let conrete = unwrap<ClientRectList>(obj);
let rval = (*concrete).getLength();
JS_SET_RVAL(argv, rval);
return 1;
}
fn getItem(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool unsafe {
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
if obj.is_null() {
return 0;
}
let raw_arg1 = if argc < 1 {
//XXX convert null
} else {
JS_ARGV(vp, 0);
};
let arg1 = if !RUST_JSVAL_IS_INT(raw_arg1) {
//XXX convert to int
} else {
RUST_JSVAL_TO_INT(raw_arg1);
} as u32;
let conrete = unwrap<ClientRectList>(obj);
let rval = (*concrete).getItem(arg1);
JS_SET_RVAL(vp, rval.to_jsval())
return 1;
}
}
*/

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,6 @@ class Configuration:
the configuration file.
"""
def __init__(self, filename, parseData):
# Read the configuration file.
glbl = {}
execfile(filename, glbl)
@ -140,6 +139,7 @@ class Descriptor(DescriptorProvider):
nativeTypeDefault = "mozilla::dom::" + ifaceName
self.nativeType = desc.get('nativeType', nativeTypeDefault)
self.pointerType = desc.get('pointerType', '@')
self.hasInstanceInterface = desc.get('hasInstanceInterface', None)
# Do something sane for JSObject

View File

@ -5,6 +5,9 @@
# We do one global pass over all the WebIDL to generate our prototype enum
# and generate information for subsequent phases.
import sys
sys.path.append("./parser/")
sys.path.append("./ply/")
import os
import cStringIO
import WebIDL

View File

@ -0,0 +1,59 @@
/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
#ifndef mozilla_dom_PrototypeList_h__
#define mozilla_dom_PrototypeList_h__
namespace mozilla {
namespace dom {
namespace prototypes {
namespace id {
enum ID
{
ClientRect = 0,
_ID_Count
};
} // namespace id
typedef id::ID ID;
const unsigned MaxProtoChainLength = 1;
} // namespace prototypes
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
namespace constructors {
namespace id {
enum ID
{
_ID_Count
};
} // namespace id
typedef id::ID ID;
} // namespace constructors
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
template <prototypes::ID PrototypeID>
struct PrototypeTraits;
template <class ConcreteClass>
struct PrototypeIDMap;
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_PrototypeList_h__

View File

@ -0,0 +1,20 @@
#include "ClientRectBinding.h"
#include "nsScriptNameSpaceManager.h"
namespace mozilla {
namespace dom {
void
Register(nsScriptNameSpaceManager* aNameSpaceManager)
{
#define REGISTER_PROTO(_dom_class, _pref_check) \
aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Binding::DefineDOMInterface, _pref_check);
REGISTER_PROTO(ClientRect, nullptr);
#undef REGISTER_PROTO
}
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,14 @@
#ifndef mozilla_dom_RegisterBindings_h__
#define mozilla_dom_RegisterBindings_h__
namespace mozilla {
namespace dom {
void
Register(nsScriptNameSpaceManager* aNameSpaceManager);
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_RegisterBindings_h__

View File

@ -0,0 +1,16 @@
#ifndef mozilla_dom_UnionConversions_h__
#define mozilla_dom_UnionConversions_h__
#include "mozilla/dom/UnionTypes.h"
#include "nsDOMQS.h"
#include "nsDebug.h"
namespace mozilla {
namespace dom {
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_UnionConversions_h__

View File

@ -0,0 +1,12 @@
#ifndef mozilla_dom_UnionTypes_h__
#define mozilla_dom_UnionTypes_h__
#include "mozilla/dom/BindingUtils.h"
namespace mozilla {
namespace dom {
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_UnionTypes_h__

View File

@ -0,0 +1,28 @@
Copyright (C) 2001-2009,
David M. Beazley (Dabeaz LLC)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the David Beazley or Dabeaz LLC may be used to
endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,9 @@
David Beazley's PLY (Python Lex-Yacc)
http://www.dabeaz.com/ply/
Licensed under BSD.
This directory contains just the code and license from PLY version 3.3;
the full distribution (see the URL) also contains examples, tests,
documentation, and a longer README.

View File

@ -0,0 +1,4 @@
# PLY package
# Author: David Beazley (dave@dabeaz.com)
__all__ = ['lex','yacc']

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,7 @@ pub mod dom {
pub mod node;
pub mod utils;
pub mod window;
pub mod ClientRectBinding;
}
pub mod document;
pub mod element;