static v8::Handle<v8::Value> itemCallback(const v8::Arguments& args) { INC_STATS("DOM.MediaList.item"); MediaList* imp = V8MediaList::toNative(args.Holder()); EXCEPTION_BLOCK(unsigned, index, toUInt32(args[0])); return v8StringOrNull(imp->item(index)); }
JSValue jsMediaListLength(ExecState* exec, JSValue slotBase, const Identifier&) { JSMediaList* castedThis = static_cast<JSMediaList*>(asObject(slotBase)); UNUSED_PARAM(exec); MediaList* imp = static_cast<MediaList*>(castedThis->impl()); JSValue result = jsNumber(imp->length()); return result; }
JSValue jsMediaListMediaText(ExecState* exec, JSValue slotBase, const Identifier&) { JSMediaList* castedThis = static_cast<JSMediaList*>(asObject(slotBase)); UNUSED_PARAM(exec); MediaList* imp = static_cast<MediaList*>(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->mediaText()); return result; }
void setJSMediaListMediaText(ExecState* exec, JSObject* thisObject, JSValue value) { JSMediaList* castedThis = static_cast<JSMediaList*>(thisObject); MediaList* imp = static_cast<MediaList*>(castedThis->impl()); ExceptionCode ec = 0; imp->setMediaText(valueToStringWithNullCheck(exec, value), ec); setDOMException(exec, ec); }
static void mediaTextAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.MediaList.mediaText._set"); MediaList* imp = V8MediaList::toNative(info.Holder()); V8Parameter<WithNullCheck> v = value; ExceptionCode ec = 0; imp->setMediaText(v, ec); if (UNLIKELY(ec)) V8Proxy::setDOMException(ec); return; }
void JSMediaList::putValueProperty(ExecState* exec, int token, JSValue* value) { switch (token) { case MediaTextAttrNum: { MediaList* imp = static_cast<MediaList*>(impl()); ExceptionCode ec = 0; imp->setMediaText(valueToStringWithNullCheck(exec, value), ec); setDOMException(exec, ec); break; } } }
JSValue* jsMediaListPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSMediaList::s_info)) return throwError(exec, TypeError); JSMediaList* castedThisObj = static_cast<JSMediaList*>(thisValue); MediaList* imp = static_cast<MediaList*>(castedThisObj->impl()); unsigned index = args.at(exec, 0)->toInt32(exec); JSC::JSValue* result = jsStringOrNull(exec, imp->item(index)); return result; }
JSValue* jsMediaListPrototypeFunctionAppendMedium(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSMediaList::s_info)) return throwError(exec, TypeError); JSMediaList* castedThisObj = static_cast<JSMediaList*>(thisValue); MediaList* imp = static_cast<MediaList*>(castedThisObj->impl()); ExceptionCode ec = 0; const UString& newMedium = args.at(exec, 0)->toString(exec); imp->appendMedium(newMedium, ec); setDOMException(exec, ec); return jsUndefined(); }
int main (int argc, char * argv []) { MediaList includeMedia; myStderr = stderr; printf ("MeMo Compiler v%s\n", VERSION); setExePath (argv[0]); if (argc < 2) { usage (argv[0]); } if (strcmp (argv[1], "-d") ==0) { dumpTable (argv[2]); return (0); } if (strcmp (argv[1], "-b") ==0) { ByteCode::generate (argv[2]); return (0); } bool verbose = false; int start = 1; char * dir = (char *)"."; char * file = NULL; while (start < argc) { if (strcmp (argv[start], "-v") == 0) { verbose = true; } else if (strcmp (argv[start], "-s") == 0) { myStderr = stdout; } else if (strcmp (argv[start], "-o") == 0) { start++; dir = strdup (argv[start]); } else if (strcmp (argv[start], "-I") == 0) { start++; MultiPathFile::addMultiplePaths (argv[start]); } else if (strcmp (argv[start], "-i") == 0) { start++; includeMedia.addMedia (argv[start]); } else if (strcmp (argv[start], "-h") ==0) { usage (argv[0]); return (0); } else if (strcmp (argv[start], "--compat") == 0) { ByteCode::s_compat = true; } else if (strcmp (argv[start], "--ignore-new-paths") == 0) { MultiPathFile::s_follow = false; } else { file = argv [start]; } start++; } if (file != NULL && endsWith (file, "wrl")) { compile (file, dir, includeMedia, verbose); } else { usage (argv[0]); } return (0); }
EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionItem(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSMediaList::s_info)) return throwVMTypeError(exec); JSMediaList* castedThis = static_cast<JSMediaList*>(asObject(thisValue)); MediaList* imp = static_cast<MediaList*>(castedThis->impl()); unsigned index(exec->argument(0).toUInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = jsStringOrNull(exec, imp->item(index)); return JSValue::encode(result); }
EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionAppendMedium(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSMediaList::s_info)) return throwVMTypeError(exec); JSMediaList* castedThis = static_cast<JSMediaList*>(asObject(thisValue)); MediaList* imp = static_cast<MediaList*>(castedThis->impl()); ExceptionCode ec = 0; const String& newMedium(ustringToString(exec->argument(0).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); imp->appendMedium(newMedium, ec); setDOMException(exec, ec); return JSValue::encode(jsUndefined()); }
JSValue* JSMediaList::getValueProperty(ExecState* exec, int token) const { switch (token) { case MediaTextAttrNum: { MediaList* imp = static_cast<MediaList*>(impl()); return jsStringOrNull(exec, imp->mediaText()); } case LengthAttrNum: { MediaList* imp = static_cast<MediaList*>(impl()); return jsNumber(exec, imp->length()); } case ConstructorAttrNum: return getConstructor(exec); } return 0; }
static v8::Handle<v8::Value> appendMediumCallback(const v8::Arguments& args) { INC_STATS("DOM.MediaList.appendMedium"); MediaList* imp = V8MediaList::toNative(args.Holder()); ExceptionCode ec = 0; { STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, newMedium, args[0]); imp->appendMedium(newMedium, ec); if (UNLIKELY(ec)) goto fail; return v8::Handle<v8::Value>(); } fail: V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); }
JSValue* JSMediaListPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) { if (!thisObj->inherits(&JSMediaList::info)) return throwError(exec, TypeError); JSMediaList* castedThisObj = static_cast<JSMediaList*>(thisObj); MediaList* imp = static_cast<MediaList*>(castedThisObj->impl()); switch (id) { case JSMediaList::ItemFuncNum: { bool indexOk; unsigned index = args[0]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = jsStringOrNull(imp->item(index)); return result; } case JSMediaList::DeleteMediumFuncNum: { ExceptionCode ec = 0; String oldMedium = args[0]->toString(exec); imp->deleteMedium(oldMedium, ec); setDOMException(exec, ec); return jsUndefined(); } case JSMediaList::AppendMediumFuncNum: { ExceptionCode ec = 0; String newMedium = args[0]->toString(exec); imp->appendMedium(newMedium, ec); setDOMException(exec, ec); return jsUndefined(); } } return 0; }
void compile (char * inName, char * dir, MediaList &includeMedia, bool verbose) { char * orgName = inName; MultiPathFile::addPath (inName, true); // main path is set as last path int cd = open (".", O_RDONLY); int i = lastIndexOf (inName, '/'); if (i >= 0) { inName [i] = '\0'; chdir (inName); //MultiPathFile::addPath (inName); inName += i+1; } char * binName = strdup (inName); strcpy (binName+strlen(binName)-3, "m4m"); printf ("compile %s -> %s/%s\n", orgName, dir, binName); Scene scene (binName, verbose); FILE * in = fopen (inName, "rb"); if (in == NULL) { fprintf (myStderr, "cannot open %s", inName); exit (1); } printf (">> Compiling scene %s\n", inName); scene.parse (inName, in, verbose); fchdir (cd); char * outName = (char *)malloc (strlen (binName)+strlen(dir)+2); sprintf (outName, "%s/%s", dir, binName); FILE * out = fopen (outName, "wb"); if (out == NULL) { fprintf (myStderr, "Cannot open %s for writing, please check if path exists\n", outName); exit (1); } int total = includeMedia.dump (out); total += scene.encode (out, verbose); total += FontManager::dumpAll (execPath, out); write (out, 0xFFFF); // final end of file printf ("<< End of scene %s [%d B]\n", inName, total); fclose (in); fclose (out); LocaleManager::checkMissingTranslations(); }
static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.MediaList.length._get"); MediaList* imp = V8MediaList::toNative(info.Holder()); return v8::Integer::NewFromUnsigned(imp->length()); }
static v8::Handle<v8::Value> mediaTextAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.MediaList.mediaText._get"); MediaList* imp = V8MediaList::toNative(info.Holder()); return v8StringOrNull(imp->mediaText()); }