From b8c5f9219f724580d7de9500f9d6e5078d19d085 Mon Sep 17 00:00:00 2001 From: Louis Grignon Date: Fri, 10 Feb 2017 18:15:40 +0100 Subject: [PATCH] api es6 fixes + transpiler javadoc in target --- .../src/main/java/jsweet/util/Globals.java | 4 +- core-lib/es6/src/main/java/def/js/Object.java | 393 ++++++++++++------ .../src/main/java/jsweet/util/Globals.java | 4 +- transpiler/pom.xml | 2 +- .../typescript/Java2TypeScriptTranslator.java | 3 +- 5 files changed, 271 insertions(+), 135 deletions(-) diff --git a/core-lib/es5/src/main/java/jsweet/util/Globals.java b/core-lib/es5/src/main/java/jsweet/util/Globals.java index 2d59c961..a869ea72 100644 --- a/core-lib/es5/src/main/java/jsweet/util/Globals.java +++ b/core-lib/es5/src/main/java/jsweet/util/Globals.java @@ -553,7 +553,7 @@ public final class Globals { * the object typed after one of the types of the union type * @return the same object, but typed after a union type */ - native public static , T> U union3(T object); + native public static Union3 union3(T object); /** * This helper casts an object to an union type. @@ -566,7 +566,7 @@ public final class Globals { * the object typed after one of the types of the union type * @return the same object, but typed after a union type */ - native public static , T> U union4(T object); + native public static Union4 union4(T object); /** * This utility function allows using the typeof JavaScript diff --git a/core-lib/es6/src/main/java/def/js/Object.java b/core-lib/es6/src/main/java/def/js/Object.java index 469320be..00b4005d 100644 --- a/core-lib/es6/src/main/java/def/js/Object.java +++ b/core-lib/es6/src/main/java/def/js/Object.java @@ -1,131 +1,266 @@ package def.js; -public class Object { - /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ - public Function constructor; - /** Returns a string representation of an object. */ - native public java.lang.String toString(); - /** Returns a date converted to a string using the current locale. */ - native public java.lang.String toLocaleString(); - /** Returns the primitive value of the specified object. */ - native public java.lang.Object valueOf(); - /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ - native public java.lang.Boolean isPrototypeOf(java.lang.Object v); - public Object(java.lang.Object value){} - native public static java.lang.Object applyStatic(); - native public static java.lang.Object applyStatic(java.lang.Object value); - /** A reference to the prototype for a class of objects. */ - public static java.lang.Object prototype; - /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ - native public static java.lang.Object getPrototypeOf(java.lang.Object o); - /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ - native public static PropertyDescriptor getOwnPropertyDescriptor(java.lang.Object o, java.lang.String p); - /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ - native public static java.lang.String[] getOwnPropertyNames(java.lang.Object o); - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ - native public static java.lang.Object create(java.lang.Object o, PropertyDescriptorMap properties); - /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ - native public static java.lang.Object defineProperty(java.lang.Object o, java.lang.String p, PropertyDescriptor attributes); - /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ - native public static java.lang.Object defineProperties(java.lang.Object o, PropertyDescriptorMap properties); - /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - native public static T seal(T o); - /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - native public static T freeze(T o); - /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ - native public static T preventExtensions(T o); - /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ - native public static java.lang.Boolean isSealed(java.lang.Object o); - /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ - native public static java.lang.Boolean isFrozen(java.lang.Object o); - /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ - native public static java.lang.Boolean isExtensible(java.lang.Object o); - /** - * Returns the names of the enumerable properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - native public static java.lang.String[] keys(java.lang.Object o); - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - native public java.lang.Boolean hasOwnProperty(java.lang.String v); - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - native public java.lang.Boolean propertyIsEnumerable(java.lang.String v); - public Object(){} - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ - native public static java.lang.Object create(java.lang.Object o); - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - native public java.lang.Boolean hasOwnProperty(double v); - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - native public java.lang.Boolean hasOwnProperty(String v); - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - native public java.lang.Boolean propertyIsEnumerable(String v); - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - native public java.lang.Boolean propertyIsEnumerable(double v); -} +public class Object { + /** + * The initial value of Object.prototype.constructor is the standard + * built-in Object constructor. + */ + public Function constructor; + + /** Returns a string representation of an object. */ + native public java.lang.String toString(); + + /** Returns a date converted to a string using the current locale. */ + native public java.lang.String toLocaleString(); + + /** Returns the primitive value of the specified object. */ + native public java.lang.Object valueOf(); + + /** + * Determines whether an object exists in another object's prototype chain. + * + * @param v + * Another object whose prototype chain is to be checked. + */ + native public java.lang.Boolean isPrototypeOf(java.lang.Object v); + + public Object(java.lang.Object value) { + } + + native public static java.lang.Object applyStatic(); + + native public static java.lang.Object applyStatic(java.lang.Object value); + + /** A reference to the prototype for a class of objects. */ + public static java.lang.Object prototype; + + /** + * Returns the prototype of an object. + * + * @param o + * The object that references the prototype. + */ + native public static java.lang.Object getPrototypeOf(java.lang.Object o); + + /** + * Gets the own property descriptor of the specified object. An own property + * descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * + * @param o + * Object that contains the property. + * @param p + * Name of the property. + */ + native public static PropertyDescriptor getOwnPropertyDescriptor(java.lang.Object o, java.lang.String p); + + /** + * Returns the names of the own properties of an object. The own properties + * of an object are those that are defined directly on that object, and are + * not inherited from the object's prototype. The properties of an object + * include both fields (objects) and functions. + * + * @param o + * Object that contains the own properties. + */ + native public static java.lang.String[] getOwnPropertyNames(java.lang.Object o); + + /** + * Creates an object that has the specified prototype, and that optionally + * contains specified properties. + * + * @param o + * Object to use as a prototype. May be null + * @param properties + * JavaScript object that contains one or more property + * descriptors. + */ + native public static java.lang.Object create(java.lang.Object o, PropertyDescriptorMap properties); + + /** + * Adds a property to an object, or modifies attributes of an existing + * property. + * + * @param o + * Object on which to add or modify the property. This can be a + * native JavaScript object (that is, a user-defined object or a + * built in object) or a DOM object. + * @param p + * The property name. + * @param attributes + * Descriptor for the property. It can be for a data property or + * an accessor property. + */ + native public static java.lang.Object defineProperty(java.lang.Object o, java.lang.String p, + PropertyDescriptor attributes); + + /** + * Adds one or more properties to an object, and/or modifies attributes of + * existing properties. + * + * @param o + * Object on which to add or modify the properties. This can be a + * native JavaScript object or a DOM object. + * @param properties + * JavaScript object that contains one or more descriptor + * objects. Each descriptor object describes a data property or + * an accessor property. + */ + native public static java.lang.Object defineProperties(java.lang.Object o, PropertyDescriptorMap properties); + + /** + * Prevents the modification of attributes of existing properties, and + * prevents the addition of new properties. + * + * @param o + * Object on which to lock the attributes. + */ + native public static T seal(T o); + + /** + * Prevents the modification of existing property attributes and values, and + * prevents the addition of new properties. + * + * @param o + * Object on which to lock the attributes. + */ + native public static T freeze(T o); + + /** + * Prevents the addition of new properties to an object. + * + * @param o + * Object to make non-extensible. + */ + native public static T preventExtensions(T o); + + /** + * Returns true if existing property attributes cannot be modified in an + * object and new properties cannot be added to the object. + * + * @param o + * Object to test. + */ + native public static java.lang.Boolean isSealed(java.lang.Object o); + + /** + * Returns true if existing property attributes and values cannot be + * modified in an object, and new properties cannot be added to the object. + * + * @param o + * Object to test. + */ + native public static java.lang.Boolean isFrozen(java.lang.Object o); + + /** + * Returns a value that indicates whether new properties can be added to an + * object. + * + * @param o + * Object to test. + */ + native public static java.lang.Boolean isExtensible(java.lang.Object o); + + /** + * Returns the names of the enumerable properties and methods of an object. + * + * @param o + * Object that contains the properties and methods. This can be + * an object that you created or an existing Document Object + * Model (DOM) object. + */ + native public static java.lang.String[] keys(java.lang.Object o); + + /** + * Determines whether an object has a property with the specified name. + * + * @param v + * A property name. + */ + native public java.lang.Boolean hasOwnProperty(java.lang.String v); + + /** + * Determines whether a specified property is enumerable. + * + * @param v + * A property name. + */ + native public java.lang.Boolean propertyIsEnumerable(java.lang.String v); + + public Object() { + } + + /** + * Creates an object that has the specified prototype, and that optionally + * contains specified properties. + * + * @param o + * Object to use as a prototype. May be null + * @param properties + * JavaScript object that contains one or more property + * descriptors. + */ + native public static java.lang.Object create(java.lang.Object o); + + /** + * Determines whether an object has a property with the specified name. + * + * @param v + * A property name. + */ + native public java.lang.Boolean hasOwnProperty(double v); + + /** + * Determines whether an object has a property with the specified name. + * + * @param v + * A property name. + */ + native public java.lang.Boolean hasOwnProperty(String v); + + /** + * Determines whether a specified property is enumerable. + * + * @param v + * A property name. + */ + native public java.lang.Boolean propertyIsEnumerable(String v); + + /** + * Determines whether a specified property is enumerable. + * + * @param v + * A property name. + */ + native public java.lang.Boolean propertyIsEnumerable(double v); + + /** + * Gets the value for the given key. Generates this[key]. + * + * @see jsweet.util.Globals#$get(java.lang.String) + * @see jsweet.util.Globals#$set(java.lang.String,java.lang.Object) + * @see jsweet.util.Globals#$delete(java.lang.String) + */ + native public java.lang.Object $get(java.lang.String key); + + /** + * Sets the value for the given key. Generates this[key]=value. + * + * @see jsweet.util.Globals#$get(java.lang.String) + * @see jsweet.util.Globals#$set(java.lang.String,java.lang.Object) + * @see jsweet.util.Globals#$delete(java.lang.String) + */ + native public void $set(java.lang.String key, java.lang.Object value); + + /** + * Deletes the value of the given key. Generates + * delete this[key]. + * + * @see jsweet.util.Globals#$get(java.lang.String) + * @see jsweet.util.Globals#$set(java.lang.String,java.lang.Object) + * @see jsweet.util.Globals#$delete(java.lang.String) + */ + native public void $delete(java.lang.String key); + + native public java.lang.Object $super(java.lang.Object... params); +} diff --git a/core-lib/es6/src/main/java/jsweet/util/Globals.java b/core-lib/es6/src/main/java/jsweet/util/Globals.java index 4a5897ad..351156ad 100644 --- a/core-lib/es6/src/main/java/jsweet/util/Globals.java +++ b/core-lib/es6/src/main/java/jsweet/util/Globals.java @@ -553,7 +553,7 @@ public final class Globals { * the object typed after one of the types of the union type * @return the same object, but typed after a union type */ - native public static , T> U union3(T object); + native public static Union3 union3(T object); /** * This helper casts an object to an union type. @@ -566,7 +566,7 @@ public final class Globals { * the object typed after one of the types of the union type * @return the same object, but typed after a union type */ - native public static , T> U union4(T object); + native public static Union4 union4(T object); /** * This utility function allows using the typeof JavaScript diff --git a/transpiler/pom.xml b/transpiler/pom.xml index 88d3896f..d45f6454 100644 --- a/transpiler/pom.xml +++ b/transpiler/pom.xml @@ -131,7 +131,7 @@ all false /var/www/apidocs/org/jsweet - jsweet-transpiler-${project.version} + target/jsweet-transpiler-${project.version}
http://www.jsweet.org]]>
Copyright 2015, Cinchéo SAS - Web site: http://www.jsweet.org
]]> /var/www/apidocs/stylesheet.css diff --git a/transpiler/src/main/java/org/jsweet/transpiler/typescript/Java2TypeScriptTranslator.java b/transpiler/src/main/java/org/jsweet/transpiler/typescript/Java2TypeScriptTranslator.java index 0f174b6f..2016934a 100644 --- a/transpiler/src/main/java/org/jsweet/transpiler/typescript/Java2TypeScriptTranslator.java +++ b/transpiler/src/main/java/org/jsweet/transpiler/typescript/Java2TypeScriptTranslator.java @@ -2324,7 +2324,8 @@ public class Java2TypeScriptTranslator extends Abstract } String adaptedQualId = getAdapter().needsImport(importDecl, qualId); if (adaptedQualId != null && adaptedQualId.contains(".")) { - if (importDecl.isStatic() && !qualId.contains("." + JSweetConfig.GLOBALS_CLASS_NAME + ".")) { + if (importDecl.isStatic() && !qualId.contains("." + JSweetConfig.GLOBALS_CLASS_NAME + ".") + && !qualId.contains("." + JSweetConfig.STRING_TYPES_INTERFACE_NAME + ".")) { if (!context.bundleMode) { print(VAR_DECL_KEYWORD + " ").print(qualId.substring(qualId.lastIndexOf('.') + 1)).print(": any = ") .print(qualId).print(";");