Coder Social home page Coder Social logo

gojs's Introduction

Go JavaScript Bindings

Highly experiemental, I'm not even sure these work currently. Original author is Robery Johnstone, and his mercurial repository can be found at https://bitbucket.org/rj/golang-javascriptcore/. I have updated the bindings to work with the latest changes to the reflect API, bits of it manually. The entire test suite minus one function (finally!) passes.

Update (2013/10/16): The test suite does not work at all, but it compiles again with go 1.0. Feel free to hack away at this if you think it might be useful :).

Update (2013/12/26): Thanks to @sqs, the test suite now passes. This library should still be considered "experimental", but should work.

Install

go get github.com/crazy2be/gojs

Use:

package main

import (
	"github.com/crazy2be/gojs"
	"fmt"
)

func main() {
	ctx := gojs.NewContext()
	defer ctx.Release()

	ret, err := ctx.EvaluateScript("['hello', 'world'].join(' ')", nil, ".", 0)

	if err != nil {
		fmt.Println("Script had an error :(", ctx.ToStringOrDie(err))
		return
	}

	if ret == nil {
		fmt.Println("Nothing returned...")
		return
	}

	retstr := ctx.ToStringOrDie(ret)

	fmt.Println(retstr)
}

TODOs

(for anyone interested)

  1. Get the test suite to pass ;)
  2. Move as many functions as possible off of context. We should be able to make a nicely broken-down API where the conceptual weight is lower. For example, all of the functions that take obj *Object as the first parameter should really just be functions on *Object directly.
  3. ???
  4. PROFIT! (i.e. make something cool).

Documentation

There's not much documentation, because the original had no documentation. If I find a use for this beyond curiousity, I might add that as I go. Current documentation generated by godoc is available at http://godoc.org/github.com/crazy2be/gojs.

gojs's People

Contributors

crazy2be avatar sqs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gojs's Issues

Compile error

gojs/context.go:17: const initializer unsafe.Pointer(uintptr(0)) is not a constant

With go version go1.4 darwin/amd64

Move Methods Off of *Context

Methods relevant to *Values should be on *Values, not on *Context. I've started moving a few of these, leaving the old ones for compatibility with the existing codebase. Eventually, these old methods should be removed completely to avoid clutter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.