Sha256: 779be88f65adf6fe424d8e3d062a04fd09ac2da7261db2af56d89bd6de7be647

Contents?: true

Size: 1.61 KB

Versions: 26

Compression:

Stored size: 1.61 KB

Contents

#ifndef __convert_string_h__
#define __convert_string_h__

#include "v8.h"
#include <string>

/**
 * StringDest is a data type conversion destination that converts
 * any argument into a string.  It should have all methods listed
 * in data_conversion.txt so it can be used as a template argument
 * for a conversion source class.
 */
class StringDest {

public:
    StringDest();
    ~StringDest();

    std::string pushString(const std::string& value) {
        return value;
    }

#ifdef FIGURED_OUT_INT_ISSUES
    const char* pushInt(int32_t value) {
        char buffer[64];
        sprintf(buffer, "%d", value);
        convertedValue = buffer;
        return convertedValue.c_str();
    }
#endif

    std::string pushInt(int64_t value) {
        char buffer[64];
				sprintf(buffer, "%lld", value);
        std::string convertedValue(buffer);   
        return convertedValue;
    }

    std::string pushDouble(double value) {
        char buffer[64];
        sprintf(buffer, "%g", value);
        std::string convertedValue(buffer);   
        return convertedValue;
    }

    std::string pushBool(bool value) {
        std::string convertedValue(value ? TRUE : FALSE);
        return convertedValue;
    }

    std::string pushNull() {
      printf("I bet we aren't even getting here<br/>");
        return ""; // this kind of sucks
    }
    
    std::string pushUndefined() {
        return "undefined"; // this too
    }

private:

    /**
     * constant "true" used for pushBool
     */
    static const std::string TRUE;

    /**
     * constant "false" used for pushBool
     */
    static const std::string FALSE;
};

#endif

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
therubyracer-0.7.1 ext/v8/convert_string.h
therubyracer-0.7.1.pre ext/v8/convert_string.h
therubyracer-0.7.0 ext/v8/convert_string.h
therubyracer-0.7.0.pre ext/v8/convert_string.h
therubyracer-0.6.3 ext/v8/convert_string.h
therubyracer-0.6.2 ext/v8/convert_string.h
therubyracer-0.6.1 ext/v8/convert_string.h
therubyracer-0.6.0 ext/v8/convert_string.h
therubyracer-0.5.5 ext/v8/convert_string.h
therubyracer-0.5.4 ext/v8/convert_string.h
therubyracer-0.5.3 ext/v8/convert_string.h
therubyracer-0.5.2-x86-darwin-10 ext/v8/convert_string.h
therubyracer-0.5.2 ext/v8/convert_string.h
therubyracer-0.5.1-x86-darwin-9 ext/v8/convert_string.h
therubyracer-0.5.1-x86-darwin-10 ext/v8/convert_string.h
therubyracer-0.5.1 ext/v8/convert_string.h
therubyracer-0.5.0-x86-darwin-9 ext/v8/convert_string.h
therubyracer-0.5.0-x86-linux ext/v8/convert_string.h
therubyracer-0.5.0-x86_64-linux ext/v8/convert_string.h
therubyracer-0.4.9-x86_64-linux ext/v8/convert_string.h