Skip to content

Commit

Permalink
add NativeObject
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Sep 20, 2018
1 parent afea46c commit 864da93
Show file tree
Hide file tree
Showing 148 changed files with 539 additions and 283 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(SOURCES src/application_cache.cc
src/element.cc
src/event.cc
src/event_target.cc
src/export.cc
src/external.cc
src/history.cc
src/hit_region_options.cc
Expand Down Expand Up @@ -63,6 +64,8 @@ set(SOURCES src/application_cache.cc
src/media_list.cc
src/mime_type.cc
src/mime_type_array.cc
src/native_array.cc
src/native_object.cc
src/navigator.cc
src/node.cc
src/node_filter.cc
Expand Down
8 changes: 2 additions & 6 deletions include/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ NAMESPACE_HTML5_BEGIN;
class Array : public Object {
public:

Array();
Array(emscripten::val v);
virtual ~Array();
static Array *create();
void add(Object *o);

private:
std::vector<Object *> arr;
static Array *create(emscripten::val v);
};

NAMESPACE_HTML5_END;
1 change: 0 additions & 1 deletion include/array_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class ArrayBuffer : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(ArrayBuffer, unsigned long, byteLength);

Expand Down
1 change: 0 additions & 1 deletion include/array_buffer_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class ArrayBuffer;

class ArrayBufferView : public Object {
public:
emscripten::val v;

HTML5_PROPERTY_OBJECT(ArrayBufferView, ArrayBuffer, buffer);
HTML5_PROPERTY(ArrayBufferView, unsigned long, byteLength);
Expand Down
1 change: 0 additions & 1 deletion include/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class Attr : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(Attr, std::string, localName);
HTML5_PROPERTY(Attr, std::string, name);
Expand Down
1 change: 0 additions & 1 deletion include/audio_track.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class AudioTrack : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(AudioTrack, bool, enabled);
HTML5_PROPERTY(AudioTrack, std::string, id);
Expand Down
8 changes: 4 additions & 4 deletions include/auto_release_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

NAMESPACE_HTML5_BEGIN;

class Object;
class NativeObject;

class AutoReleasePool {
public:

AutoReleasePool();
~AutoReleasePool();
static AutoReleasePool *sharedInstance();
void addObject(Object *o);
void addObject(NativeObject *o);
void clear();
bool contains(Object *o) const;
bool contains(NativeObject *o) const;
void releaseObjects();

private:
std::vector<Object *> objects;
std::vector<NativeObject *> objects;
};

NAMESPACE_HTML5_END;
1 change: 0 additions & 1 deletion include/bar_prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class BarProp : public Object {
public:
emscripten::val v;
HTML5_PROPERTY(BarProp, bool, visible);

BarProp(emscripten::val v);
Expand Down
1 change: 0 additions & 1 deletion include/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class Blob : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(Blob, unsigned long long, size);
HTML5_PROPERTY(Blob, std::string, type);
Expand Down
1 change: 0 additions & 1 deletion include/canvas_gradient.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class CanvasGradient : public Object {
public:
emscripten::val v;

CanvasGradient(emscripten::val v);
virtual ~CanvasGradient();
Expand Down
1 change: 0 additions & 1 deletion include/canvas_pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class SVGMatrix;

class CanvasPattern : public Object {
public:
emscripten::val v;

CanvasPattern(emscripten::val v);
virtual ~CanvasPattern();
Expand Down
23 changes: 23 additions & 0 deletions include/console.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "libhtml5.h"

NAMESPACE_HTML5_BEGIN;

class Console : public Object {
public:
emscripten::val v;

Console(emscripten::val v);
virtual ~Console();
static Console *create(emscripten::val v);
void assert(bool expr, std::string ...args);
void clear();
void count();
void count(std::string label);
void countReset();
void countReset(std::string label);
void dir(Object *o);
};

NAMESPACE_HTML5_END;
2 changes: 0 additions & 2 deletions include/css_rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class CSSRule : public Object {
HOST_RULE = 1001,
};

emscripten::val v;

HTML5_PROPERTY(CSSRule, std::string, cssText);
HTML5_PROPERTY_OBJECT(CSSRule, CSSRule, parentRule);
HTML5_PROPERTY_OBJECT(CSSRule, CSSStyleSheet, parentStyleSheet);
Expand Down
1 change: 0 additions & 1 deletion include/css_rule_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class CSSRule;

class CSSRuleList : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(CSSRuleList, unsigned long, length);

Expand Down
1 change: 0 additions & 1 deletion include/css_style_declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class CSSRule;

class CSSStyleDeclaration : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(CSSStyleDeclaration, std::string, cssFloat);
HTML5_PROPERTY(CSSStyleDeclaration, std::string, cssText);
Expand Down
1 change: 0 additions & 1 deletion include/date.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class Date : public Object {
public:
emscripten::val v;

Date(emscripten::val v);
virtual ~Date();
Expand Down
1 change: 0 additions & 1 deletion include/document_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Node;

class DocumentType : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(DocumentType, std::string, name);
HTML5_PROPERTY(DocumentType, std::string, publicId);
Expand Down
1 change: 0 additions & 1 deletion include/dom_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class DOMError : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(DOMError, std::string, message);
HTML5_PROPERTY(DOMError, std::string, name);
Expand Down
1 change: 0 additions & 1 deletion include/dom_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class DocumentType;

class DOMImplementation : public Object {
public:
emscripten::val v;

DOMImplementation(emscripten::val v);
virtual ~DOMImplementation();
Expand Down
1 change: 0 additions & 1 deletion include/dom_token_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ NAMESPACE_HTML5_BEGIN;

class DOMTokenList : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(DOMTokenList, unsigned long, length);

Expand Down
2 changes: 0 additions & 2 deletions include/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class Event : public Object {
BUBBLING_PHASE = 3,
};

emscripten::val v;

HTML5_PROPERTY(Event, bool, bubbles);
HTML5_PROPERTY(Event, bool, cancelable);
HTML5_PROPERTY_OBJECT(Event, EventTarget, currentTarget);
Expand Down
1 change: 0 additions & 1 deletion include/event_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Event;

class EventTarget : public Object {
public:
emscripten::val v;

EventTarget(emscripten::val v);
virtual ~EventTarget();
Expand Down
65 changes: 65 additions & 0 deletions include/export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

// this is included by libhtml5.h

NAMESPACE_HTML5_BEGIN;

class Window;
class Document;
class ApplicationCache;
class Document;
class External;
class Element;
class History;
class IDBFactory;
class Storage;
class Location;
class BarProp;
class Navigator;
class Promise;
class CSSStyleDeclaration;
class HTMLImageElement;
class HTMLVideoElement;
class HTMLCanvasElement;
class Blob;
class ImageData;
class CanvasRenderingContext2D;
class ImageBitmap;
class Transferable;
class Performance;
class WindowProxy;

extern Window *window;
extern Document *document;

extern void alert(std::string message);
extern std::string atob(std::string atob);
extern void blur();
extern std::string btoa(std::string btoa);
extern void cancelAnimationFrame(long handle);
extern void clearInterval(long handle);
extern void clearTimeout(long handle);
extern void close();
extern bool confirm(std::string message);
extern Promise *createImageBitmap(HTMLImageElement *image, long sx, long sy, long sw, long sh);
extern Promise *createImageBitmap(HTMLVideoElement *image, long sx, long sy, long sw, long sh);
extern Promise *createImageBitmap(HTMLCanvasElement *image, long sx, long sy, long sw, long sh);
extern Promise *createImageBitmap(Blob *image, long sx, long sy, long sw, long sh);
extern Promise *createImageBitmap(ImageData *image, long sx, long sy, long sw, long sh);
extern Promise *createImageBitmap(CanvasRenderingContext2D *image, long sx, long sy, long sw, long sh);
extern Promise *createImageBitmap(ImageBitmap *image, long sx, long sy, long sw, long sh);
extern void focus();
extern CSSStyleDeclaration *getComputedStyle(Element *elt, std::string pseudoElt);
extern WindowProxy *getter(void *indexName);
extern WindowProxy *open(std::string url, std::string target, std::string features, bool replace);
extern void postMessage(void *message, std::string targetOrigin, std::vector<Transferable *> transfer);
extern void print();
extern std::string prompt(std::string message, std::string _default);
extern long requestAnimationFrame(std::function<void(double)> *callback);
extern long setInterval(std::function<void(void)> *handler, long timeout);
extern long setTimeout(std::function<void(void)> *handler, long timeout);
extern void stop();

NAMESPACE_HTML5_END;

extern void HTML5_INIT();
1 change: 0 additions & 1 deletion include/external.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class External : public Object {
public:
emscripten::val v;

External(emscripten::val v);
virtual ~External();
Expand Down
2 changes: 1 addition & 1 deletion include/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NAMESPACE_HTML5_BEGIN;

class History : public Object {
public:
emscripten::val v;

HTML5_READONLY_PROPERTY(History, long, length);
//HTML5_PROPERTY(History, void *, state);

Expand Down
1 change: 0 additions & 1 deletion include/hit_region_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Element;

class HitRegionOptions : public Object {
public:
emscripten::val v;

HTML5_PROPERTY_OBJECT(HitRegionOptions, Element, control);
HTML5_PROPERTY(HitRegionOptions, std::string, cursor);
Expand Down
1 change: 0 additions & 1 deletion include/html_collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Element;

class HTMLCollection : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(HTMLCollection, unsigned long, length);

Expand Down
1 change: 0 additions & 1 deletion include/idb_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class IDBFactory;

class IDBEnvironment : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(IDBEnvironment, IDBFactory *, indexedDB);

Expand Down
1 change: 0 additions & 1 deletion include/idb_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class IDBOpenDBRequest;

class IDBFactory : public Object {
public:
emscripten::val v;

IDBFactory(emscripten::val v);
virtual ~IDBFactory();
Expand Down
1 change: 0 additions & 1 deletion include/idb_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class IDBRequest;

class IDBIndex : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(IDBIndex, std::string, keyPath);
HTML5_PROPERTY(IDBIndex, bool, multiEntry);
Expand Down
1 change: 0 additions & 1 deletion include/idb_index_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class IDBIndexParameters : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(IDBIndexParameters, bool, multiEntry);
HTML5_PROPERTY(IDBIndexParameters, bool, unique);
Expand Down
1 change: 0 additions & 1 deletion include/idb_object_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class IDBTransaction;

class IDBObjectStore : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(IDBObjectStore, bool, autoIncrement);
HTML5_PROPERTY(IDBObjectStore, std::string, keyPath);
Expand Down
1 change: 0 additions & 1 deletion include/image_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ NAMESPACE_HTML5_BEGIN;

class ImageBitmap : public Object {
public:
emscripten::val v;

HTML5_PROPERTY(ImageBitmap, unsigned long, height);
HTML5_PROPERTY(ImageBitmap, unsigned long, width);
Expand Down
1 change: 0 additions & 1 deletion include/image_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Uint8ClampedArray;

class ImageData : public Object {
public:
emscripten::val v;

HTML5_PROPERTY_OBJECT(ImageData, Uint8ClampedArray, data);
HTML5_PROPERTY(ImageData, unsigned long, height);
Expand Down
Loading

0 comments on commit 864da93

Please sign in to comment.